Skip to content

Commit 861005c

Browse files
chore(ci): enable Flakybot to monitor builds (#173)
1 parent 918ff83 commit 861005c

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

.github/flakybot.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
issuePriority: p2

.github/workflows/tests.yaml

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,24 @@ jobs:
8989
ALLOYDB_USER: 'postgres'
9090
ALLOYDB_PASS: '${{ steps.secrets.outputs.ALLOYDB_CLUSTER_PASS }}'
9191
ALLOYDB_URI: '${{ steps.secrets.outputs.ALLOYDB_URI }}'
92+
# specifying bash shell ensures a failure in a piped process isn't lost by using `set -eo pipefail`
93+
shell: bash
9294
run: |
93-
go test -v -race -cover ./e2e_test.go
95+
go test -v -race -cover ./e2e_test.go | tee test_results.txt
96+
97+
- name: Convert test output to XML
98+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && always() }}
99+
run: |
100+
go install github.com/jstemmer/go-junit-report/v2@latest
101+
go-junit-report -in test_results.txt -set-exit-code -out integration_sponge_log.xml
102+
103+
- name: FlakyBot
104+
# only run flakybot on periodic (schedule) and continuous (push) events
105+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && always() }}
106+
run: |
107+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
108+
chmod +x ./flakybot
109+
./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
94110
95111
unit:
96112
# run job on proper workflow event triggers (skip job for pull_request event from forks and only run pull_request_target for "tests: run" label)
@@ -106,6 +122,9 @@ jobs:
106122
- os: macos-latest
107123
goarch: "386"
108124
fail-fast: false
125+
permissions:
126+
contents: 'read'
127+
id-token: 'write'
109128
env:
110129
GOARCH: ${{ matrix.goarch }}
111130
steps:
@@ -137,12 +156,48 @@ jobs:
137156
ref: ${{ github.event.pull_request.head.sha }}
138157
repository: ${{ github.event.pull_request.head.repo.full_name }}
139158

159+
- id: 'auth'
160+
name: 'Authenticate to Google Cloud'
161+
uses: 'google-github-actions/auth@v1.0.0'
162+
with:
163+
workload_identity_provider: ${{ secrets.PROVIDER_NAME }}
164+
service_account: ${{ secrets.SERVICE_ACCOUNT }}
165+
140166
- name: Run tests
141167
if: matrix.goarch == ''
168+
# specifying bash shell ensures a failure in a piped process isn't lost by using `set -eo pipefail`
169+
shell: bash
142170
run: |
143-
go test -v -race -cover -short ./...
171+
go test -v -race -cover -short ./... | tee test_results.txt
144172
- name: Run tests (386)
145173
# 386 archs don't support race detector
146174
if: matrix.goarch == '386'
147175
run: |
148176
go test -v -cover -short ./...
177+
178+
- name: Convert test output to XML
179+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && always() && matrix.goarch == '' }}
180+
run: |
181+
go install github.com/jstemmer/go-junit-report/v2@latest
182+
go-junit-report -in test_results.txt -set-exit-code -out unit_sponge_log.xml
183+
184+
- name: FlakyBot (Linux)
185+
# only run flakybot on periodic (schedule) and continuous (push) events
186+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Linux' && always() }}
187+
run: |
188+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
189+
chmod +x ./flakybot
190+
./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
191+
- name: FlakyBot (Windows)
192+
# only run flakybot on periodic (schedule) and continuous (push) events
193+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Windows' && always() }}
194+
run: |
195+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot.exe -o flakybot.exe -s -L
196+
./flakybot.exe --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
197+
- name: FlakyBot (macOS)
198+
# only run flakybot on periodic (schedule) and continuous (push) events
199+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'macOS' && always() }}
200+
run: |
201+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot-darwin-amd64 -o flakybot -s -L
202+
chmod +x ./flakybot
203+
./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}

0 commit comments

Comments
 (0)