DEV: Update CI workflows (#91)

Co-authored-by: davidtaylorhq <davidtaylorhq@users.noreply.github.com>
This commit is contained in:
discoursebot 2021-07-05 14:58:19 -04:00 committed by GitHub
parent 4354e1b766
commit da4ad30477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 62 deletions

View File

@ -20,31 +20,35 @@ jobs:
node-version: 12 node-version: 12
- name: Set up ruby - name: Set up ruby
uses: actions/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: 2.7 ruby-version: 2.7
bundler-cache: true
- name: Setup bundler
run: gem install bundler -v 2.1.4 --no-doc
- name: Setup gems
run: bundle install --jobs 4
- name: Yarn install - name: Yarn install
run: yarn install --dev run: yarn install
- name: ESLint - name: ESLint
if: ${{ always() }}
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts
- name: Prettier - name: Prettier
if: ${{ always() }}
shell: bash
run: | run: |
yarn prettier -v yarn prettier -v
if [ -d "assets" ]; then \ shopt -s extglob
yarn prettier --list-different "assets/**/*.{scss,js,es6}" ; \ if ls assets/**/*.@(scss|js|es6) &> /dev/null; then
yarn prettier --list-different "assets/**/*.{scss,js,es6}"
fi fi
if [ -d "test" ]; then \ if ls test/**/*.@(js|es6) &> /dev/null; then
yarn prettier --list-different "test/**/*.{js,es6}" ; \ yarn prettier --list-different "test/**/*.{js,es6}"
fi fi
- name: Ember template lint
if: ${{ always() }}
run: yarn ember-template-lint assets/javascripts
- name: Rubocop - name: Rubocop
if: ${{ always() }}
run: bundle exec rubocop . run: bundle exec rubocop .

View File

@ -10,14 +10,15 @@ on:
jobs: jobs:
build: build:
name: ${{ matrix.build_type }} name: ${{ matrix.build_type }}
runs-on: ${{ matrix.os }} runs-on: ubuntu-latest
container: discourse/discourse_test:release
timeout-minutes: 60 timeout-minutes: 60
env: env:
DISCOURSE_HOSTNAME: www.example.com DISCOURSE_HOSTNAME: www.example.com
RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072 RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072
RAILS_ENV: test RAILS_ENV: test
PGHOST: localhost PGHOST: postgres
PGUSER: discourse PGUSER: discourse
PGPASSWORD: discourse PGPASSWORD: discourse
@ -26,9 +27,8 @@ jobs:
matrix: matrix:
build_type: ["backend", "frontend"] build_type: ["backend", "frontend"]
os: [ubuntu-latest] ruby: ["2.7"]
ruby: ["2.6"] postgres: ["13"]
postgres: ["12"]
redis: ["4.x"] redis: ["4.x"]
services: services:
@ -47,74 +47,46 @@ jobs:
--health-retries 5 --health-retries 5
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@v2
with: with:
repository: discourse/discourse repository: discourse/discourse
fetch-depth: 1 fetch-depth: 1
- name: Install plugin - name: Install plugin
uses: actions/checkout@master uses: actions/checkout@v2
with: with:
path: plugins/${{ github.event.repository.name }} path: plugins/${{ github.event.repository.name }}
fetch-depth: 1 fetch-depth: 1
- name: Check spec existence
id: check_spec
uses: andstor/file-existence-action@v1
with:
files: "plugins/${{ github.event.repository.name }}/spec"
- name: Check qunit existence
id: check_qunit
uses: andstor/file-existence-action@v1
with:
files: "plugins/${{ github.event.repository.name }}/test/javascripts"
- name: Setup Git - name: Setup Git
run: | run: |
git config --global user.email "ci@ci.invalid" git config --global user.email "ci@ci.invalid"
git config --global user.name "Discourse CI" git config --global user.name "Discourse CI"
- name: Setup packages
run: |
sudo apt-get update
sudo apt-get -yqq install postgresql-client libpq-dev gifsicle jpegoptim optipng jhead
wget -qO- https://raw.githubusercontent.com/discourse/discourse_docker/master/image/base/install-pngquant | sudo sh
- name: Update imagemagick
if: matrix.build_type == 'backend'
run: |
wget https://raw.githubusercontent.com/discourse/discourse_docker/master/image/base/install-imagemagick
chmod +x install-imagemagick
sudo ./install-imagemagick
- name: Setup redis - name: Setup redis
uses: shogo82148/actions-setup-redis@v1 uses: shogo82148/actions-setup-redis@v1
with: with:
redis-version: ${{ matrix.redis }} redis-version: ${{ matrix.redis }}
- name: Setup ruby
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Setup bundler
run: |
gem install bundler -v 2.1.4 --no-doc
bundle config deployment 'true'
bundle config without 'development'
- name: Bundler cache - name: Bundler cache
uses: actions/cache@v2 uses: actions/cache@v2
id: bundler-cache
with: with:
path: vendor/bundle path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: | restore-keys: |
${{ runner.os }}-gem- ${{ runner.os }}-${{ matrix.ruby }}-gem-
- name: Setup gems - name: Setup gems
run: bundle install --jobs 4 run: |
bundle config --local path vendor/bundle
bundle config --local deployment true
bundle config --local without development
bundle install --jobs 4
bundle clean
- name: Lint English locale
if: matrix.build_type == 'backend'
run: bundle exec ruby script/i18n_lint.rb "plugins/${{ github.event.repository.name }}/locales/{client,server}.en.yml"
- name: Get yarn cache directory - name: Get yarn cache directory
id: yarn-cache-dir id: yarn-cache-dir
@ -130,18 +102,36 @@ jobs:
${{ runner.os }}-${{ matrix.os }}-yarn- ${{ runner.os }}-${{ matrix.os }}-yarn-
- name: Yarn install - name: Yarn install
run: yarn install --dev run: yarn install
- name: Migrate database - name: Migrate database
run: | run: |
bin/rake db:create bin/rake db:create
bin/rake db:migrate bin/rake db:migrate
- name: Check spec existence
id: check_spec
shell: bash
run: |
shopt -s extglob
if ls plugins/${{ github.event.repository.name }}/spec/**/*.@(rb) &> /dev/null; then
echo "::set-output name=files_exist::true"
fi
- name: Plugin RSpec - name: Plugin RSpec
if: matrix.build_type == 'backend' && steps.check_spec.outputs.files_exists == 'true' if: matrix.build_type == 'backend' && steps.check_spec.outputs.files_exist == 'true'
run: bin/rake plugin:spec[${{ github.event.repository.name }}] run: bin/rake plugin:spec[${{ github.event.repository.name }}]
- name: Check qunit existence
id: check_qunit
shell: bash
run: |
shopt -s extglob
if ls plugins/${{ github.event.repository.name }}/test/javascripts/**/*.@(js|es6) &> /dev/null; then
echo "::set-output name=files_exist::true"
fi
- name: Plugin QUnit - name: Plugin QUnit
if: matrix.build_type == 'frontend' && steps.check_qunit.outputs.files_exists == 'true' if: matrix.build_type == 'frontend' && steps.check_qunit.outputs.files_exist == 'true'
run: bundle exec rake plugin:qunit['${{ github.event.repository.name }}','1200000'] run: bundle exec rake plugin:qunit['${{ github.event.repository.name }}','1200000']
timeout-minutes: 30 timeout-minutes: 30