This repository has been archived by the owner on Feb 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (73 loc) · 2.62 KB
/
ci.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
name: CI
on:
push:
branches: [main]
paths:
- '.github/workflows/ci.yml'
- 'app/**'
- 'scripts/**'
- 'src/**'
- 'test/**'
- '**.cabal'
- '**.nix'
pull_request:
paths:
- '.github/workflows/ci.yml'
- 'app/**'
- 'scripts/**'
- 'src/**'
- 'test/**'
- '**.cabal'
- '**.nix'
workflow_dispatch:
jobs:
hspec:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- id: extract_nixpkgs_url
run:
# `nix eval --raw --impure --expr '(import ./flake.nix).inputs.nixpkgs.url'` can detect the nixpkgs url, but it requires nix... I want this information before installing nix :<
echo "url=$(ruby -e 'puts File.read("flake.nix").slice(/nixpkgs = { url = "([^"]+)/, 1)')" | tee -a $GITHUB_OUTPUT
- uses: cachix/install-nix-action@v19
with:
nix_path: nixpkgs=${{ steps.extract_nixpkgs_url.outputs.url }}
# https://github.com/cachix/install-nix-action/blob/5c11eae19dba042788936d4f1c9685fdd814ac49/README.md?plain=1#L80-L85
# Actually don't work for specifying nix_path...
- id: detect_nixpkgs
name: Detect nixpkgs version
run: echo "nixpkgs_version=$(nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version' | tr -d '"')" | tee -a $GITHUB_OUTPUT
- uses: cachix/cachix-action@v12
with:
name: asdf2json
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# How to cache nix store is https://github.com/kachick/dotfiles/blob/b264b152302cf38afe46d513f5a4cd9531197958/.github/workflows/ci-dev.yml#L28-L32
# No big benefit exists...
- name: Print current versions
run: |
nix develop --command bash -c '
which ghc
ghc --version
which cabal
cabal --version
which stack
stack --version
dprint --version
'
- name: Cache cabal global
id: cache-cabal-global
uses: actions/cache@v3
with:
path: ~/.cabal
key: ${{ runner.os }}-cabal-global-${{ hashFiles('**.nix', '**.cabal') }}
- name: Cache cabal local
id: cache-cabal-local
uses: actions/cache@v3
with:
path: dist-newstyle
key: ${{ runner.os }}-cabal-local-${{ hashFiles('**.nix', '**.cabal') }}
- name: Cabal update
if: steps.cache-cabal-global.outputs.cache-hit != 'true' || steps.cache-cabal-local.outputs.cache-hit != 'true'
run: nix develop --command bash -c 'cabal update'
- run: nix develop --command bash -c 'cabal test'