Skip to content

Commit e34d3bd

Browse files
committed
Run job nix build on PRs that change nix files
1 parent e806cc2 commit e34d3bd

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

.github/workflows/nix.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ jobs:
1212
pre_job:
1313
runs-on: ubuntu-latest
1414
outputs:
15-
should_skip: ${{ steps.skip_check.outputs.should_skip }}
15+
should_skip_develop: ${{ steps.skip_check.outputs.should_skip }}
16+
should_skip_build: ${{ steps.skip_check_no_nix.outputs.should_skip }}
1617
steps:
1718
- id: skip_check
1819
uses: fkirc/skip-duplicate-actions@master
1920
with:
2021
cancel_others: true
2122
paths_ignore: '["**/docs/**", "**.md", "**/LICENSE", ".circleci/**", "install/**"]'
23+
- id: skip_check_no_nix
24+
uses: fkirc/skip-duplicate-actions@master
25+
with:
26+
cancel_others: false
27+
paths: '["**.nix"]'
2228

2329
# Enter the development shell and run `cabal build`
2430
develop:
@@ -31,34 +37,39 @@ jobs:
3137
os: [ubuntu-latest, macOS-latest]
3238

3339
steps:
34-
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
40+
- if: ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
3541
uses: actions/checkout@v2
3642
with:
3743
submodules: true
38-
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
44+
- if: ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
3945
uses: cachix/install-nix-action@v13
4046
with:
4147
install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install
4248
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
4349
extra_nix_config: |
4450
experimental-features = nix-command flakes
4551
nix_path: nixpkgs=channel:nixos-unstable
46-
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
52+
- if: ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
4753
uses: cachix/cachix-action@v10
4854
with:
4955
name: haskell-language-server
5056
# Disable pushing, we will do that in job `build`
5157
skipPush: true
52-
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
58+
- if: ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
5359
run: |
5460
nix develop --command cabal update
5561
nix develop --command cabal build
5662
5763
# Build and then push HLS binaries with developmet shell to cachix
58-
# This job runs when PRs are merged to master, and should be excluded from branch protections
64+
# This job runs when
65+
# 1. PRs are merged to master (runs on master)
66+
# 2. Nix files are changed (runs on PR)
5967
build:
68+
needs: pre_job
6069
runs-on: ${{ matrix.os }}
61-
if: ${{ github.repository_owner == 'haskell' && github.ref == 'refs/heads/master' }}
70+
env:
71+
HAS_TOKEN: ${{ secrets.HLS_CACHIX_AUTH_TOKEN != '' }}
72+
if: ${{ needs.pre_job.outputs.should_skip_build != 'true' || (github.repository_owner == 'haskell' && github.ref == 'refs/heads/master') }}
6273
strategy:
6374
fail-fast: false
6475
matrix:
@@ -79,9 +90,13 @@ jobs:
7990
with:
8091
name: haskell-language-server
8192
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
93+
- name: Build development shell
94+
run: nix develop --profile dev
8295
- name: Push development shell
83-
run: nix develop --profile dev && cachix push haskell-language-server dev
84-
- name: Build and push binaries
85-
run: |
86-
nix build
87-
nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server
96+
if: ${{ env.HAS_TOKEN == 'true' }}
97+
run: cachix push haskell-language-server dev
98+
- name: Build binaries
99+
run: nix build
100+
- name: Push binaries
101+
if: ${{ env.HAS_TOKEN == 'true' }}
102+
run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server

0 commit comments

Comments
 (0)