Migrate linter workflow to GitHub Actions

This runs faster and allows for future improvements.

I'm following a general principle of keeping code that isn't portable
between CI providers inside the config file for the CI provider. So in
this case we remove the Circle-CI-specific stuff from the file in
tools/scripts/, and into .github/workflows/. We use an external action
(tj-actions/changed-files) to gather the list of files to lint.
This commit is contained in:
Philip Chimento 2024-11-04 11:22:28 -08:00 committed by Philip Chimento
parent 6b38428da1
commit 7fc86bca6a
4 changed files with 75 additions and 25 deletions

View File

@ -37,7 +37,7 @@ execution_steps: &execution_steps
- run: hostPath=$HOME/.esvu/bin/$hostPath npm run ci
jobs:
"Test262: verify tools; build & lint tests":
"Test262: verify tools; build tests":
docker:
- image: cimg/python:3.7.4
working_directory: ~/test262
@ -46,21 +46,12 @@ jobs:
- run:
name: "Install requirements for generation tool"
command: python -m pip install --user --requirement tools/generation/requirements.txt
- run:
name: "Install requirements for lint tool"
command: python -m pip install --user --requirement tools/lint/requirements.txt
- run:
name: "Test the generation tool"
command: ./tools/generation/test/run.py
- run:
name: "Test the lint tool"
command: ./tools/lint/test/run.py
- run:
name: "Build tests; check for new changes"
command: ./tools/scripts/ci_build.sh
- run:
name: "Lint tests"
command: ./tools/scripts/ci_lint.sh
"V8: New or modified tests execution":
docker:
- image: *node_image
@ -134,7 +125,7 @@ workflows:
version: 2
Tools:
jobs:
- "Test262: verify tools; build & lint tests"
- "Test262: verify tools; build tests"
Tests execution:
jobs:
# - "ChakraCore: New or modified tests execution"

28
.github/workflows/checks-main.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Checks
on: push
jobs:
lint:
name: Lint tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tools/lint/requirements.txt
- name: Test the lint tool
run: ./tools/lint/test/run.py
- name: Lint all tests
run: ./tools/scripts/ci_lint.sh

42
.github/workflows/checks-pr.yml vendored Normal file
View File

@ -0,0 +1,42 @@
name: Required PR checks
on: pull_request
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tools/lint/requirements.txt
- name: Test the lint tool
run: ./tools/lint/test/run.py
- name: Identify new or changed tests
id: changed_tests
uses: tj-actions/changed-files@v45
with:
files: test/
- name: Lint new or changed tests
if: steps.changed_tests.outputs.any_changed == 'true'
env:
CHANGED: ${{ steps.changed_tests.outputs.all_changed_files }}
run: |
echo New or modified test files:
for file in $CHANGED; do
echo $file
done
./tools/scripts/ci_lint.sh $CHANGED

View File

@ -1,18 +1,7 @@
#!/bin/bash
if [ "$CIRCLE_PULL_REQUEST" != "" ]; then
paths=$(git diff --diff-filter ACMR --name-only origin/main.. -- test/)
if [ "$paths" == "" ]; then
echo No test files added or modified. Exiting.
exit 0
fi
echo New or modified test files:
echo "$paths"
else
paths="test/"
if [ "$#" -eq 0 ]; then
set -- test/
fi
./tools/lint/lint.py --exceptions lint.exceptions $paths
./tools/lint/lint.py --exceptions lint.exceptions $@