-
-
Notifications
You must be signed in to change notification settings - Fork 367
132 lines (121 loc) · 4.45 KB
/
nix.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Nix
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true
on:
pull_request:
branches:
- '**'
push:
branches:
- master
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip_develop: ${{ steps.skip_check.outputs.should_skip }}
should_skip_build: ${{ steps.skip_check_no_nix.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected]
with:
cancel_others: false
paths_ignore: '[ "**/docs/**"
, "**.md"
, "**/LICENSE"
, ".circleci/**"
, "**/README.md"
, "FUNDING.yml"
, "**/stack*.yaml"
, "**/stack*.yaml"
, ".gitlab-ci.yaml"
, ".gitlab/**"
]'
- id: skip_check_no_nix
uses: fkirc/[email protected]
with:
cancel_others: false
paths: '[ "**.nix" ]'
# Enter the development shell and run `cabal build`
develop:
if: needs.pre_job.outputs.should_skip_develop != 'true'
needs: pre_job
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
experimental-features = nix-command flakes
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: haskell-language-server
# Disable pushing, we will do that in job `build`
skipPush: true
- run: |
nix develop --print-build-logs --command cabal update
nix develop --print-build-logs --command cabal build
# Build and then push HLS binaries with developmet shell to cachix
# This job runs when
# 1. PRs are merged to master (runs on master)
# 2. Nix files are changed (runs on PR)
build:
needs: pre_job
runs-on: ${{ matrix.os }}
env:
HAS_TOKEN: ${{ secrets.HLS_CACHIX_AUTH_TOKEN != '' }}
if: (needs.pre_job.outputs.should_skip_build != 'true' && needs.pre_job.outputs.should_skip_pr != 'true') || (github.repository_owner == 'haskell' && github.ref == 'refs/heads/master')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
experimental-features = nix-command flakes
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: haskell-language-server
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
- name: Build development shell
run: nix develop --print-build-logs --profile dev
- name: Build all development shell (without nix dependencies)
run: nix develop --print-build-logs .#all-simple-dev-shells --profile dev
# We only build nix dev shell for current GHC version because some are
# failing with different GHC version on darwin.
- name: Build development shell with nix dependencies for current GHC version
if: matrix.os == 'macOS-latest'
run: nix develop --print-build-logs .#haskell-language-server-dev-nix --profile dev
- name: Build development shells with nix dependencies
if: matrix.os == 'ubuntu-latest'
run: nix develop --print-build-logs .#all-nix-dev-shells --profile dev
- name: Push development shell
if: ${{ env.HAS_TOKEN == 'true' }}
run: cachix push haskell-language-server dev
- name: Build binaries
run: nix build --print-build-logs
- name: Build all binaries
run: nix build --print-build-logs .#all-haskell-language-server
- name: Push binaries
if: ${{ env.HAS_TOKEN == 'true' }}
run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server
nix_post_job:
if: always()
runs-on: ubuntu-latest
needs: [pre_job, develop, build]
steps:
- run: |
echo "jobs info: ${{ toJSON(needs) }}"
- if: contains(needs.*.result, 'failure')
run: exit 1
- if: contains(needs.*.result, 'cancelled') && needs.pre_job.outputs.should_skip != 'true'
run: exit 1