-
Notifications
You must be signed in to change notification settings - Fork 2k
ci: use flakybot with actions workflows #3079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
ff652c2
ci: use flakybot with actions workflows
kweinmeister 2090428
revert to old workflow file
kweinmeister 46e2e86
use 2 workflows
kweinmeister e46a195
comment out both workflows
kweinmeister b4f6345
add back flakybot
kweinmeister 320c829
update flakybot path
kweinmeister abfc09a
refactor directory structure
kweinmeister 6aab921
fix job reference
kweinmeister 2bd765b
more tests
kweinmeister d5951ee
rename file
kweinmeister df9d6b4
test
kweinmeister 77c248b
update var names
kweinmeister f033771
remove if
kweinmeister a0cadfa
update var names
kweinmeister dd43240
add env vars to GITHUB_ENV
kweinmeister 71a49d4
fix env vars
kweinmeister 141769f
fix if statement
kweinmeister 918b15f
test flakybot run
kweinmeister b819ae2
cleanup flakybot script
kweinmeister 7a5f878
use go.mod file
kweinmeister 9b4f956
missing $
kweinmeister 73984ef
missing }
kweinmeister 7c27ae8
update flakybot yaml
kweinmeister 771b794
improve caching
kweinmeister 0479596
test flakybot run
kweinmeister a60af54
test run
kweinmeister 9cbe3ad
Update workflow conditions
kweinmeister 80915fd
revert test case to pass
kweinmeister 790ff93
remove label fix
kweinmeister dc947af
test pr number logic
kweinmeister 48e4089
revert change to root package.json
kweinmeister 0f8e6d1
test simplifying remove_label
kweinmeister d83abb5
remove comment
kweinmeister 51188d4
Merge branch 'main' into flakybot-actions
kweinmeister acf819a
Merge branch 'main' into flakybot-actions
pattishin 3390b7e
address feedback and update template
kweinmeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# 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. | ||
|
||
issuePriority: p2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# 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: FlakyBot | ||
|
||
on: | ||
workflow_call: | ||
|
||
env: | ||
FLAKYBOT_VERSION: '1.2.0' | ||
|
||
jobs: | ||
flakybot: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
steps: | ||
- uses: 'google-github-actions/auth@v1' | ||
with: | ||
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' | ||
service_account: '[email protected]' | ||
create_credentials_file: 'true' | ||
access_token_lifetime: 600s | ||
- name: download test results | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: test-results | ||
- name: download FlakyBot | ||
run: | | ||
curl -s -L https://github.com/googleapis/repo-automation-bots/archive/refs/tags/flakybot-v${{ env.FLAKYBOT_VERSION }}.tar.gz -o flakybot.tar.gz | ||
tar xzf flakybot.tar.gz | ||
cp -rT repo-automation-bots-flakybot-v${{ env.FLAKYBOT_VERSION}}/packages/flakybot/ . | ||
- uses: actions/setup-go@v3 | ||
with: | ||
cache: true | ||
cache-dependency-path: '${{ github.workspace }}/go.sum' | ||
go-version-file: '${{ github.workspace }}/go.mod' | ||
- name: run FlakyBot | ||
run: go run flakybot.go --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# 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: Remove Label | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
remove_label: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
try { | ||
const event = JSON.parse( | ||
require("fs").readFileSync(process.env.GITHUB_EVENT_PATH, "utf8") | ||
); | ||
await github.rest.issues.removeLabel({ | ||
name: "actions:force-run", | ||
owner: "GoogleCloudPlatform", | ||
repo: "nodejs-docs-samples", | ||
issue_number: event.pull_request.number, | ||
}); | ||
} catch (e) { | ||
if (!e.message.includes("Label does not exist")) { | ||
throw e; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,57 +33,15 @@ on: | |
- cron: '0 0 * * 0' | ||
jobs: | ||
test: | ||
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 60 | ||
permissions: | ||
contents: 'write' | ||
pull-requests: 'write' | ||
id-token: 'write' | ||
defaults: | ||
run: | ||
working-directory: scheduler | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
ref: ${{github.event.pull_request.head.sha}} | ||
- uses: 'google-github-actions/[email protected]' | ||
with: | ||
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' | ||
service_account: '[email protected]' | ||
create_credentials_file: 'true' | ||
access_token_lifetime: 600s | ||
- uses: actions/[email protected] | ||
with: | ||
node-version: 16 | ||
- run: npm install | ||
working-directory: . | ||
- run: npm install | ||
- run: npm run build | ||
- run: npm test | ||
env: | ||
MOCHA_REPORTER_SUITENAME: scheduler | ||
MOCHA_REPORTER_OUTPUT: scheduler_sponge_log.xml | ||
MOCHA_REPORTER: xunit | ||
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
try { | ||
await github.rest.issues.removeLabel({ | ||
name: 'actions:force-run', | ||
owner: 'GoogleCloudPlatform', | ||
repo: 'nodejs-docs-samples', | ||
issue_number: context.payload.pull_request.number | ||
}); | ||
} catch (e) { | ||
if (!e.message.includes('Label does not exist')) { | ||
throw e; | ||
} | ||
} | ||
- if: ${{ github.event_name == 'schedule' && always() }} | ||
run: | | ||
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L | ||
chmod +x ./flakybot | ||
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} | ||
if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' | ||
uses: ./.github/workflows/test.yaml | ||
with: | ||
name: 'scheduler' | ||
path: 'scheduler' | ||
remove_label: | ||
if: github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' && always() | ||
uses: ./.github/workflows/remove-label.yaml | ||
flakybot: | ||
if: github.event_name == 'schedule' && always() | ||
uses: ./.github/workflows/flakybot.yaml | ||
needs: [test] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# 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: Test | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
name: | ||
required: true | ||
type: string | ||
path: | ||
required: true | ||
type: string | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 60 | ||
permissions: | ||
contents: 'write' | ||
pull-requests: 'write' | ||
id-token: 'write' | ||
defaults: | ||
run: | ||
working-directory: ${{ inputs.path }} | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
ref: ${{github.event.pull_request.head.sha}} | ||
- uses: 'google-github-actions/[email protected]' | ||
with: | ||
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' | ||
service_account: '[email protected]' | ||
create_credentials_file: 'true' | ||
access_token_lifetime: 600s | ||
- uses: actions/[email protected] | ||
with: | ||
node-version: 16 | ||
- name: Get npm cache directory | ||
id: npm-cache-dir | ||
shell: bash | ||
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | ||
- uses: actions/cache@v3 | ||
id: npm-cache | ||
with: | ||
path: ${{ steps.npm-cache-dir.outputs.dir }} | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: install repo dependencies | ||
run: npm install | ||
working-directory: . | ||
- name: install directory dependencies | ||
run: npm install | ||
- run: npm run build | ||
- name: Set env vars for scheduled run | ||
if: github.event.action == 'schedule' | ||
run: | | ||
echo "MOCHA_REPORTER_SUITENAME=${{ inputs.name }}" >> $GITHUB_ENV | ||
echo "MOCHA_REPORTER_OUTPUT=${{github.run_id}}_sponge_log.xml" >> $GITHUB_ENV | ||
echo "MOCHA_REPORTER=xunit" >> $GITHUB_ENV | ||
- run: npm test | ||
- name: Upload test results for FlakyBot workflow | ||
if: github.event.action == 'schedule' && always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-results | ||
path: ${{ inputs.path }}/${{ env.MOCHA_REPORTER_OUTPUT }} | ||
retention-days: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2020 Google LLC | ||
// | ||
// 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. | ||
const config = {}; | ||
|
||
if (process.env.MOCHA_THROW_DEPRECATION === 'false') { | ||
delete config['throw-deprecation']; | ||
} | ||
if (process.env.MOCHA_REPORTER) { | ||
config.reporter = process.env.MOCHA_REPORTER; | ||
} | ||
|
||
const reporterOptions = []; | ||
if (process.env.MOCHA_REPORTER_OUTPUT) { | ||
reporterOptions.push(`output=${process.env.MOCHA_REPORTER_OUTPUT}`); | ||
} | ||
if (process.env.MOCHA_REPORTER_SUITENAME) { | ||
reporterOptions.push(`suiteName=${process.env.MOCHA_REPORTER_SUITENAME}`); | ||
} | ||
config['reporter-option'] = reporterOptions; | ||
|
||
module.exports = config; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.