forked from haskell/haskell-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (115 loc) · 4.27 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
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/**"
, "install/**"
, "**/README.md"
, "FUNDING.yml"
, "**/stack*.yaml"
]'
- 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@v2
- uses: cachix/install-nix-action@v16
with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10
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@v2
- uses: cachix/install-nix-action@v16
with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10
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 development shell (GHC 9.0.1)
run: nix develop --print-build-logs .#haskell-language-server-901-dev --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 binaries (GHC 9.0.1)
run: nix build --print-build-logs .#haskell-language-server-901
- 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