tests-main #237
This file contains 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
# 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: tests-main | |
on: # at 5:10 UTC every day and on each push to main | |
schedule: | |
- cron: "10 5 * * *" | |
push: | |
branches: | |
- 'main' | |
permissions: read-all | |
jobs: | |
unit: | |
name: unit tests | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
- id: 'auth' | |
name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1 | |
with: | |
workload_identity_provider: ${{ secrets.PROVIDER_NAME }} | |
service_account: ${{ secrets.SERVICE_ACCOUNT }} | |
access_token_lifetime: 600s | |
project_id: ${{ secrets.GOOGLE_CLOUD_PROJECT }} | |
- name: Setup Go | |
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | |
with: | |
go-version: '1.20' | |
- name: Set up build.env with phony secrets. | |
run: cp build.sample.env build.env | |
- name: Verify no changes from code generation. | |
run: "make generate \nif ! git diff --exit-code --quiet ; then \n echo\n echo\n git diff --stat \"HEAD\"\n echo\n echo\n echo 'ERROR: Lint tools caused changes to the working dir. '\n exit 1\nfi\n" | |
- name: make test | |
run: make test | |
# specifying bash shell ensures a failure in a piped process isn't lost | |
# by using `set -eo pipefail` | |
shell: bash | |
- name: Convert test output to XML | |
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && always() }} | |
run: | | |
go install github.com/jstemmer/go-junit-report/v2@latest | |
go-junit-report -in test_results.txt -set-exit-code -out unit_sponge_log.xml | |
- name: FlakyBot | |
# only run flakybot on periodic (schedule) and continuous (push) events | |
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && 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 ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} | |
e2e: | |
name: e2e tests | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1 | |
with: | |
workload_identity_provider: ${{ secrets.PROVIDER_NAME }} | |
service_account: ${{ secrets.SERVICE_ACCOUNT }} | |
access_token_lifetime: 600s | |
project_id: ${{ secrets.GOOGLE_CLOUD_PROJECT }} | |
create_credentials_file: true | |
- name: 'Set up Cloud SDK' | |
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1 | |
- name: 'Setup Go' | |
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | |
with: | |
go-version: '1.20' | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@6a58db7e0d21ca03e6c44877909e80e45217eed2 # v2.6.0 | |
- id: 'e2e' | |
name: 'Run E2E Tests' | |
run: "./tools/e2e_test_job.sh" | |
# specifying bash shell ensures a failure in a piped process isn't lost | |
# by using `set -eo pipefail` | |
shell: bash | |
env: | |
ENVIRONMENT_NAME: "ci-branch-main" | |
NODEPOOL_SERVICEACCOUNT_EMAIL: "${{secrets.NODEPOOL_SERVICEACCOUNT_EMAIL}}" | |
WORKLOAD_ID_SERVICEACCOUNT_EMAIL: "${{secrets.WORKLOAD_ID_SERVICEACCOUNT_EMAIL}}" | |
TFSTATE_STORAGE_BUCKET: "${{secrets.TFSTATE_STORAGE_BUCKET}}" | |
E2E_PROJECT_ID: "${{secrets.GOOGLE_CLOUD_PROJECT}}" | |
- name: Convert test output to XML | |
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && always() }} | |
run: | | |
go install github.com/jstemmer/go-junit-report/v2@latest | |
go-junit-report -in test_results.txt -set-exit-code -out unit_sponge_log.xml | |
- name: FlakyBot | |
if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && 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 ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} |