Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reusable ESLint workflow. #279

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/reusable-eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: reusable eslint
on:
workflow_call:
inputs:
paths:
required: true
type: string
description: |
A list of root directory/s to where a package.json and eslint
configuration file (eslint.config.mjs) exist.
e.g.: my/root/one my/cool/root/two
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- if: ${{ startsWith(github.repository, 'GeoNet/') == false }}
name: require GeoNet org
run: |
exit 1
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "20.x"
- name: Install Node modules
id: install-node-modules
env:
PATHS: ${{ inputs.paths }}
run: |
for path in $PATHS; do
npm install --prefix $path
done
- name: Run ESLint
id: eslint
env:
PATHS: ${{ inputs.paths }}
run: |
for path in $PATHS; do
ESLINT_USE_FLAT_CONFIG=true $path/node_modules/.bin/eslint -c $path/eslint.config.mjs
done
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- [Markdown lint](#markdown-lint)
- [Copy to S3](#copy-to-s3)
- [Clean container versions](#clean-container-versions)
- [ESLint](#eslint)
- [Composite Actions](#composite-actions)
- [Tagging](#tagging)
- [Other documentation](#other-documentation)
Expand Down Expand Up @@ -1092,6 +1093,30 @@ jobs:
number-kept: 7
```

### ESLint

STATUS: alpha

Used to run ESLint on one or more directories. The paths specified
should have a package.json with eslint defined, alongside an eslint config
file named eslint.config.mjs.

```yaml
name: eslint
on:
push: {}
pull_request: {}
workflow_dispatch: {}
jobs:
eslint:
uses: GeoNet/Actions/.github/workflows/reusable-eslint.yml@main
with:
paths: |
./root/folder/one
./cool/root/folder/two
```


## Composite Actions

### Tagging
Expand Down
Loading