Only run the pre-commit hook on changed files (#3145)

* Only run the pre-commit hook on changed files

* Let's change a haskell file

* Didn't use the PATTERN field correctly

* Move pre-commit block before building stylish-haskell

* Try to evaluate GIT_DIFF value to pass to pre-commit

* Try to evaluate GIT_DIFF value to pass to pre-commit

* Move pre-commit action back to original spot

* Introduce bad formatting in a file

* Conditionally run the pre-commit job only when there are haskell source
changes

* Restore haskell files we used for testing

* workflow fixes

* Try changing haskell source files with new workflow structure

* Revert all changes to files during testing

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
This commit is contained in:
Nick Suchecki 2022-09-18 15:21:22 -04:00 committed by GitHub
parent 362ca34488
commit ff4f29f859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,11 +6,24 @@ on:
branches: [master]
jobs:
file-diff:
runs-on: ubuntu-latest
outputs:
git-diff: ${{ steps.git-diff.outputs.diff }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Find changed files
uses: technote-space/get-diff-action@v4.0.1
id: git-diff
with:
PATTERNS: |
+(src|exe|test|ghcide|plugins|hls-plugin-api|hie-compat|hls-graph|hls-test-utils)/**/*.hs
pre-commit:
runs-on: ubuntu-latest
needs: file-diff
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-build
with:
os: ${{ runner.os }}
@ -40,3 +53,5 @@ jobs:
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0
with:
extra_args: --files ${{ needs.file-diff.outputs.git-diff }}