DEV: Update CI workflows (#10)

DEV: Update CI workflows (#10)

Included:

  • Prettier/eslint/gitignore configuration
  • Fix template linting issues
diff --git a/.eslintignore b/.eslintignore
index 75bcf55..0cc57cf 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,2 +1,2 @@
 support/*
-public/*
\ No newline at end of file
+public/*
diff --git a/.github/workflows/plugin-linting.yml b/.github/workflows/plugin-linting.yml
index 5a20ec2..3d7f6d9 100644
--- a/.github/workflows/plugin-linting.yml
+++ b/.github/workflows/plugin-linting.yml
@@ -1,41 +1,52 @@
 name: Linting
 
-on: [push, pull_request]
+on:
+  push:
+    branches:
+      - master
+      - main
+  pull_request:
 
 jobs:
   build:
     runs-on: ubuntu-latest
 
     steps:
-    - uses: actions/checkout@v2
-
-    - name: Set up Node.js
-      uses: actions/setup-node@v1
-      with:
-        node-version: 12
-
-    - name: Set up ruby
-      uses: actions/setup-ruby@v1
-      with:
-        ruby-version: 2.7
-
-    - name: Setup bundler
-      run: gem install bundler -v 2.1.4 --no-doc
-
-    - name: Setup gems
-      run: bundle install --jobs 4
-
-    - name: Yarn install
-      run: yarn install --dev
-
-    - name: ESLint
-      run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern assets/javascripts
-
-    - name: Prettier
-      run: |
-        yarn prettier -v
-        yarn prettier --list-different \
-          "assets/**/*.{scss,js,es6}"
-
-    - name: Rubocop
-      run: bundle exec rubocop .
+      - uses: actions/checkout@v2
+
+      - name: Set up Node.js
+        uses: actions/setup-node@v1
+        with:
+          node-version: 12
+
+      - name: Set up ruby
+        uses: ruby/setup-ruby@v1
+        with:
+          ruby-version: 2.7
+          bundler-cache: true
+
+      - name: Yarn install
+        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() }}
+        run: |
+          yarn prettier -v
+          if [ -d "assets" ]; then \
+            yarn prettier --list-different "assets/**/*.{scss,js,es6}" ; \
+          fi
+          if [ -d "test" ]; 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 fb2afda..ff87d58 100644
--- a/.github/workflows/plugin-tests.yml
+++ b/.github/workflows/plugin-tests.yml
@@ -1,20 +1,24 @@
 name: Plugin Tests
 
-on: [push, pull_request]
+on:
+  push:
+    branches:
+      - master
+      - main
+  pull_request:
 
 jobs:
   build:
-    name: "${{ matrix.target }}-${{ matrix.build_types }}"
-    runs-on: ${{ matrix.os }}
+    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
-      BUILD_TYPE: ${{ matrix.build_types }}
-      TARGET: ${{ matrix.target }}
       RAILS_ENV: test
-      PGHOST: localhost
+      PGHOST: postgres
       PGUSER: discourse
       PGPASSWORD: discourse
 
@@ -22,12 +26,10 @@ jobs:
       fail-fast: false
 
       matrix:
-        build_types: ["BACKEND", "FRONTEND"]
-        target: ["PLUGINS", "CORE"]
-        os: [ubuntu-latest]
-        ruby: ["2.6"]
-        postgres: ["12"]
-        redis: ["4.x"]
+        build_type: ['backend', 'frontend']
+        ruby: ['2.7']
+        postgres: ['12']
+        redis: ['4.x']
 
     services:
       postgres:
@@ -45,13 +47,13 @@ jobs:
           --health-retries 5
 
     steps:
-      - uses: actions/checkout@master
+      - uses: actions/checkout@v2
         with:
           repository: discourse/discourse
           fetch-depth: 1
 
       - name: Install plugin
-        uses: actions/checkout@master
+        uses: actions/checkout@v2
         with:
           path: plugins/${{ github.event.repository.name }}
           fetch-depth: 1
@@ -60,66 +62,50 @@ jobs:
         id: check_spec
         uses: andstor/file-existence-action@v1
         with:
-          files: "plugins/${{ github.event.repository.name }}/spec"
+          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"
+          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: env.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: 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
-        uses: actions/cache@v1
-        id: bundler-cache
+        uses: actions/cache@v2
         with:
           path: vendor/bundle
-          key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
+          key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
           restore-keys: |
-            ${{ runner.os }}-gem-
+            ${{ runner.os }}-${{ matrix.ruby }}-gem-
 
       - 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
         id: yarn-cache-dir
         run: echo "::set-output name=dir::$(yarn cache dir)"
 
       - name: Yarn cache
-        uses: actions/cache@v1
+        uses: actions/cache@v2
         id: yarn-cache
         with:
           path: ${{ steps.yarn-cache-dir.outputs.dir }}
@@ -128,35 +114,18 @@ 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: Create parallel databases
-        if: env.BUILD_TYPE == 'BACKEND' && env.TARGET == 'CORE'
-        run: |
-          bin/rake parallel:create
-          bin/rake parallel:migrate
-
-      - name: Core RSpec
-        if: env.BUILD_TYPE == 'BACKEND' && env.TARGET == 'CORE'
-        run: |
-          bin/turbo_rspec
-          bin/rake plugin:spec
-
       - name: Plugin RSpec
-        if: env.BUILD_TYPE == 'BACKEND' && env.TARGET == 'PLUGINS' && steps.check_spec.outputs.files_exists == 'true'

[... diff too long, it was truncated ...]

GitHub sha: 2b417f05

1 Like

This commit appears in #10 which was approved by techAPJ. It was merged by CvX.