Skip to content

Commit 22ab679

Browse files
committed
DEV: Add linting, tests, copyright, license, etc.
1 parent 7e68d30 commit 22ab679

File tree

7 files changed

+524
-3
lines changed

7 files changed

+524
-3
lines changed
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Linting
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: 12
20+
21+
- name: Yarn install
22+
run: yarn install
23+
24+
- name: ESLint
25+
if: ${{ always() }}
26+
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,javascripts}
27+
28+
- name: Prettier
29+
if: ${{ always() }}
30+
shell: bash
31+
run: |
32+
yarn prettier -v
33+
shopt -s extglob
34+
if ls @(javascripts|desktop|mobile|common|scss)/**/*.@(scss|js|es6) &> /dev/null; then
35+
yarn prettier --list-different "@(javascripts|desktop|mobile|common|scss)/**/*.{scss,js,es6}"
36+
fi
37+
if ls test/**/*.@(js|es6) &> /dev/null; then
38+
yarn prettier --list-different "test/**/*.{js,es6}"
39+
fi
40+
41+
- name: Ember template lint
42+
if: ${{ always() }}
43+
run: yarn ember-template-lint javascripts

.github/workflows/component-tests.yml

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
container: discourse/discourse_test:slim-browsers
13+
timeout-minutes: 30
14+
15+
env:
16+
DISCOURSE_HOSTNAME: www.example.com
17+
RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072
18+
RAILS_ENV: development
19+
QUNIT_RAILS_ENV: development
20+
PGHOST: postgres
21+
PGUSER: discourse
22+
PGPASSWORD: discourse
23+
24+
services:
25+
postgres:
26+
image: postgres:13
27+
ports:
28+
- 5432:5432
29+
env:
30+
POSTGRES_USER: discourse
31+
POSTGRES_PASSWORD: discourse
32+
options: >-
33+
--mount type=tmpfs,destination=/var/lib/postgresql/data
34+
--health-cmd pg_isready
35+
--health-interval 10s
36+
--health-timeout 5s
37+
--health-retries 5
38+
39+
steps:
40+
- uses: actions/checkout@v2
41+
with:
42+
repository: discourse/discourse
43+
fetch-depth: 1
44+
45+
- name: Install component
46+
uses: actions/checkout@v2
47+
with:
48+
path: tmp/component
49+
fetch-depth: 1
50+
51+
- name: Setup Git
52+
run: |
53+
git config --global user.email "[email protected]"
54+
git config --global user.name "Discourse CI"
55+
56+
- name: Start redis
57+
run: |
58+
redis-server /etc/redis/redis.conf &
59+
60+
- name: Start Postgres
61+
run: |
62+
chown -R postgres /var/run/postgresql
63+
sudo -E -u postgres script/start_test_db.rb
64+
sudo -u postgres psql -c "CREATE ROLE $PGUSER LOGIN SUPERUSER PASSWORD '$PGPASSWORD';"
65+
66+
- name: Bundler cache
67+
uses: actions/cache@v2
68+
with:
69+
path: vendor/bundle
70+
key: ${{ runner.os }}-2.7-gem-${{ hashFiles('**/Gemfile.lock') }}
71+
restore-keys: |
72+
${{ runner.os }}-2.7-gem-
73+
74+
- name: Setup gems
75+
run: |
76+
bundle config --local path vendor/bundle
77+
bundle config --local deployment true
78+
bundle config --local without development
79+
bundle install --jobs 4
80+
bundle clean
81+
82+
- name: Get yarn cache directory
83+
id: yarn-cache-dir
84+
run: echo "::set-output name=dir::$(yarn cache dir)"
85+
86+
- name: Yarn cache
87+
uses: actions/cache@v2
88+
id: yarn-cache
89+
with:
90+
path: ${{ steps.yarn-cache-dir.outputs.dir }}
91+
key: ${{ runner.os }}-${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
92+
restore-keys: |
93+
${{ runner.os }}-${{ matrix.os }}-yarn-
94+
95+
- name: Yarn install
96+
run: yarn install
97+
98+
- name: Migrate database
99+
run: |
100+
bin/rake db:create
101+
bin/rake db:migrate
102+
103+
- name: Check qunit existence
104+
id: check_qunit
105+
shell: bash
106+
run: |
107+
shopt -s extglob
108+
if ls tmp/component/test/**/*.@(js|es6) &> /dev/null; then
109+
echo "::set-output name=files_exist::true"
110+
fi
111+
112+
- name: Component QUnit
113+
if: steps.check_qunit.outputs.files_exist == 'true'
114+
run: |
115+
bundle exec rake themes:install -- '--{"${{ github.event.repository.name }}": "tmp/component"}'
116+
UNICORN_TIMEOUT=120 bundle exec rake themes:qunit[name,${{ github.event.repository.name }}]
117+
timeout-minutes: 10
118+
119+
- name: Lint English locale
120+
if: ${{ always() }}
121+
run: bundle exec ruby script/i18n_lint.rb "tmp/component/locales/en.yml"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.discourse-site
22
node_modules
33
HELP
4+
.DS_Store

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

COPYRIGHT.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
All code in this repository is Copyright 2022 by Keegan George.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; either version 2 of the License, or (at
6+
your option) any later version.
7+
8+
This program is distributed in the hope that it will be useful, but
9+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11+
for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program as the file LICENSE.txt; if not, please see
15+
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

0 commit comments

Comments
 (0)