Skip to content

Commit

Permalink
Combine push and PR actions
Browse files Browse the repository at this point in the history
This reduces duplication, with the tradeoff of having some steps in the
linter job that are mutually exclusive depending on the job trigger.
  • Loading branch information
ptomato committed Nov 12, 2024
1 parent 5be2025 commit 24e46d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 62 deletions.
57 changes: 0 additions & 57 deletions .github/workflows/checks-main.yml

This file was deleted.

19 changes: 14 additions & 5 deletions .github/workflows/checks-pr.yml → .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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: |
Expand All @@ -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': ' <errors.out \
"{ sub(\"$(pwd)/\", \"\"); printf \"::error file=%s,line=1::%s\n\", \$1, \$2 }"
Expand Down

0 comments on commit 24e46d9

Please sign in to comment.