Skip to content

Commit

Permalink
Github Actions: Perform selective eslint & testing for PRs (#9506)
Browse files Browse the repository at this point in the history
  • Loading branch information
im-tofa committed Apr 30, 2023
1 parent 6a04694 commit 3901e11
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
35 changes: 34 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,45 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- run: npm ci
- run: npm run full-test

- name: Determine which files to lint (if pull request)
if: ${{ github.event_name == 'pull_request' }}
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.js
**/*.ts
**/*.tsx
- name: Determine whether test/sim or test/random-battles need to run (if pull request)
if: ${{ github.event_name == 'pull_request' }}
id: changed-directories
uses: tj-actions/changed-files@v35
with:
files: |
config/formats.ts
data/**
sim/**
- name: Run selective lint & neccessary tests (if pull request)
if: ${{ github.event_name == 'pull_request' }}
run: npm run full-test-ci
env:
CI: true
FILES: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
SKIPSIMTESTS: ${{ steps.changed-directories.outputs.all_changed_and_modified_files == '' }}

- name: Run full lint & test (if push to master)
run: npm run full-test
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
env:
CI: true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"test": "mocha",
"posttest": "npm run tsc",
"full-test": "npm run lint && npm run tsc && mocha --timeout 8000 --forbid-only -g \".*\"",
"full-test-ci": "eslint ${FILES} --max-warnings 0 && npm run tsc && (([ \"$SKIPSIMTESTS\" = true ] && mocha --timeout 8000 --forbid-only -g \".*\" --exclude \"test/{sim,random-battles}/**\") || mocha --timeout 8000 --forbid-only -g \".*\")",
"postinstall": "npm run build postinstall"
},
"bin": "./pokemon-showdown",
Expand Down

0 comments on commit 3901e11

Please sign in to comment.