Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 154fd5e

Browse files
discoursebotdavidtaylorhqCvX
authored
DEV: Update CI workflows (#27)
* DEV: Update CI workflows * Fix rubocop Co-authored-by: davidtaylorhq <davidtaylorhq@users.noreply.github.com> Co-authored-by: Jarek Radosz <jradosz@gmail.com>
1 parent 151e353 commit 154fd5e

File tree

4 files changed

+53
-46
lines changed

4 files changed

+53
-46
lines changed

.github/workflows/plugin-linting.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,32 @@ jobs:
2323
uses: ruby/setup-ruby@v1
2424
with:
2525
ruby-version: 2.7
26-
27-
- name: Setup gems
28-
run: bundle install --jobs 4
26+
bundler-cache: true
2927

3028
- name: Yarn install
31-
run: yarn install --dev
29+
run: yarn install
3230

3331
- name: ESLint
32+
if: ${{ always() }}
3433
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts
3534

3635
- name: Prettier
36+
if: ${{ always() }}
37+
shell: bash
3738
run: |
3839
yarn prettier -v
39-
if [ -d "assets" ]; then \
40-
yarn prettier --list-different "assets/**/*.{scss,js,es6}" ; \
40+
shopt -s extglob
41+
if ls assets/**/*.@(scss|js|es6) &> /dev/null; then
42+
yarn prettier --list-different "assets/**/*.{scss,js,es6}"
4143
fi
42-
if [ -d "test" ]; then \
43-
yarn prettier --list-different "test/**/*.{js,es6}" ; \
44+
if ls test/**/*.@(js|es6) &> /dev/null; then
45+
yarn prettier --list-different "test/**/*.{js,es6}"
4446
fi
4547
4648
- name: Ember template lint
49+
if: ${{ always() }}
4750
run: yarn ember-template-lint assets/javascripts
4851

4952
- name: Rubocop
53+
if: ${{ always() }}
5054
run: bundle exec rubocop .

.github/workflows/plugin-tests.yml

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ jobs:
1111
build:
1212
name: ${{ matrix.build_type }}
1313
runs-on: ubuntu-latest
14+
container: discourse/discourse_test:release
1415
timeout-minutes: 60
1516

1617
env:
1718
DISCOURSE_HOSTNAME: www.example.com
1819
RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072
1920
RAILS_ENV: test
20-
PGHOST: localhost
21+
PGHOST: postgres
2122
PGUSER: discourse
2223
PGPASSWORD: discourse
2324

@@ -27,7 +28,7 @@ jobs:
2728
matrix:
2829
build_type: ["backend", "frontend"]
2930
ruby: ["2.7"]
30-
postgres: ["12"]
31+
postgres: ["13"]
3132
redis: ["4.x"]
3233

3334
services:
@@ -57,46 +58,31 @@ jobs:
5758
path: plugins/${{ github.event.repository.name }}
5859
fetch-depth: 1
5960

60-
- name: Check spec existence
61-
id: check_spec
62-
uses: andstor/file-existence-action@v1
63-
with:
64-
files: "plugins/${{ github.event.repository.name }}/spec"
65-
66-
- name: Check qunit existence
67-
id: check_qunit
68-
uses: andstor/file-existence-action@v1
69-
with:
70-
files: "plugins/${{ github.event.repository.name }}/test/javascripts"
71-
7261
- name: Setup Git
7362
run: |
7463
git config --global user.email "ci@ci.invalid"
7564
git config --global user.name "Discourse CI"
7665
77-
- name: Setup packages
78-
run: |
79-
sudo apt-get update
80-
sudo apt-get -yqq install postgresql-client libpq-dev gifsicle jpegoptim optipng jhead
81-
wget -qO- https://raw.githubusercontent.com/discourse/discourse_docker/master/image/base/install-pngquant | sudo sh
82-
83-
- name: Update imagemagick
84-
if: matrix.build_type == 'backend'
85-
run: |
86-
wget https://raw.githubusercontent.com/discourse/discourse_docker/master/image/base/install-imagemagick
87-
chmod +x install-imagemagick
88-
sudo ./install-imagemagick
89-
9066
- name: Setup redis
9167
uses: shogo82148/actions-setup-redis@v1
9268
with:
9369
redis-version: ${{ matrix.redis }}
9470

95-
- name: Setup ruby
96-
uses: ruby/setup-ruby@v1
71+
- name: Bundler cache
72+
uses: actions/cache@v2
9773
with:
98-
ruby-version: ${{ matrix.ruby }}
99-
bundler-cache: true
74+
path: vendor/bundle
75+
key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
76+
restore-keys: |
77+
${{ runner.os }}-${{ matrix.ruby }}-gem-
78+
79+
- name: Setup gems
80+
run: |
81+
bundle config --local path vendor/bundle
82+
bundle config --local deployment true
83+
bundle config --local without development
84+
bundle install --jobs 4
85+
bundle clean
10086
10187
- name: Lint English locale
10288
if: matrix.build_type == 'backend'
@@ -116,18 +102,36 @@ jobs:
116102
${{ runner.os }}-${{ matrix.os }}-yarn-
117103
118104
- name: Yarn install
119-
run: yarn install --dev
105+
run: yarn install
120106

121107
- name: Migrate database
122108
run: |
123109
bin/rake db:create
124110
bin/rake db:migrate
125111
112+
- name: Check spec existence
113+
id: check_spec
114+
shell: bash
115+
run: |
116+
shopt -s extglob
117+
if ls plugins/${{ github.event.repository.name }}/spec/**/*.@(rb) &> /dev/null; then
118+
echo "::set-output name=files_exist::true"
119+
fi
120+
126121
- name: Plugin RSpec
127-
if: matrix.build_type == 'backend' && steps.check_spec.outputs.files_exists == 'true'
122+
if: matrix.build_type == 'backend' && steps.check_spec.outputs.files_exist == 'true'
128123
run: bin/rake plugin:spec[${{ github.event.repository.name }}]
129124

125+
- name: Check qunit existence
126+
id: check_qunit
127+
shell: bash
128+
run: |
129+
shopt -s extglob
130+
if ls plugins/${{ github.event.repository.name }}/test/javascripts/**/*.@(js|es6) &> /dev/null; then
131+
echo "::set-output name=files_exist::true"
132+
fi
133+
130134
- name: Plugin QUnit
131-
if: matrix.build_type == 'frontend' && steps.check_qunit.outputs.files_exists == 'true'
135+
if: matrix.build_type == 'frontend' && steps.check_qunit.outputs.files_exist == 'true'
132136
run: bundle exec rake plugin:qunit['${{ github.event.repository.name }}','1200000']
133137
timeout-minutes: 30

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
gems/*
1+
/gems
22
node_modules
3-
yarn-error.log
4-
.rubocop-https---raw-githubusercontent-com-discourse-*

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ inherit_gem:
22
rubocop-discourse: default.yml
33
AllCops:
44
Exclude:
5-
- 'gems/**/*'
5+
- "gems/**/*"
6+
- "vendor/bundle/**/*"

0 commit comments

Comments
 (0)