Skip to content

Commit b3eb1ed

Browse files
committed
Conditionally run the pre-commit job only when there are haskell source
changes
1 parent b8bbbc9 commit b3eb1ed

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

.github/workflows/pre-commit.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ on:
66
branches: [master]
77

88
jobs:
9-
pre-commit:
10-
runs-on: ubuntu-latest
11-
steps:
9+
file-diff:
1210
- uses: actions/checkout@v3
1311
- uses: technote-space/get-diff-action@v4.0.1
1412
with:
1513
PATTERNS: |
1614
+(src|exe|test|ghcide|plugins|hls-plugin-api|hie-compat|hls-graph|hls-test-utils)/**/*.hs
15+
pre-commit:
16+
needs: file-diff
17+
if env.GIT_DIFF
18+
runs-on: ubuntu-latest
19+
steps:
1720

1821
- uses: ./.github/actions/setup-build
1922
with:
2023
os: ${{ runner.os }}
2124
shorten-hls: false
22-
if: env.GIT_DIFF
2325

2426
- name: "Install stylish-haskell"
2527
run: |
2628
cabal install stylish-haskell
2729
echo "${HOME}/.cabal/bin" >> $GITHUB_PATH
28-
if: env.GIT_DIFF
2930
3031
- name: "Check stylish-haskell is available"
3132
run: |
3233
echo $(which stylish-haskell)
33-
if: env.GIT_DIFF
3434
3535
- name: Compiled deps cache
3636
id: stylish-haskell-compiled-cache
@@ -44,11 +44,8 @@ jobs:
4444
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-
4545
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-
4646
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-
47-
if: env.GIT_DIFF
4847
4948
- uses: actions/setup-python@v4
50-
if: env.GIT_DIFF
5149
- uses: pre-commit/action@v3.0.0
5250
with:
5351
extra_args: --files ${{ env.GIT_DIFF }}
54-
if: env.GIT_DIFF

0 commit comments

Comments
 (0)