-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (135 loc) · 5.09 KB
/
build-test.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Copyright 2021 The Cross-Media Measurement Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build and test
on:
push:
branches:
- main
- 'releases/**'
pull_request:
branches:
- main
- 'releases/**'
types: [opened, synchronize, edited]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
wait-for-main:
name: Wait for main branch build
runs-on: ubuntu-latest
steps:
# This is run in a separate job to avoid invalidating the build cache.
- uses: lewagon/[email protected]
if: github.event_name == 'pull_request'
with:
ref: main
check-name: Build and test
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 90
build-test:
name: Build and test
runs-on: ubuntu-20.04
needs: wait-for-main
env:
CLUSTER_LOGS_PATH: cluster-logs
steps:
- name: Check out revision
uses: actions/checkout@v3
- name: Write ~/.bazelrc
run: |
cat << EOF > ~/.bazelrc
build -c opt
build --host_platform //build/platforms:ubuntu_20_04
build --define container_registry=localhost:5001
build --define image_repo_prefix=halo
build --define image_tag=latest
build --define kingdom_public_api_target=kingdom.example.com:8443
build --define duchy_public_api_target=duchy.example.com:8443
build --define mc_name=measurementConsumers/foo
build --define edp1_name=dataProviders/foo1
build --define edp2_name=dataProviders/foo2
build --define edp3_name=dataProviders/foo3
build --define edp4_name=dataProviders/foo4
build --define edp5_name=dataProviders/foo5
build --define edp6_name=dataProviders/foo6
build --define google_cloud_project=example-project
build --define bigquery_dataset=example-dataset
build --define bigquery_table=events
EOF
- name: Get Bazel cache params
id: get-cache-params
uses: world-federation-of-advertisers/actions/bazel-get-cache-params@v2
with:
cache-version: 1
- name: Restore Bazel cache
uses: actions/cache/restore@v3
with:
path: ${{ steps.get-cache-params.outputs.cache-path }}
key: ${{ steps.get-cache-params.outputs.cache-key }}
restore-keys: |-
${{ steps.get-cache-params.outputs.restore-key }}
- name: Build
run: >
bazelisk build --worker_quit_after_build
//...
//src/main/k8s/dev:synthetic_generator_edp_simulators
- name: Run tests
id: run-tests
run: bazelisk test //...
- name: Create cluster
id: create-cluster
run: |
echo "KUBECONFIG=$HOME/.kube/config" >> "$GITHUB_ENV"
curl -LOJ https://kind.sigs.k8s.io/examples/kind-with-registry.sh
chmod +x kind-with-registry.sh
./kind-with-registry.sh
- name: Run correctness test
id: run-correctness-test
run: >
bazelisk test
//src/test/kotlin/org/wfanet/measurement/integration/k8s:EmptyClusterCorrectnessTest
--test_output=streamed
- name: Export cluster logs
id: export-cluster-logs
if: failure() && steps.run-correctness-test.outcome == 'failure'
continue-on-error: true
run: |
mkdir -p "$CLUSTER_LOGS_PATH"
kind export logs "$CLUSTER_LOGS_PATH"
- name: Upload cluster logs artifact
if: failure() && steps.export-cluster-logs.outcome == 'success'
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: cluster-logs
path: ${{ env.CLUSTER_LOGS_PATH }}
# Delete large files that are cheap to re-create.
- name: Trim Bazel cache
if: github.event_name == 'push'
run: |
bazel_out="$(bazelisk info output_path)"
find "${bazel_out}" -type f \( -iname '*.tar' -o -iname '*.tar.gz' \) -delete
- name: Save Bazel cache
if: github.event_name == 'push'
uses: actions/cache/save@v3
continue-on-error: true
with:
path: ${{ steps.get-cache-params.outputs.cache-path }}
key: ${{ steps.get-cache-params.outputs.cache-key }}
- name: Upload Bazel testlogs
continue-on-error: true
uses: world-federation-of-advertisers/actions/bazel-upload-testlogs@v2
if: failure() && (steps.run-tests.outcome == 'failure' || steps.run-correctness-test.outcome == 'failure')