2021-02-22 17:28:32 +08:00
|
|
|
name: Linting
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
2021-11-26 04:44:40 +08:00
|
|
|
concurrency:
|
2021-11-26 06:31:05 +08:00
|
|
|
group: linting-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}
|
2021-11-26 04:44:40 +08:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-07-30 23:22:03 +08:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2021-02-22 17:28:32 +08:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: run
|
|
|
|
runs-on: ubuntu-latest
|
2021-12-15 02:30:25 +08:00
|
|
|
container: discourse/discourse_test:slim
|
2021-02-22 17:28:32 +08:00
|
|
|
timeout-minutes: 30
|
|
|
|
|
|
|
|
steps:
|
2022-04-28 21:51:48 +08:00
|
|
|
- uses: actions/checkout@v3
|
2021-02-22 17:28:32 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
|
|
|
- name: Setup Git
|
|
|
|
run: |
|
|
|
|
git config --global user.email "ci@ci.invalid"
|
|
|
|
git config --global user.name "Discourse CI"
|
|
|
|
|
|
|
|
- name: Bundler cache
|
2022-03-31 18:51:42 +08:00
|
|
|
uses: actions/cache@v3
|
2021-02-22 17:28:32 +08:00
|
|
|
with:
|
|
|
|
path: vendor/bundle
|
|
|
|
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-gem-
|
|
|
|
|
|
|
|
- name: Setup gems
|
|
|
|
run: |
|
2022-01-13 05:50:04 +08:00
|
|
|
gem install bundler --conservative -v $(awk '/BUNDLED WITH/ { getline; gsub(/ /,""); print $0 }' Gemfile.lock)
|
2021-02-22 17:28:32 +08:00
|
|
|
bundle config --local path vendor/bundle
|
|
|
|
bundle config --local deployment true
|
|
|
|
bundle config --local without development
|
|
|
|
bundle install --jobs 4
|
|
|
|
bundle clean
|
|
|
|
|
|
|
|
- name: Get yarn cache directory
|
|
|
|
id: yarn-cache-dir
|
2022-11-11 21:12:08 +08:00
|
|
|
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
2021-02-22 17:28:32 +08:00
|
|
|
|
|
|
|
- name: Yarn cache
|
2022-03-31 18:51:42 +08:00
|
|
|
uses: actions/cache@v3
|
2021-02-22 17:28:32 +08:00
|
|
|
id: yarn-cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-
|
|
|
|
|
|
|
|
- name: Yarn install
|
|
|
|
run: yarn install
|
|
|
|
|
|
|
|
- name: Rubocop
|
2022-09-21 21:32:21 +08:00
|
|
|
if: ${{ !cancelled() }}
|
2022-07-07 13:29:14 +08:00
|
|
|
run: bundle exec rubocop --parallel .
|
2021-02-22 17:28:32 +08:00
|
|
|
|
|
|
|
- name: ESLint (core)
|
2022-09-21 21:32:21 +08:00
|
|
|
if: ${{ !cancelled() }}
|
2021-11-13 19:51:53 +08:00
|
|
|
run: yarn eslint app/assets/javascripts
|
2021-02-22 17:28:32 +08:00
|
|
|
|
|
|
|
- name: ESLint (core plugins)
|
2022-09-21 21:32:21 +08:00
|
|
|
if: ${{ !cancelled() }}
|
2021-11-13 19:51:53 +08:00
|
|
|
run: yarn eslint plugins
|
2021-02-22 17:28:32 +08:00
|
|
|
|
|
|
|
- name: Prettier
|
2022-09-21 21:32:21 +08:00
|
|
|
if: ${{ !cancelled() }}
|
2021-02-22 17:28:32 +08:00
|
|
|
run: |
|
|
|
|
yarn prettier -v
|
2022-07-07 13:29:14 +08:00
|
|
|
yarn pprettier --list-different \
|
2021-02-22 17:28:32 +08:00
|
|
|
"app/assets/stylesheets/**/*.scss" \
|
2021-11-13 19:51:53 +08:00
|
|
|
"app/assets/javascripts/**/*.js" \
|
2021-02-22 17:28:32 +08:00
|
|
|
"plugins/**/assets/stylesheets/**/*.scss" \
|
2021-11-13 19:51:53 +08:00
|
|
|
"plugins/**/assets/javascripts/**/*.js"
|
2021-02-22 17:28:32 +08:00
|
|
|
|
|
|
|
- name: Ember template lint
|
2022-09-21 21:32:21 +08:00
|
|
|
if: ${{ !cancelled() }}
|
2021-02-22 17:28:32 +08:00
|
|
|
run: |
|
|
|
|
yarn ember-template-lint \
|
2022-07-06 16:37:54 +08:00
|
|
|
--no-error-on-unmatched-pattern \
|
|
|
|
"app/assets/javascripts/**/*.hbs" \
|
|
|
|
"plugins/**/assets/javascripts/**/*.hbs"
|
2021-02-22 17:28:32 +08:00
|
|
|
|
|
|
|
- name: English locale lint (core)
|
2022-09-21 21:32:21 +08:00
|
|
|
if: ${{ !cancelled() }}
|
2021-02-22 17:28:32 +08:00
|
|
|
run: bundle exec ruby script/i18n_lint.rb "config/**/locales/{client,server}.en.yml"
|
|
|
|
|
|
|
|
- name: English locale lint (core plugins)
|
2022-09-21 21:32:21 +08:00
|
|
|
if: ${{ !cancelled() }}
|
2021-02-22 17:28:32 +08:00
|
|
|
run: bundle exec ruby script/i18n_lint.rb "plugins/**/locales/{client,server}.en.yml"
|