Skip to content

Commit

Permalink
Migrate linter workflow to GitHub Actions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ptomato committed Nov 5, 2024
1 parent 6e2b414 commit 6593162
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 25 deletions.
13 changes: 2 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/checks-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Checks

on: push
# FIXME:
# on:
# push:
# branches:
# main

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
41 changes: 41 additions & 0 deletions .github/workflows/checks-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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/
separator: "\n"

- 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:
echo "$CHANGED"
./tools/scripts/ci_lint.sh $CHANGED
17 changes: 3 additions & 14 deletions tools/scripts/ci_lint.sh
Original file line number Diff line number Diff line change
@@ -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 $@

0 comments on commit 6593162

Please sign in to comment.