2021-02-22 03:28:32 -06:00
|
|
|
name: Linting
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
2021-11-25 14:44:40 -06:00
|
|
|
concurrency:
|
2021-11-25 16:31:05 -06:00
|
|
|
group: linting-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}
|
2021-11-25 14:44:40 -06:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-07-30 10:22:03 -05:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2021-02-22 03:28:32 -06:00
|
|
|
jobs:
|
|
|
|
build:
|
2023-05-12 07:00:04 -05:00
|
|
|
if: github.event_name == 'pull_request' || github.repository != 'discourse/discourse-private-mirror'
|
2021-02-22 03:28:32 -06:00
|
|
|
name: run
|
|
|
|
runs-on: ubuntu-latest
|
2021-12-14 12:30:25 -06:00
|
|
|
container: discourse/discourse_test:slim
|
2021-02-22 03:28:32 -06:00
|
|
|
timeout-minutes: 30
|
|
|
|
|
|
|
|
steps:
|
2023-02-02 06:34:39 -06:00
|
|
|
- name: Set working directory owner
|
|
|
|
run: chown root:root .
|
|
|
|
|
2022-04-28 08:51:48 -05:00
|
|
|
- uses: actions/checkout@v3
|
2021-02-22 03:28:32 -06: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 05:51:42 -05:00
|
|
|
uses: actions/cache@v3
|
2021-02-22 03:28:32 -06:00
|
|
|
with:
|
|
|
|
path: vendor/bundle
|
|
|
|
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
2023-05-12 07:00:04 -05:00
|
|
|
restore-keys: ${{ runner.os }}-gem-
|
2021-02-22 03:28:32 -06:00
|
|
|
|
|
|
|
- name: Setup gems
|
|
|
|
run: |
|
2022-01-12 15:50:04 -06:00
|
|
|
gem install bundler --conservative -v $(awk '/BUNDLED WITH/ { getline; gsub(/ /,""); print $0 }' Gemfile.lock)
|
2021-02-22 03:28:32 -06: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 07:12:08 -06:00
|
|
|
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
2021-02-22 03:28:32 -06:00
|
|
|
|
|
|
|
- name: Yarn cache
|
2022-03-31 05:51:42 -05:00
|
|
|
uses: actions/cache@v3
|
2021-02-22 03:28:32 -06:00
|
|
|
id: yarn-cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
2023-05-12 07:00:04 -05:00
|
|
|
restore-keys: ${{ runner.os }}-yarn-
|
2021-02-22 03:28:32 -06:00
|
|
|
|
|
|
|
- name: Yarn install
|
2023-05-02 10:25:22 -05:00
|
|
|
run: yarn install --frozen-lockfile
|
2021-02-22 03:28:32 -06:00
|
|
|
|
|
|
|
- name: Rubocop
|
2022-09-21 08:32:21 -05:00
|
|
|
if: ${{ !cancelled() }}
|
2022-07-07 00:29:14 -05:00
|
|
|
run: bundle exec rubocop --parallel .
|
2021-02-22 03:28:32 -06:00
|
|
|
|
2023-01-07 05:11:08 -06:00
|
|
|
- name: syntax_tree
|
|
|
|
if: ${{ !cancelled() }}
|
2023-02-02 06:34:39 -06:00
|
|
|
run: |
|
|
|
|
set -E
|
|
|
|
bundle exec stree check Gemfile $(git ls-files '*.rb') $(git ls-files '*.rake')
|
2023-01-07 05:11:08 -06:00
|
|
|
|
2021-02-22 03:28:32 -06:00
|
|
|
- name: ESLint (core)
|
2022-09-21 08:32:21 -05:00
|
|
|
if: ${{ !cancelled() }}
|
DEV: Setup lint to the future (#20990)
## How does this work?
Any time a lint rule is added or changed, you can run `yarn lint:fix` to handle all the auto-fixable situations.
But not all lints are auto-fixable -- for those, lint-to-the-future has tooling to automatically ignore present violations.
An alias has been added for lint-to-the-future to ignore new violations, `yarn lttf:ignore`.
The command will add lint-ignore declarations throughout all the files with present violations, which should then be committed.
An excerpt from lint-to-the-future's [README](https://github.com/mansona/lint-to-the-future#lint-to-the-future-dashboard):
> The point of Lint to the Future is to allow you to progressively update your codebase using new lint rules without overwhelming you with the task. You can easily ignore lint rules using project-based ignores in your config files but that doesn't prevent you from making the same errors in new files.
> We chose to do the ignores on a file basis as it is a perfect balance and it means that the tracking/graphing aspects of Lint to the Future provide you with achievable goals, especially in large codebases.
## How do I view progress?
lint-to-the-future provides graphs of violations-over-time per lint rule in a dashboard format, so we can track how well we're doing at cleaning up the violations.
To view the dashboard locally, run `yarn lint-progress` and visit `http://localhost:8084` (or whatever the port it chose, as it will choose a new port if 8084 is preoccupied)
Also there is a `list` command which shows a JSON object of:
```ts
{
[date: string]: { // yyyy-mm-dd
[pluginName: string]: {
[fileName: string]: string[]; // list of files with violations
}
}
}
```
```bash
yarn lint-to-the-future list --stdout
```
## What about lint-todo?
Lint todo is another system available for both eslint and ember-template-lint that _forces_ folks to "leave things better than they found them" by being transparent / line-specific ignoring of violations.
It was decided that for _this_ project, it made more sense, and would be less disruptive to new contributors to have the ignore declarations explicitly defined in each file (whereas in lint-todo, they are hidden).
To effectively use lint-todo, a whole team needs to agree to the workflow, and in open source, we want "just anyway" to be able to contribute, and throwing surprises at them can deter contributions.
2023-04-06 11:25:01 -05:00
|
|
|
run: yarn lint:js
|
2021-02-22 03:28:32 -06:00
|
|
|
|
|
|
|
- name: ESLint (core plugins)
|
2022-09-21 08:32:21 -05:00
|
|
|
if: ${{ !cancelled() }}
|
DEV: Setup lint to the future (#20990)
## How does this work?
Any time a lint rule is added or changed, you can run `yarn lint:fix` to handle all the auto-fixable situations.
But not all lints are auto-fixable -- for those, lint-to-the-future has tooling to automatically ignore present violations.
An alias has been added for lint-to-the-future to ignore new violations, `yarn lttf:ignore`.
The command will add lint-ignore declarations throughout all the files with present violations, which should then be committed.
An excerpt from lint-to-the-future's [README](https://github.com/mansona/lint-to-the-future#lint-to-the-future-dashboard):
> The point of Lint to the Future is to allow you to progressively update your codebase using new lint rules without overwhelming you with the task. You can easily ignore lint rules using project-based ignores in your config files but that doesn't prevent you from making the same errors in new files.
> We chose to do the ignores on a file basis as it is a perfect balance and it means that the tracking/graphing aspects of Lint to the Future provide you with achievable goals, especially in large codebases.
## How do I view progress?
lint-to-the-future provides graphs of violations-over-time per lint rule in a dashboard format, so we can track how well we're doing at cleaning up the violations.
To view the dashboard locally, run `yarn lint-progress` and visit `http://localhost:8084` (or whatever the port it chose, as it will choose a new port if 8084 is preoccupied)
Also there is a `list` command which shows a JSON object of:
```ts
{
[date: string]: { // yyyy-mm-dd
[pluginName: string]: {
[fileName: string]: string[]; // list of files with violations
}
}
}
```
```bash
yarn lint-to-the-future list --stdout
```
## What about lint-todo?
Lint todo is another system available for both eslint and ember-template-lint that _forces_ folks to "leave things better than they found them" by being transparent / line-specific ignoring of violations.
It was decided that for _this_ project, it made more sense, and would be less disruptive to new contributors to have the ignore declarations explicitly defined in each file (whereas in lint-todo, they are hidden).
To effectively use lint-todo, a whole team needs to agree to the workflow, and in open source, we want "just anyway" to be able to contribute, and throwing surprises at them can deter contributions.
2023-04-06 11:25:01 -05:00
|
|
|
run: yarn lint:js-plugins
|
2021-02-22 03:28:32 -06:00
|
|
|
|
|
|
|
- name: Prettier
|
2022-09-21 08:32:21 -05:00
|
|
|
if: ${{ !cancelled() }}
|
2021-02-22 03:28:32 -06:00
|
|
|
run: |
|
|
|
|
yarn prettier -v
|
DEV: Setup lint to the future (#20990)
## How does this work?
Any time a lint rule is added or changed, you can run `yarn lint:fix` to handle all the auto-fixable situations.
But not all lints are auto-fixable -- for those, lint-to-the-future has tooling to automatically ignore present violations.
An alias has been added for lint-to-the-future to ignore new violations, `yarn lttf:ignore`.
The command will add lint-ignore declarations throughout all the files with present violations, which should then be committed.
An excerpt from lint-to-the-future's [README](https://github.com/mansona/lint-to-the-future#lint-to-the-future-dashboard):
> The point of Lint to the Future is to allow you to progressively update your codebase using new lint rules without overwhelming you with the task. You can easily ignore lint rules using project-based ignores in your config files but that doesn't prevent you from making the same errors in new files.
> We chose to do the ignores on a file basis as it is a perfect balance and it means that the tracking/graphing aspects of Lint to the Future provide you with achievable goals, especially in large codebases.
## How do I view progress?
lint-to-the-future provides graphs of violations-over-time per lint rule in a dashboard format, so we can track how well we're doing at cleaning up the violations.
To view the dashboard locally, run `yarn lint-progress` and visit `http://localhost:8084` (or whatever the port it chose, as it will choose a new port if 8084 is preoccupied)
Also there is a `list` command which shows a JSON object of:
```ts
{
[date: string]: { // yyyy-mm-dd
[pluginName: string]: {
[fileName: string]: string[]; // list of files with violations
}
}
}
```
```bash
yarn lint-to-the-future list --stdout
```
## What about lint-todo?
Lint todo is another system available for both eslint and ember-template-lint that _forces_ folks to "leave things better than they found them" by being transparent / line-specific ignoring of violations.
It was decided that for _this_ project, it made more sense, and would be less disruptive to new contributors to have the ignore declarations explicitly defined in each file (whereas in lint-todo, they are hidden).
To effectively use lint-todo, a whole team needs to agree to the workflow, and in open source, we want "just anyway" to be able to contribute, and throwing surprises at them can deter contributions.
2023-04-06 11:25:01 -05:00
|
|
|
yarn lint:prettier
|
2021-02-22 03:28:32 -06:00
|
|
|
|
|
|
|
- name: Ember template lint
|
2022-09-21 08:32:21 -05:00
|
|
|
if: ${{ !cancelled() }}
|
DEV: Setup lint to the future (#20990)
## How does this work?
Any time a lint rule is added or changed, you can run `yarn lint:fix` to handle all the auto-fixable situations.
But not all lints are auto-fixable -- for those, lint-to-the-future has tooling to automatically ignore present violations.
An alias has been added for lint-to-the-future to ignore new violations, `yarn lttf:ignore`.
The command will add lint-ignore declarations throughout all the files with present violations, which should then be committed.
An excerpt from lint-to-the-future's [README](https://github.com/mansona/lint-to-the-future#lint-to-the-future-dashboard):
> The point of Lint to the Future is to allow you to progressively update your codebase using new lint rules without overwhelming you with the task. You can easily ignore lint rules using project-based ignores in your config files but that doesn't prevent you from making the same errors in new files.
> We chose to do the ignores on a file basis as it is a perfect balance and it means that the tracking/graphing aspects of Lint to the Future provide you with achievable goals, especially in large codebases.
## How do I view progress?
lint-to-the-future provides graphs of violations-over-time per lint rule in a dashboard format, so we can track how well we're doing at cleaning up the violations.
To view the dashboard locally, run `yarn lint-progress` and visit `http://localhost:8084` (or whatever the port it chose, as it will choose a new port if 8084 is preoccupied)
Also there is a `list` command which shows a JSON object of:
```ts
{
[date: string]: { // yyyy-mm-dd
[pluginName: string]: {
[fileName: string]: string[]; // list of files with violations
}
}
}
```
```bash
yarn lint-to-the-future list --stdout
```
## What about lint-todo?
Lint todo is another system available for both eslint and ember-template-lint that _forces_ folks to "leave things better than they found them" by being transparent / line-specific ignoring of violations.
It was decided that for _this_ project, it made more sense, and would be less disruptive to new contributors to have the ignore declarations explicitly defined in each file (whereas in lint-todo, they are hidden).
To effectively use lint-todo, a whole team needs to agree to the workflow, and in open source, we want "just anyway" to be able to contribute, and throwing surprises at them can deter contributions.
2023-04-06 11:25:01 -05:00
|
|
|
run: yarn lint:hbs
|
2021-02-22 03:28:32 -06:00
|
|
|
|
|
|
|
- name: English locale lint (core)
|
2022-09-21 08:32:21 -05:00
|
|
|
if: ${{ !cancelled() }}
|
2021-02-22 03:28:32 -06:00
|
|
|
run: bundle exec ruby script/i18n_lint.rb "config/**/locales/{client,server}.en.yml"
|
|
|
|
|
|
|
|
- name: English locale lint (core plugins)
|
2022-09-21 08:32:21 -05:00
|
|
|
if: ${{ !cancelled() }}
|
2021-02-22 03:28:32 -06:00
|
|
|
run: bundle exec ruby script/i18n_lint.rb "plugins/**/locales/{client,server}.en.yml"
|