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 never get executed in one or the other situation.
  • Loading branch information
ptomato committed Nov 7, 2024
1 parent 459641e commit fa8c451
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 67 deletions.
62 changes: 0 additions & 62 deletions .github/workflows/checks-main.yml

This file was deleted.

21 changes: 16 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,14 @@
name: Required PR checks
name: Checks

on: pull_request
on:
- push:
branches:
main
- pull_request

jobs:
lint:
name: Lint
name: Lint tests
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -21,14 +25,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 +50,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 fa8c451

Please sign in to comment.