forked from magma/magma
-
Notifications
You must be signed in to change notification settings - Fork 2
198 lines (191 loc) · 8.81 KB
/
agw-coverage.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# Copyright 2022 The Magma Authors.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
#
# 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: AGW Generate Coverage
on:
push:
branches:
- master
- 'v1.*'
pull_request:
branches:
- master
- 'v1.*'
types: [ opened, reopened, synchronize ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
BAZEL_BASE_IMAGE: "ghcr.io/magma/magma/bazel-base:latest"
# Regarding the CACHE_KEY see https://github.com/magma/magma/pull/14041
CACHE_KEY: bazel-base-image-sha-c4de1e5
REMOTE_DOWNLOAD_OPTIMIZATION_C_CPP: true
REMOTE_DOWNLOAD_OPTIMIZATION_PYTHON: false
jobs:
path_filter:
runs-on: ubuntu-latest
outputs:
should_not_skip: ${{ steps.changes.outputs.filesChanged }}
steps:
# Need to get git on push event
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
if: github.event_name == 'push'
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # [email protected]
id: changes
with:
filters: |
filesChanged:
- '.github/workflows/agw-coverage.yml'
- 'orc8r/**'
- 'lte/**'
- '.bazelrc'
- 'WORKSPACE.bazel'
- 'bazel/**'
c-cpp-codecov:
needs: path_filter
if: ${{ needs.path_filter.outputs.should_not_skip == 'true' }}
name: C / C++ code coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
- name: Maximize build space
uses: ./.github/workflows/composite/maximize-build-space
- name: Setup Bazel Base Image
uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # pin@v3
with:
image: ${{ env.BAZEL_BASE_IMAGE }}
options: --pull always
# Run a simple echo command to pull down the image. This makes it a bit more clear how much time is spent on building Magma and not pulling down the image.
run: |
echo "Pulled the bazel base image!"
bazel # pull down bazel, if bazel download fails we can fail before we do all the lengthy work below
- name: Run C/C++ coverage with Bazel
if: always()
id: bazel-cc-codecoverage
uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # pin@v3
with:
image: ${{ env.BAZEL_BASE_IMAGE }}
# TODO: Remove work-around mount of Github workspace to /magma (https://github.com/addnab/docker-run-action/issues/11)
options: -v ${{ github.workspace }}:/workspaces/magma/ -v ${{ github.workspace }}/lte/gateway/configs:/etc/magma
run: |
bazel/scripts/remote_cache_bazelrc_setup.sh "${{ env.CACHE_KEY }}" "${{ env.REMOTE_DOWNLOAD_OPTIMIZATION_C_CPP }}" "${{ secrets.BAZEL_REMOTE_PASSWORD }}"
# Collecting coverage with Bazel can be slow. We can follow this thread to see if this can be improved: https://github.com/bazelbuild/bazel/issues/8178
# Coverage in bazel is flaky for remote caches - the flags below are helping. See GH13026 for details.
bazel coverage \
--profile=Bazel_test_cc_coverage_profile \
--experimental_split_coverage_postprocessing --experimental_fetch_all_coverage_outputs --remote_download_outputs=all \
//orc8r/gateway/c/...:* //lte/gateway/c/...:*
# copy out coverage information into magma so that it's accessible from the CI node
cp bazel-out/_coverage/_coverage_report.dat .
- name: Upload code coverage
if: always()
id: c-cpp-codecov-upload
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # [email protected]
with:
flags: c_cpp
- name: Publish bazel profile
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # pin@v3
if: |
always() &&
github.repository_owner == 'magma' &&
github.ref_name == 'master'
with:
name: Bazel test C and C++ coverage profile
path: Bazel_test_cc_coverage_profile
- name: Build space left after run
shell: bash
run: |
echo "Available storage:"
df -h
- name: Notify Bazel C/C++ coverage failure to slack
if: |
failure() &&
(steps.bazel-cc-codecoverage.conclusion == 'failure' ||
steps.c-cpp-codecov-upload.outcome == 'failure') &&
github.event_name == 'push'
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 # [email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_TITLE: "C / C++ code coverage with Bazel"
SLACK_USERNAME: ${{ github.workflow }}
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '
MSG_MINIMAL: actions url,commit
python-codecov:
needs: path_filter
if: ${{ needs.path_filter.outputs.should_not_skip == 'true' }}
name: Python code coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
- name: Maximize build space
uses: ./.github/workflows/composite/maximize-build-space
- name: Setup Bazel Base Image
uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # pin@v3
with:
image: ${{ env.BAZEL_BASE_IMAGE }}
options: --pull always
# Run a simple echo command to pull down the image. This makes it a bit more clear how much time is spent on building Magma and not pulling down the image.
run: |
echo "Pulled the bazel base image!"
bazel # pull down bazel, if bazel download fails we can fail before we do all the lengthy work below
- name: Run Python coverage with Bazel
if: always()
id: bazel-python-codecoverage
uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # pin@v3
with:
image: ${{ env.BAZEL_BASE_IMAGE }}
# TODO: Remove work-around mount of Github workspace to /magma (https://github.com/addnab/docker-run-action/issues/11)
options: -v ${{ github.workspace }}:/workspaces/magma/ -v ${{ github.workspace }}/lte/gateway/configs:/etc/magma
run: |
bazel/scripts/remote_cache_bazelrc_setup.sh "${{ env.CACHE_KEY }}" "${{ env.REMOTE_DOWNLOAD_OPTIMIZATION_PYTHON }}" "${{ secrets.BAZEL_REMOTE_PASSWORD }}"
# Collecting coverage with Bazel can be slow. We can follow this thread to see if this can be improved: https://github.com/bazelbuild/bazel/issues/8178
# Coverage in bazel is flaky for remote caches - the flags below are helping. See GH13026 for details.
bazel coverage \
--profile=Bazel_test_python_coverage_profile \
//orc8r/gateway/python/...:* //lte/gateway/python/...:*
# copy out coverage information into magma so that it's accessible from the CI node
cp bazel-out/_coverage/_coverage_report.dat .
- name: Upload code coverage
if: always()
id: python-codecov-upload
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # [email protected]
with:
flags: lte-test
- name: Publish bazel profile
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # pin@v3
if: |
always() &&
github.repository_owner == 'magma' &&
github.ref_name == 'master'
with:
name: Bazel test python coverage profile
path: Bazel_test_python_coverage_profile
- name: Build space left after run
shell: bash
run: |
echo "Available storage:"
df -h
- name: Notify Bazel Python coverage failure to slack
if: |
failure() &&
(steps.bazel-python-codecoverage.conclusion == 'failure' ||
steps.python-codecov-upload.outcome == 'failure') &&
github.event_name == 'push'
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 # [email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_TITLE: "Python code coverage with Bazel"
SLACK_USERNAME: ${{ github.workflow }}
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '
MSG_MINIMAL: actions url,commit