From ad34b55738598b5f04654140350409e340655ab3 Mon Sep 17 00:00:00 2001 From: davidtaylorhq Date: Fri, 2 Jul 2021 13:00:51 +0000 Subject: [PATCH 1/2] DEV: Update CI workflows --- .github/workflows/plugin-linting.yml | 20 ++++---- .github/workflows/plugin-tests.yml | 72 +++++++++++++++------------- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/.github/workflows/plugin-linting.yml b/.github/workflows/plugin-linting.yml index affe103..51b9b82 100644 --- a/.github/workflows/plugin-linting.yml +++ b/.github/workflows/plugin-linting.yml @@ -23,28 +23,32 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 - - - name: Setup gems - run: bundle install --jobs 4 + bundler-cache: true - name: Yarn install - run: yarn install --dev + run: yarn install - name: ESLint + if: ${{ always() }} run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts - name: Prettier + if: ${{ always() }} + shell: bash run: | yarn prettier -v - if [ -d "assets" ]; then \ - yarn prettier --list-different "assets/**/*.{scss,js,es6}" ; \ + shopt -s extglob + if ls assets/**/*.@(scss|js|es6) &> /dev/null; then + yarn prettier --list-different "assets/**/*.{scss,js,es6}" fi - if [ -d "test" ]; then \ - yarn prettier --list-different "test/**/*.{js,es6}" ; \ + if ls test/**/*.@(js|es6) &> /dev/null; then + yarn prettier --list-different "test/**/*.{js,es6}" fi - name: Ember template lint + if: ${{ always() }} run: yarn ember-template-lint assets/javascripts - name: Rubocop + if: ${{ always() }} run: bundle exec rubocop . diff --git a/.github/workflows/plugin-tests.yml b/.github/workflows/plugin-tests.yml index ad05806..b28d0e2 100644 --- a/.github/workflows/plugin-tests.yml +++ b/.github/workflows/plugin-tests.yml @@ -11,13 +11,14 @@ jobs: build: name: ${{ matrix.build_type }} runs-on: ubuntu-latest + container: discourse/discourse_test:release timeout-minutes: 60 env: DISCOURSE_HOSTNAME: www.example.com RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072 RAILS_ENV: test - PGHOST: localhost + PGHOST: postgres PGUSER: discourse PGPASSWORD: discourse @@ -27,7 +28,7 @@ jobs: matrix: build_type: ["backend", "frontend"] ruby: ["2.7"] - postgres: ["12"] + postgres: ["13"] redis: ["4.x"] services: @@ -57,46 +58,31 @@ jobs: path: plugins/${{ github.event.repository.name }} 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 run: | git config --global user.email "ci@ci.invalid" 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 uses: shogo82148/actions-setup-redis@v1 with: redis-version: ${{ matrix.redis }} - - name: Setup ruby - uses: ruby/setup-ruby@v1 + - name: Bundler cache + uses: actions/cache@v2 with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true + path: vendor/bundle + key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.ruby }}-gem- + + - name: Setup gems + 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' @@ -116,18 +102,36 @@ jobs: ${{ runner.os }}-${{ matrix.os }}-yarn- - name: Yarn install - run: yarn install --dev + run: yarn install - name: Migrate database run: | bin/rake db:create 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 - 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 }}] + - 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 - 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'] timeout-minutes: 30 From 10041c3e6b80fd2bba61493585a1d864dd0727db Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Sun, 4 Jul 2021 23:39:12 +0200 Subject: [PATCH 2/2] Fix rubocop --- .gitignore | 4 +--- .rubocop.yml | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 113898a..5b586b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -gems/* +/gems node_modules -yarn-error.log -.rubocop-https---raw-githubusercontent-com-discourse-* diff --git a/.rubocop.yml b/.rubocop.yml index e6ca29f..81b3b65 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,4 +2,5 @@ inherit_gem: rubocop-discourse: default.yml AllCops: Exclude: - - 'gems/**/*' + - "gems/**/*" + - "vendor/bundle/**/*"