-
Notifications
You must be signed in to change notification settings - Fork 1
135 lines (111 loc) · 4.12 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
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
133
134
135
name: "Test"
on:
push:
schedule:
- cron: '40 0 * * *' # run every night
jobs:
test:
strategy:
matrix:
shellSource: [packages, flakes, file, devShell]
runs-on: [ubuntu-latest, macos-latest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Don't install `nix` ourselves to ensure that the action does.
# Check that we've got the default Actions Runner path:
- run: echo $PATH && rustc --version
# Map to the right shell source:
- name: 'Load Shell Env'
uses: ./.github/workflows/matrix-expansion-helper
with:
source: ${{ matrix.shellSource }}
packages: hello
flakes: nixpkgs#hello
file: test/shell.nix
devShell: ./test
preserveDefaultPath: false
extraNixOptions: |
--option access-tokens github.com=${{ secrets.GITHUB_TOKEN }}
# Test that the PATH has been cleared now:
- run: |
echo $PATH
command -v rustc && exit 1 || :
# Test that `hello` is on the path:
- run: hello
# `devShell` and `file` sources also exported the test case vars; check
# that the vars roundtripped correctly in these shells:
- name: 'Check Env Var Roundtrip Testcases'
if: ${{ (matrix.shellSource == 'devShell') || (matrix.shellSource == 'file') }}
run: |
bash -c "source util.bash; check_testcases"
# Check that modifications in `shellHook` take effect:
echo $PATH | grep "foo" || exit 3
# Note that `bash` is *not* on the path now..
#
# (but only for the flakes route since that's the only route here that's
# not `mkShell` based and thus doesn't dump the stdenv's bash/coreutils on
# $PATH)
- if: ${{ matrix.shellSource == 'flakes' }}
run: |
! command -v bash
- name: 'Run Script with Host Env'
uses: ./.github/workflows/matrix-expansion-helper
with:
source: ${{ matrix.shellSource }}
packages: bash, tiny
flakes: nixpkgs#bash, nixpkgs#tiny
file: test/shell2.nix
devShell: ./test#noHello
extraNixOptions: |
--option access-tokens github.com=${{ secrets.GITHUB_TOKEN }}
exportEnv: false
clearEnvForScript: false
script: |
hello # should still be available because we didn't clear the env
tiny --version
touch foo
# check that we didn't add python to the github actions env:
- name: 'Did not update environment'
run: |
command -v tiny && exit 3 || :
[[ -e foo ]] # check that the script actually ran
# Test that we can run with non-interactive bash on $PATH:
- name: 'Put non-interactive bash on $PATH'
uses: ./
with:
packages: bash
- run: |
! bash -c "type compgen"
- name: 'Run Script without Host Env'
uses: ./.github/workflows/matrix-expansion-helper
with:
source: ${{ matrix.shellSource }}
packages: bash
flakes: nixpkgs#bash
file: test/shell2.nix
devShell: ./test#noHello
extraNixOptions: |
--option access-tokens github.com=${{ secrets.GITHUB_TOKEN }}
exportEnv: false
clearEnvForScript: true
script: |
hello && exit 3 || : okay # shouldn't be there anymore
- name: 'Run Script with Other Interpreter'
uses: ./.github/workflows/matrix-expansion-helper
with:
source: ${{ matrix.shellSource }}
packages: python3
flakes: nixpkgs#python3
file: test/shell2.nix
devShell: ./test#noHello
extraNixOptions: |
--option access-tokens github.com=${{ secrets.GITHUB_TOKEN }}
exportEnv: false
clearEnvForScript: true
interpreter: python3
script: |
import os
print(os.sys.version)
print(os.environ['PATH'])
# TODO: run in shell with `clearEnvForScript` and not; check that outside stuff is available/is not available