-
Notifications
You must be signed in to change notification settings - Fork 81
170 lines (154 loc) · 5.56 KB
/
workflow.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Continuous integration
on:
push:
pull_request:
branches: master
workflow_dispatch: # allows manual triggering
workflow_call: # allows call from another workflow
schedule:
- cron: '1 11 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
# test-nixpkgs:
# name: Build & Test - Nixpkgs - ${{ matrix.bzlmodEnabled && 'bzlmod' || 'workspace' }} ${{ matrix.withNixRemote && '- NixRemote ' || '' }}- ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os:
# - ubuntu-latest
# - macos-12
# bzlmodEnabled:
# - true
# - false
# withNixRemote:
# - true
# - false
# exclude:
# # skip nix remote jobs on MacOS
# - os: macos-12
# withNixRemote: true
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v4
# - uses: cachix/install-nix-action@v30
# with:
# nix_path: nixpkgs=./docs/nixpkgs.nix
# - uses: ./.github/actions/configure_bazelrc
# with:
# buildbuddy_api_key: ${{ secrets.BUILDBUDDY_API_KEY }}
# - name: Start remote Nix server
# if: matrix.withNixRemote
# run: |
# # Generate temporary SSH keys.
# mkdir -p $HOME/.ssh
# mkdir -p .github/nix-server/keys
# ssh-keygen -t ed25519 -f .github/nix-server/keys/ci -C ci-nix-server -q -N ""
# docker build -t nix-server -f .github/nix-server/Dockerfile .
# docker run -d -p 2222:22 nix-server
# cp .github/nix-server/keys/* $HOME/.ssh/
# sudo cp .github/nix-server/config /etc/ssh/ssh_config
# echo "Setting BAZEL_NIX_REMOTE env variable"
# echo BAZEL_NIX_REMOTE=nix-server >> "$GITHUB_ENV"
# - name: Build & test
# env:
# BZLMOD_ENABLED: ${{ matrix.bzlmodEnabled }}
# run: |
# nix-shell --pure \
# --keep GITHUB_STEP_SUMMARY \
# --keep GITHUB_REPOSITORY \
# --keep BZLMOD_ENABLED \
# --keep BAZEL_NIX_REMOTE \
# --run 'bash .github/build-and-test'
test-examples:
name: Build & Test - Examples
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-12
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=./nixpkgs.nix
- uses: ./.github/actions/configure_bazelrc
with:
buildbuddy_api_key: ${{ secrets.BUILDBUDDY_API_KEY }}
# - name: Build & test
# run: |
# skip() {
# echo "Will skip $(head -n1 $2/README.md) ${1%_nix} Nix"
# local p="$1[@]"
# read -a ${1} <<< $(echo ${!p//$2})
# }
# pushd examples/cc-template
# echo
# echo "::group::Running $(head -n1 README.md) with Nix, WORKSPACE"
# nix develop --command bazel run --noenable_bzlmod //src:hello-world
# popd
# pushd examples/cc-template
# echo
# echo "::group::Running $(head -n1 README.md) with Nix, bzlmod"
# nix develop --command bazel run --enable_bzlmod //src:hello-world
# popd
# pushd examples/toolchains
# with_nix=( $(ls) )
# without_nix=( cc go java )
# for dir in "${with_nix[@]}"; do
# pushd "$dir"
# echo
# example_name="$(head -n1 README.md) with Nix"
# if [[ -f skip-on-ci ]]; then
# echo "Skipping $example_name"
# popd
# continue
# else
# echo "::group::Running $example_name"
# nix-shell --pure --keep GITHUB_STEP_SUMMARY --keep GITHUB_REPOSITORY --keep BZLMOD_ENABLED --keep BAZEL_NIX_REMOTE --command 'bazel run --config=nix :hello'
# # TODO: all toolchains should run without Nixpkgs
# fi
# popd
# done
# for dir in "${without_nix[@]}"; do
# pushd "$dir"
# echo
# echo "::group::Running $(head -n1 README.md) without Nix"
# bazel run :hello
# popd
# done
# popd
- name: Test cross C++ example
if: ${{ runner.os == 'macOS' }}
uses: tweag/run-nix-shell@v0
with:
derivation-path: examples/toolchains/cc_cross_osx_to_linux_amd64
working-directory: examples/toolchains/cc_cross_osx_to_linux_amd64
run: bazel run --config=cross :hello_image
- name: Build bazel-nix-python-container with Nix
uses: tweag/run-nix-shell@v0
if: ${{ runner.os == 'Linux' }}
with:
pure: false
working-directory: examples/python-container
run: bazel build :hello_image
- name: Run bazel-nix-flakes-example with Nix
uses: tweag/run-nix-shell@v0
if: ${{ runner.os == 'Linux' }}
with:
pure: false
working-directory: examples/flakes
run: bazel run --crosstool_top=@nixpkgs_config_cc//:toolchain :hello
# all_ci_tests:
# runs-on: ubuntu-latest
# needs:
# - test-nixpkgs
# - test-examples
# if: ${{ always() }}
# steps:
# - uses: cgrindel/gha_join_jobs@794a2d117251f22607f1aab937d3fd3eaaf9a2f5 # v1
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}