-
Notifications
You must be signed in to change notification settings - Fork 351
129 lines (127 loc) · 3.9 KB
/
buildtest.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
name: "Build & Test"
on:
pull_request:
push:
branches:
- main
tags:
- v*
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [[ubuntu-latest], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
- uses: cachix/cachix-action@v14
with:
name: devenv
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build
- name: Run tests
run: |
./result/bin/devenv ci
./result/bin/devenv shell devenv-run-tests
./result/bin/devenv search ncdu | grep "pkgs\.ncdu"
pin:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
uses: ./.github/workflows/pin.yml
secrets: inherit
generate-examples:
runs-on: ubuntu-latest
outputs:
examples: ${{ steps.set-examples.outputs.examples }}
steps:
- name: Checkout base repo
uses: actions/checkout@v4
- id: set-examples
run: |
json=$(tree -J -L 1 examples | jq -c '[.[0].contents[] | .name]')
echo "examples=$json" >> $GITHUB_OUTPUT
examples:
name: ${{ matrix.example }} (${{ join(matrix.os) }})
needs: [generate-examples, build]
strategy:
fail-fast: false
matrix:
os: [[ubuntu-latest], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]]
example: ${{ fromJSON(needs.generate-examples.outputs.examples) }}
runs-on: ${{ matrix.os }}
steps:
- run: sudo rm -rf /opt&
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v14
with:
name: devenv
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Disable package aliases
run: |
mkdir -p ~/.config/nixpkgs
echo '{ allowAliases = false; }' > ~/.config/nixpkgs/config.nix
- run: |
nix build
./result/bin/devenv test ${{ matrix.example }}
direnv:
name: direnv (${{ join(matrix.os) }})
needs: build
strategy:
fail-fast: false
matrix:
os: [[ubuntu-latest], [macos-latest], [self-hosted, macOS], [self-hosted, Linux, ARM64]]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v14
with:
name: devenv
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: |
mv ./examples/simple/devenv.yaml ./examples/simple/devenv.yaml.orig
nix run nixpkgs#gawk -- '
{ print }
/^inputs:$/ {
print " devenv:";
print " url: path:../../?dir=src/modules";
}
' ./examples/simple/devenv.yaml.orig > ./examples/simple/devenv.yaml
nix profile remove '.*'
nix profile install . 'nixpkgs#direnv'
mkdir -p ~/.config/direnv/
cat > ~/.config/direnv/direnv.toml << 'EOF'
[global]
strict_env = true
EOF
direnv allow ./examples/simple
direnv exec ./examples/simple true
fish-zsh:
name: zsh/fish (${{ join(matrix.os) }})
needs: build
strategy:
fail-fast: false
matrix:
os: [[ubuntu-latest], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v14
with:
name: devenv
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build
- run: |
nix shell nixpkgs#zsh -c zsh -c "./result/bin/devenv version"
nix shell nixpkgs#fish -c fish -c "./result/bin/devenv version"