@@ -12,13 +12,19 @@ jobs:
12
12
pre_job :
13
13
runs-on : ubuntu-latest
14
14
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 }}
16
17
steps :
17
18
- id : skip_check
18
19
uses : fkirc/skip-duplicate-actions@master
19
20
with :
20
21
cancel_others : true
21
22
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"]'
22
28
23
29
# Enter the development shell and run `cabal build`
24
30
develop :
@@ -31,34 +37,39 @@ jobs:
31
37
os : [ubuntu-latest, macOS-latest]
32
38
33
39
steps :
34
- - if : ${{ needs.pre_job.outputs.should_skip != 'true' }}
40
+ - if : ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
35
41
uses : actions/checkout@v2
36
42
with :
37
43
submodules : true
38
- - if : ${{ needs.pre_job.outputs.should_skip != 'true' }}
44
+ - if : ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
39
45
uses : cachix/install-nix-action@v13
40
46
with :
41
47
install_url : https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install
42
48
install_options : ' --tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
43
49
extra_nix_config : |
44
50
experimental-features = nix-command flakes
45
51
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' }}
47
53
uses : cachix/cachix-action@v10
48
54
with :
49
55
name : haskell-language-server
50
56
# Disable pushing, we will do that in job `build`
51
57
skipPush : true
52
- - if : ${{ needs.pre_job.outputs.should_skip != 'true' }}
58
+ - if : ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
53
59
run : |
54
60
nix develop --command cabal update
55
61
nix develop --command cabal build
56
62
57
63
# 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)
59
67
build :
68
+ needs : pre_job
60
69
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') }}
62
73
strategy :
63
74
fail-fast : false
64
75
matrix :
79
90
with :
80
91
name : haskell-language-server
81
92
authToken : ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
93
+ - name : Build development shell
94
+ run : nix develop --profile dev
82
95
- 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