-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (143 loc) · 4.92 KB
/
ci.yaml
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
136
137
138
139
140
141
142
143
144
145
146
147
name: Continuous integration
on:
push:
branches: main
pull_request:
branches: main
workflow_dispatch: # allows manual triggering
schedule:
- cron: '1 11 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
unit_tests:
name: Unit Tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: ./.github/actions/set_up_runner
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Execute Bazel tests
shell: bash
run: bazel test //...
integration_tests:
name: Integration Tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: ./.github/actions/set_up_runner
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Execute in directory with shell.nix
uses: ./
with:
verbose: true
# Demonstrate passing a directory that contains a shell.nix.
derivation-path: ./tests/integration_tests
working-directory: ./tests/integration_tests
options: |
--arg customVarBool true
--argstr customVarStr "Hello, World!"
run: |
echo "FIRST" > integration_test.out
echo "${CUSTOM_VAR_BOOL}" >> integration_test.out
echo "${CUSTOM_VAR_STR}" >> integration_test.out
- name: Confirm output for Execute in directory with shell.nix
shell: bash
run: |
output="$(<./tests/integration_tests/integration_test.out)"
expected="$(cat <<-EOF
FIRST
true
Hello, World!
EOF
)"
[[ "${output}" == "${expected}" ]] || \
(echo >&2 "Ouptput from integration test does not match:" "${output}"; exit 1)
- name: Execute in directory without shell.nix
uses: ./
with:
verbose: true
# Demonstrate passing a path to a shell.nix.
derivation-path: ./tests/integration_tests/shell.nix
options: |
--argstr customVarStr "Hello, World!"
run: |
echo "${CUSTOM_VAR_STR}" >> integration_test2.out
- name: Confirm output for Execute in directory without shell.nix
shell: bash
run: |
output="$(<./integration_test2.out)"
expected="$(cat <<-EOF
Hello, World!
EOF
)"
[[ "${output}" == "${expected}" ]] || \
(echo >&2 "Ouptput from integration test does not match:" "${output}"; exit 1)
- name: Execute without recommended shell flags
uses: ./
with:
verbose: true
derivation-path: ./tests/integration_tests
shell-flags: ''
run: |
rm -f integration_test3.out
# This fails. If the recommended flags are set, we should not reach the following
# statement.
ls does_not_exist
echo "HELLO" > integration_test3.out
- name: Confirm output for Execute without recommended shell flags
shell: bash
run: |
[[ -e integration_test3.out ]] || \
(echo >&2 "The integration_test3.out does not exist."; exit 1)
output="$(<./integration_test3.out)"
expected="$(cat <<-EOF
HELLO
EOF
)"
[[ "${output}" == "${expected}" ]] || \
(echo >&2 "Ouptput from integration test does not match:" "${output}"; exit 1)
- name: Execute with recommended shell flags
# This step should fail. We will confirm that it failed as expected in the next step.
continue-on-error: true
uses: ./
with:
verbose: true
derivation-path: ./tests/integration_tests
run: |
rm -f integration_test4.out
# This fails. If the recommended flags are set, we should not reach the following
# statement.
ls does_not_exist
echo "HELLO" > integration_test4.out
- name: Confirm output for Execute with recommended shell flags
shell: bash
run: |
if [[ -e integration_test4.out ]]; then
echo >&2 "The integration_test4.out exists."
exit 1
fi
echo "SUCCESS"
all_ci_tests:
runs-on: ubuntu-latest
needs:
- unit_tests
- integration_tests
if: ${{ always() }}
steps:
- uses: cgrindel/gha_join_jobs@794a2d117251f22607f1aab937d3fd3eaaf9a2f5 # v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}