Test3 #113
Workflow file for this run
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
name: test base images | |
on: | |
pull_request_target: | |
types: | |
- labeled | |
- opened | |
- synchronize | |
pull_request_review: | |
types: [submitted] | |
# Enable manual invocation of this workflow GitHub Actions GUI | |
workflow_dispatch: | |
inputs: | |
os: | |
description: "The OS to run the integration test with" | |
type: choice | |
required: true | |
options: | |
- all | |
- ubuntu-20 | |
- ubuntu-22 | |
- os-ubuntu | |
- rocky-8.7 | |
- rocky-9.1 | |
- os-rocky | |
- centos-7.9 | |
- os-centos | |
- rhel-7.9 | |
- rhel-8.4 | |
- rhel-8.6 | |
- rhel-8.8 | |
- rhel-8.10 | |
- rhel-9.4 | |
- os-rhel | |
- oraclelinux-9.4 | |
- os-oraclelinux | |
- flatcar-3033.3.16 | |
- os-flatcar | |
env: | |
VSPHERE_USERNAME: ${{ secrets.VSPHERE_NKP_SRE_USERNAME }} | |
VSPHERE_PASSWORD: ${{ secrets.VSPHERE_SRE_PASSWORD }} | |
VSPHERE_SERVER: ${{ secrets.VSPHERE_NKP_SERVER }} | |
GOVC_URL: ${{ secrets.VSPHERE_NKP_SRE_USERNAME }}:${{ secrets.VSPHERE_SRE_PASSWORD }}@${{ secrets.VSPHERE_NKP_SERVER }} | |
PKR_VAR_vsphere_cluster: ${{ secrets.VSPHERE_CLUSTER }} | |
PKR_VAR_vsphere_datacenter: ${{ secrets.VSPHERE_DATACENTER }} | |
PKR_VAR_vsphere_datastore: ${{ secrets.VSPHERE_NKP_DATASTORE }} | |
PKR_VAR_vsphere_network: ${{ secrets.VSPHERE_NKP_NETWORK }} | |
PKR_VAR_vsphere_resource_pool: ${{ secrets.VSPHERE_RESOURCE_POOL }} | |
RHN_SUBSCRIPTION_ORG: ${{ secrets.RHN_SUBSCRIPTION_ORG }} | |
RHN_SUBSCRIPTION_KEY: ${{ secrets.RHN_SUBSCRIPTION_KEY }} | |
jobs: | |
check_approvals: | |
runs-on: self-hosted-nutanix-medium | |
outputs: | |
result: ${{ steps.check_approvals.outputs.result }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Check for required approvals and integration_test label | |
id: check_approvals | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const prNumber = context.payload.pull_request.number; | |
const { data: reviews } = await github.rest.pulls.listReviews({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: prNumber | |
}); | |
const approvedReviews = reviews.filter(review => review.state === 'APPROVED'); | |
const requiredApprovals = 1; // Set the number of required approvals here | |
const labels = context.payload.pull_request.labels.map(label => label.name); | |
const hasIntegrationTestLabel = labels.includes('integration_test') || labels.includes('skip_integration'); | |
console.log(`Approvals: ${approvedReviews.length}`); | |
console.log(`Required approvals: ${requiredApprovals}`); | |
#fail the job if the required approvals are not met | |
if (approvedReviews.length < requiredApprovals) { | |
core.setFailed(`Required approvals not met. Current approvals: ${approvedReviews.length}`); | |
} | |
#fail the job if the integration_test label is not present | |
if (!hasIntegrationTestLabel) { | |
core.setFailed('The integration_test label is required to run the integration tests'); | |
} | |
return approvedReviews.length >= requiredApprovals && hasIntegrationTestLabel; | |
# Build matrix to test when label integration_test is added to PR or manually invoked. | |
output_check_approvals: | |
runs-on: self-hosted-nutanix-medium | |
needs: check_approvals | |
steps: | |
- name: Output check approvals | |
run: | | |
echo "ouputs: ${{ needs.check_approvals.outputs.result }}" | |
build_list: | |
runs-on: | |
- self-hosted-nutanix-medium | |
needs: check_approvals | |
strategy: | |
fail-fast: false | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
if: ${{ needs.check_approvals.outputs.result == 'true' || contains(fromJson('["workflow_dispatch"]'), github.event_name) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ github.event.pull_request.head.sha }}" | |
- name: Build OS matrix for all OS | |
if: contains(github.event.pull_request.labels.*.name, 'integration_test') || contains(fromJson('["workflow_dispatch"]'), github.event_name) && github.event.inputs.os == 'all' | |
id: build-os-matrix | |
run: | | |
DYNAMICOSLIST=$(make list-os-versions | head -c -1 | tr '\n' ',') | |
echo "buildmatrix=$(jq -cn --arg os_list $DYNAMICOSLIST '{os: $os_list | split(",")}')" >> $GITHUB_ENV | |
- name: Build OS matrix for distro (os prefix) | |
if: contains(fromJson('["workflow_dispatch"]'), github.event_name) && contains(github.event.inputs.os, 'os-') | |
id: build-os-matrix-distro | |
run: | | |
OSPREFIX=$(echo ${{ github.event.inputs.os }} | cut -d '-' -f 2) | |
DYNAMICOSLIST=$(make list-os-versions | grep -E "$OSPREFIX" | head -c -1 | tr '\n' ',') | |
echo "buildmatrix=$(jq -cn --arg os_list $DYNAMICOSLIST '{os: $os_list | split(",")}')" >> $GITHUB_ENV | |
- name: Build OS matrix for single OS | |
if: contains(fromJson('["workflow_dispatch"]'), github.event_name) && github.event.inputs.os != 'all' && !contains(github.event.inputs.os, 'os-') | |
id: build-os-matrix-single | |
run: | | |
echo "buildmatrix=$(jq -cn --arg os_list '${{ github.event.inputs.os }}' '{os: $os_list | split(",")}')" >> $GITHUB_ENV | |
- name: Empty OS matrix | |
id: empty-os-matrix | |
if: ${{ !contains(fromJson('["workflow_dispatch"]'), github.event_name) }} | |
run: | | |
echo "buildmatrix=$(jq -cn --arg os_list '' '{os: $os_list | split(",")}')" >> $GITHUB_ENV | |
- name: Set matrix output | |
id: set-matrix | |
run: | | |
echo 'matrix=${{ env.buildmatrix }}' >> $GITHUB_OUTPUT | |
base_image_tests: | |
runs-on: | |
- self-hosted-nutanix-medium | |
needs: build_list | |
# if matrix os is empty, skip this job | |
if: ${{fromJson(needs.build_list.outputs.matrix)}}.os != [] | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.build_list.outputs.matrix)}} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ github.event.pull_request.head.sha }}" | |
- name: Setup requirements | |
run: | | |
sudo apt-get update && sudo apt-get -y install xorriso | |
curl -L -o - "https://github.com/vmware/govmomi/releases/latest/download/govc_$(uname -s)_$(uname -m).tar.gz" | sudo tar -C /usr/local/bin -xvzf - govc | |
- name: Run integration tests for ${{ matrix.os }} | |
run: make ${{ matrix.os }}-test |