Skip to content

Commit 47d23bc

Browse files
chore(ci): enable Flakybot on tests (#447)
1 parent ebc5004 commit 47d23bc

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
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.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,27 @@ jobs:
114114
SQLSERVER_PASS: '${{ steps.secrets.outputs.SQLSERVER_PASS }}'
115115
SQLSERVER_DB: '${{ steps.secrets.outputs.SQLSERVER_DB }}'
116116
run: nox -s system-${{ matrix.python-version }}
117+
118+
- name: FlakyBot (Linux)
119+
# only run flakybot on periodic (schedule) and continuous (push) events
120+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Linux' && always() }}
121+
run: |
122+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
123+
chmod +x ./flakybot
124+
./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
125+
- name: FlakyBot (Windows)
126+
# only run flakybot on periodic (schedule) and continuous (push) events
127+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Windows' && always() }}
128+
run: |
129+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot.exe -o flakybot.exe -s -L
130+
./flakybot.exe --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
131+
- name: FlakyBot (macOS)
132+
# only run flakybot on periodic (schedule) and continuous (push) events
133+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'macOS' && always() }}
134+
run: |
135+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot-darwin-amd64 -o flakybot -s -L
136+
chmod +x ./flakybot
137+
./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
117138
118139
unit:
119140
# 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)
@@ -125,6 +146,9 @@ jobs:
125146
os: [macos-latest, windows-latest, ubuntu-latest]
126147
python-version: ["3.7", "3.8", "3.9", "3.10"]
127148
fail-fast: false
149+
permissions:
150+
contents: 'read'
151+
id-token: 'write'
128152
steps:
129153
- name: Remove PR label
130154
if: "${{ github.event.action == 'labeled' && github.event.label.name == 'tests: run' }}"
@@ -157,5 +181,34 @@ jobs:
157181
- name: Install nox
158182
run: pip install nox
159183

184+
- id: 'auth'
185+
name: 'Authenticate to Google Cloud'
186+
uses: 'google-github-actions/auth@v0.8.1'
187+
with:
188+
workload_identity_provider: ${{ secrets.PROVIDER_NAME }}
189+
service_account: ${{ secrets.SERVICE_ACCOUNT }}
190+
access_token_lifetime: 600s
191+
160192
- name: Run tests
161193
run: nox -s unit-${{ matrix.python-version }}
194+
195+
- name: FlakyBot (Linux)
196+
# only run flakybot on periodic (schedule) and continuous (push) events
197+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Linux' && always() }}
198+
run: |
199+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
200+
chmod +x ./flakybot
201+
./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
202+
- name: FlakyBot (Windows)
203+
# only run flakybot on periodic (schedule) and continuous (push) events
204+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Windows' && always() }}
205+
run: |
206+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot.exe -o flakybot.exe -s -L
207+
./flakybot.exe --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
208+
- name: FlakyBot (macOS)
209+
# only run flakybot on periodic (schedule) and continuous (push) events
210+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'macOS' && always() }}
211+
run: |
212+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot-darwin-amd64 -o flakybot -s -L
213+
chmod +x ./flakybot
214+
./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}

noxfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def default(session, path):
5353
"--cov-config=.coveragerc",
5454
"--cov-report=",
5555
"--cov-fail-under=0",
56+
"--junitxml=sponge_log.xml",
5657
path,
5758
*session.posargs,
5859
)

0 commit comments

Comments
 (0)