KM CI Coverage Pipeline #567
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 2021 Kontain Inc | |
# | |
# 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: KM CI Coverage Pipeline | |
on: | |
# pull_request: | |
# branches: [master] | |
# paths-ignore: | |
# # See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet | |
# - "**.md" # all .md files in repo | |
# - "**/docs/**" # all content of all docs/ dirs in repo | |
# - compile_commands.json | |
# - .vscode/** | |
# - km-releases | |
# - payloads/longhaul-test/** | |
# - "**/L0-image**" | |
# push: | |
# branches: [master] | |
# paths-ignore: | |
# - "**.md" # all .md files in repo | |
# - "**/docs/**" # all content of all docs/ dirs in repo | |
# - compile_commands.json | |
# - .vscode/** | |
# - km-releases | |
# - payloads/longhaul-test/** | |
# - "**/L0-image**" | |
schedule: | |
# Posix cron format: | |
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07 | |
# Minute Hour DayOfMonth MonthOfYear DayOfWeek | |
- cron: "0 7 * * *" # Daily build midnight pacific time (UTC + 7) | |
# Gitgub doc says: | |
# Scheduled workflows run on the latest commit on the default or base branch. | |
# The shortest interval you can run scheduled workflows is once every 5 minutes. | |
# Manual trigger. | |
# See https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/ | |
workflow_dispatch: | |
inputs: | |
run_type: | |
description: "Run type: regular or nightly" | |
default: "regular" | |
required: true | |
env: | |
BUILDENV_IMAGE_VERSION: latest # use this for all buildenv containers | |
IMAGE_VERSION: ci-${{ github.run_number }} # use this for all other containers | |
SP_SUBSCRIPTION_ID: ${{ secrets.SP_SUBSCRIPTION_ID }} | |
SP_APPID: ${{ secrets.SP_APPID }} | |
SP_PASSWORD: ${{ secrets.SP_PASSWORD }} | |
SP_TENANT: ${{ secrets.SP_TENANT }} | |
jobs: | |
# starts self-hosted runner in AWS and Azure. They are NOT ephemeral and will run until cleanup in the stop-runner | |
start-runners: | |
uses: ./.github/workflows/start-cloud-runners.yaml | |
secrets: inherit | |
km-build: | |
name: Build KM, push test image | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: ./.github/actions/km-build | |
with: | |
build-flavor: coverage | |
coverage-azure: | |
name: Check code coverage on Azure | |
runs-on: ${{ fromJSON(needs.start-runners.outputs.run-ons)['azure'] }} | |
needs: [km-build, start-runners] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: ./.github/actions/run-tests | |
with: | |
kernel: kvm | |
build-flavor: coverage | |
- run: ls -la build/km/coverage/*.gcda | |
- name: Store coverage files in artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: azure-coverage | |
path: | | |
build/km/coverage/*.gcda | |
retention-days: 7 | |
coverage-ec2: | |
name: Check code coverage on AWS | |
runs-on: ${{ fromJSON(needs.start-runners.outputs.run-ons)['ec2'] }} | |
needs: [km-build, start-runners, coverage-azure] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
# get gcna files generated by tests on azure | |
- name: Get Azure report | |
uses: actions/download-artifact@v3 | |
with: | |
name: azure-coverage | |
path: build/km/coverage/ | |
- run: ls -la build/km/coverage/* | |
- uses: ./.github/actions/run-tests | |
with: | |
kernel: kkm | |
build-flavor: coverage | |
- run: ls -la build/km/coverage/* | |
- name: Store coverage files in artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: aws-azure-coverage | |
path: | | |
build/km/coverage/*.gcda | |
retention-days: 7 | |
generate-report: | |
name: Generate and Upload Coverage Report | |
runs-on: ubuntu-latest | |
needs: [coverage-ec2] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to Azure Repository | |
run: make -C cloud/azure login-cli | |
- run: | | |
sudo apt-get update -y | |
sudo apt-get install -y gcovr | |
- uses: actions/checkout@v4 | |
- name: Get report files | |
uses: actions/download-artifact@v3 | |
with: | |
name: aws-azure-coverage | |
path: build/km/coverage | |
- run: ls -la build/km/coverage | |
- name: Pull coverage testenv images | |
run: make -C tests pull-coverage-testenv-image | |
- name: generate HTML report and upload to git | |
run: make -C tests upload-coverage-withdocker GITHUB_TOKEN=${{ secrets.GH_TOKEN }} DOCKER_INTERACTIVE= DOCKER_RUN_CLEANUP= | |
# This step is to clean up on-demand runner. They work in conjunction with start-runner. | |
# Make sure to add dependencies in both "needs" clauses | |
stop-runner: | |
if: always() | |
needs: [start-runners, coverage-azure, coverage-ec2, generate-report] | |
uses: ./.github/workflows/stop-cloud-runners.yaml | |
with: | |
dependencies: ${{ toJSON(needs) }} | |
secrets: inherit |