From 418ed39dce38e1bd996b9d440c6520bffb44fcdd Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 7 Nov 2024 11:23:44 -0800 Subject: [PATCH] Combine push and PR actions This reduces duplication, with the tradeoff of having some steps in the linter job that are mutually exclusive depending on the job trigger. --- .github/workflows/checks-main.yml | 57 ------------------- .../workflows/{checks-pr.yml => checks.yml} | 19 +++++-- 2 files changed, 14 insertions(+), 62 deletions(-) delete mode 100644 .github/workflows/checks-main.yml rename .github/workflows/{checks-pr.yml => checks.yml} (83%) diff --git a/.github/workflows/checks-main.yml b/.github/workflows/checks-main.yml deleted file mode 100644 index b70395fd7a..0000000000 --- a/.github/workflows/checks-main.yml +++ /dev/null @@ -1,57 +0,0 @@ -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: Lint all tests - run: ./tools/lint/lint.py test/ - - build: - name: Build generated 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 for generation tool - run: | - python -m pip install --upgrade pip - pip install -r tools/generation/requirements.txt - - - name: Build tests - run: | - ./make.py clean >/dev/null - ./make.py - - - name: Verify changes - uses: tj-actions/verify-changed-files@v20 - with: - fail-if-changed: true - fail-message: | - New changes were found after re-generating the tests. - Please read the documentation on procedurally generated tests - https://github.com/tc39/test262/blob/HEAD/CONTRIBUTING.md#procedurally-generated-tests diff --git a/.github/workflows/checks-pr.yml b/.github/workflows/checks.yml similarity index 83% rename from .github/workflows/checks-pr.yml rename to .github/workflows/checks.yml index cab110e8d7..817ab13ad8 100644 --- a/.github/workflows/checks-pr.yml +++ b/.github/workflows/checks.yml @@ -1,10 +1,12 @@ -name: Required PR checks +name: Checks -on: pull_request +on: + - push + - pull_request jobs: lint: - name: Lint + name: Lint tests runs-on: ubuntu-latest steps: - name: Checkout @@ -21,14 +23,21 @@ jobs: python -m pip install --upgrade pip pip install -r tools/lint/requirements.txt + - name: Lint all tests + if: github.event_name == 'push' + run: ./tools/lint/lint.py test/ + - name: Identify new or changed tests id: changed_tests + if: github.event_name == 'pull_request' uses: tj-actions/changed-files@v45 with: files: test/ - name: Lint new or changed tests - if: steps.changed_tests.outputs.any_changed == 'true' + if: | + github.event_name == 'pull_request' && + steps.changed_tests.outputs.any_changed == 'true' env: CHANGED: ${{ steps.changed_tests.outputs.all_changed_files }} run: | @@ -39,7 +48,7 @@ jobs: ./tools/lint/lint.py $CHANGED 2> >(tee errors.out >&2) - name: Create annotations in the PR - if: failure() + if: failure() && github.event_name == 'pull_request' run: | awk -F': '