gha: Pass event specific info from the caller workflow

Let's ensure we're not relying, on any of the called workflows, on event
specific information.

Right now, the two information we've been relying on are:
* PR number, coming from github.event.pull_request.number
* Commit hash, coming from github.event.pull_request.head.sha

As we want to, in the future, add nightly jobs, which will be triggered
by a different event (thus, having different fields populated), we
should ensure that those are not used unless it's in the "top action"
that's trigerred by the event.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2023-07-06 11:23:17 +02:00
parent a3fc673121
commit cc3993d860
13 changed files with 79 additions and 23 deletions

View File

@ -13,6 +13,9 @@ on:
required: false required: false
type: string type: string
default: no default: no
commit-hash:
required: false
type: string
jobs: jobs:
build-asset: build-asset:
@ -60,7 +63,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
fetch-depth: 0 # This is needed in order to keep the commit ids history fetch-depth: 0 # This is needed in order to keep the commit ids history
- name: Build ${{ matrix.asset }} - name: Build ${{ matrix.asset }}
@ -88,7 +91,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: get-artifacts - name: get-artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:

View File

@ -9,6 +9,9 @@ on:
required: false required: false
type: string type: string
default: no default: no
commit-hash:
required: false
type: string
jobs: jobs:
build-asset: build-asset:
@ -41,7 +44,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
fetch-depth: 0 # This is needed in order to keep the commit ids history fetch-depth: 0 # This is needed in order to keep the commit ids history
- name: Build ${{ matrix.asset }} - name: Build ${{ matrix.asset }}
run: | run: |
@ -72,7 +75,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: get-artifacts - name: get-artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:

View File

@ -9,6 +9,9 @@ on:
required: false required: false
type: string type: string
default: no default: no
commit-hash:
required: false
type: string
jobs: jobs:
build-asset: build-asset:
@ -37,7 +40,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
fetch-depth: 0 # This is needed in order to keep the commit ids history fetch-depth: 0 # This is needed in order to keep the commit ids history
- name: Build ${{ matrix.asset }} - name: Build ${{ matrix.asset }}
run: | run: |
@ -69,7 +72,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: get-artifacts - name: get-artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:

View File

@ -12,23 +12,28 @@ on:
- synchronize - synchronize
- reopened - reopened
- labeled - labeled
env:
COMMIT_HASH: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_requesst.number }}
jobs: jobs:
build-kata-static-tarball-amd64: build-kata-static-tarball-amd64:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }} if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}
uses: ./.github/workflows/build-kata-static-tarball-amd64.yaml uses: ./.github/workflows/build-kata-static-tarball-amd64.yaml
with: with:
tarball-suffix: -${{ github.event.pull_request.number}}-${{ github.event.pull_request.head.sha }} tarball-suffix: -${{ env.PR_NUMBER }}-${{ env.COMMIT_HASH }}
commit-hash: ${{ env.COMMIT_HASH }}
publish-kata-deploy-payload-amd64: publish-kata-deploy-payload-amd64:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }} if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}
needs: build-kata-static-tarball-amd64 needs: build-kata-static-tarball-amd64
uses: ./.github/workflows/publish-kata-deploy-payload-amd64.yaml uses: ./.github/workflows/publish-kata-deploy-payload-amd64.yaml
with: with:
tarball-suffix: -${{ github.event.pull_request.number}}-${{ github.event.pull_request.head.sha }} tarball-suffix: -${{ env.PR_NUMBER }}-${{ env.COMMIT_HASH }}
registry: ghcr.io registry: ghcr.io
repo: ${{ github.repository_owner }}/kata-deploy-ci repo: ${{ github.repository_owner }}/kata-deploy-ci
tag: ${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-amd64 tag: ${{ env.PR_NUMBER }}-${{ env.COMMIT_HASH }}-amd64
commit-hash: ${{ env.COMMIT_HASH }}
secrets: inherit secrets: inherit
run-k8s-tests-on-aks: run-k8s-tests-on-aks:
@ -38,7 +43,8 @@ jobs:
with: with:
registry: ghcr.io registry: ghcr.io
repo: ${{ github.repository_owner }}/kata-deploy-ci repo: ${{ github.repository_owner }}/kata-deploy-ci
tag: ${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-amd64 tag: ${{ env.PR_NUMBER }}-${{ env.COMMIT_HASH }}-amd64
commit-hash: ${{ env.COMMIT_HASH }}
secrets: inherit secrets: inherit
run-k8s-tests-on-sev: run-k8s-tests-on-sev:
@ -48,7 +54,8 @@ jobs:
with: with:
registry: ghcr.io registry: ghcr.io
repo: ${{ github.repository_owner }}/kata-deploy-ci repo: ${{ github.repository_owner }}/kata-deploy-ci
tag: ${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-amd64 tag: ${{ env.PR_NUMBER }}-${{ env.COMMIT_HASH }}-amd64
commit-hash: ${{ env.COMMIT_HASH }}
run-k8s-tests-on-snp: run-k8s-tests-on-snp:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }} if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}
@ -57,7 +64,9 @@ jobs:
with: with:
registry: ghcr.io registry: ghcr.io
repo: ${{ github.repository_owner }}/kata-deploy-ci repo: ${{ github.repository_owner }}/kata-deploy-ci
tag: ${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-amd64 tag: ${{ env.PR_NUMBER }}-${{ env.COMMIT_HASH }}-amd64
pr-number: ${{ env.PR_NUMBER }}
commit-hash: ${{ env.COMMIT_HASH }}
run-k8s-tests-on-tdx: run-k8s-tests-on-tdx:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }} if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}
@ -66,11 +75,13 @@ jobs:
with: with:
registry: ghcr.io registry: ghcr.io
repo: ${{ github.repository_owner }}/kata-deploy-ci repo: ${{ github.repository_owner }}/kata-deploy-ci
tag: ${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-amd64 tag: ${{ env.PR_NUMBER }}-${{ env.COMMIT_HASH }}-amd64
commit-hash: ${{ env.COMMIT_HASH }}
run-metrics-tests: run-metrics-tests:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }} if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}
needs: build-kata-static-tarball-amd64 needs: build-kata-static-tarball-amd64
uses: ./.github/workflows/run-metrics.yaml uses: ./.github/workflows/run-metrics.yaml
with: with:
tarball-suffix: -${{ github.event.pull_request.number}}-${{ github.event.pull_request.head.sha }} tarball-suffix: -${{ env.PR_NUMBER }}-${{ env.COMMIT_HASH }}-amd64
commit-hash: ${{ env.COMMIT_HASH }}

View File

@ -5,22 +5,28 @@ on:
- main - main
- stable-* - stable-*
env:
COMMIT_HASH: $GITHUB_REF
jobs: jobs:
build-assets-amd64: build-assets-amd64:
uses: ./.github/workflows/build-kata-static-tarball-amd64.yaml uses: ./.github/workflows/build-kata-static-tarball-amd64.yaml
with: with:
commit-hash: ${{ env.COMMIT_HASH }}
push-to-registry: yes push-to-registry: yes
secrets: inherit secrets: inherit
build-assets-arm64: build-assets-arm64:
uses: ./.github/workflows/build-kata-static-tarball-arm64.yaml uses: ./.github/workflows/build-kata-static-tarball-arm64.yaml
with: with:
commit-hash: ${{ env.COMMIT_HASH }}
push-to-registry: yes push-to-registry: yes
secrets: inherit secrets: inherit
build-assets-s390x: build-assets-s390x:
uses: ./.github/workflows/build-kata-static-tarball-s390x.yaml uses: ./.github/workflows/build-kata-static-tarball-s390x.yaml
with: with:
commit-hash: ${{ env.COMMIT_HASH }}
push-to-registry: yes push-to-registry: yes
secrets: inherit secrets: inherit
@ -28,6 +34,7 @@ jobs:
needs: build-assets-amd64 needs: build-assets-amd64
uses: ./.github/workflows/publish-kata-deploy-payload-amd64.yaml uses: ./.github/workflows/publish-kata-deploy-payload-amd64.yaml
with: with:
commit-hash: ${{ env.COMMIT_HASH }}
registry: quay.io registry: quay.io
repo: kata-containers/kata-deploy-ci repo: kata-containers/kata-deploy-ci
tag: kata-containers-amd64 tag: kata-containers-amd64
@ -37,6 +44,7 @@ jobs:
needs: build-assets-arm64 needs: build-assets-arm64
uses: ./.github/workflows/publish-kata-deploy-payload-arm64.yaml uses: ./.github/workflows/publish-kata-deploy-payload-arm64.yaml
with: with:
commit-hash: ${{ env.COMMIT_HASH }}
registry: quay.io registry: quay.io
repo: kata-containers/kata-deploy-ci repo: kata-containers/kata-deploy-ci
tag: kata-containers-arm64 tag: kata-containers-arm64
@ -46,6 +54,7 @@ jobs:
needs: build-assets-s390x needs: build-assets-s390x
uses: ./.github/workflows/publish-kata-deploy-payload-s390x.yaml uses: ./.github/workflows/publish-kata-deploy-payload-s390x.yaml
with: with:
commit-hash: ${{ env.COMMIT_HASH }}
registry: quay.io registry: quay.io
repo: kata-containers/kata-deploy-ci repo: kata-containers/kata-deploy-ci
tag: kata-containers-s390x tag: kata-containers-s390x

View File

@ -14,6 +14,9 @@ on:
tag: tag:
required: true required: true
type: string type: string
commit-hash:
required: false
type: string
jobs: jobs:
kata-payload: kata-payload:
@ -21,7 +24,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: get-kata-tarball - name: get-kata-tarball
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3

View File

@ -14,6 +14,9 @@ on:
tag: tag:
required: true required: true
type: string type: string
commit-hash:
required: false
type: string
jobs: jobs:
kata-payload: kata-payload:
@ -25,7 +28,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: get-kata-tarball - name: get-kata-tarball
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3

View File

@ -14,6 +14,9 @@ on:
tag: tag:
required: true required: true
type: string type: string
commit-hash:
required: false
type: string
jobs: jobs:
kata-payload: kata-payload:
@ -25,7 +28,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: get-kata-tarball - name: get-kata-tarball
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3

View File

@ -11,6 +11,12 @@ on:
tag: tag:
required: true required: true
type: string type: string
pr-number:
required: true
type: string
commit-hash:
required: false
type: string
jobs: jobs:
run-k8s-tests: run-k8s-tests:
@ -31,13 +37,13 @@ jobs:
DOCKER_REGISTRY: ${{ inputs.registry }} DOCKER_REGISTRY: ${{ inputs.registry }}
DOCKER_REPO: ${{ inputs.repo }} DOCKER_REPO: ${{ inputs.repo }}
DOCKER_TAG: ${{ inputs.tag }} DOCKER_TAG: ${{ inputs.tag }}
GH_PR_NUMBER: ${{ github.event.pull_request.number }} GH_PR_NUMBER: ${{ inputs.pr-number }}
KATA_HOST_OS: ${{ matrix.host_os }} KATA_HOST_OS: ${{ matrix.host_os }}
KATA_HYPERVISOR: ${{ matrix.vmm }} KATA_HYPERVISOR: ${{ matrix.vmm }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: Download Azure CLI - name: Download Azure CLI
run: bash tests/integration/gha-run.sh install-azure-cli run: bash tests/integration/gha-run.sh install-azure-cli

View File

@ -11,6 +11,9 @@ on:
tag: tag:
required: true required: true
type: string type: string
commit-hash:
required: false
type: string
jobs: jobs:
run-k8s-tests: run-k8s-tests:
@ -29,7 +32,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: Run tests - name: Run tests
timeout-minutes: 30 timeout-minutes: 30

View File

@ -11,6 +11,9 @@ on:
tag: tag:
required: true required: true
type: string type: string
commit-hash:
required: false
type: string
jobs: jobs:
run-k8s-tests: run-k8s-tests:
@ -29,7 +32,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: Run tests - name: Run tests
timeout-minutes: 30 timeout-minutes: 30

View File

@ -11,6 +11,9 @@ on:
tag: tag:
required: true required: true
type: string type: string
commit-hash:
required: false
type: string
jobs: jobs:
run-k8s-tests: run-k8s-tests:
@ -29,7 +32,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: Run tests - name: Run tests
timeout-minutes: 30 timeout-minutes: 30

View File

@ -5,6 +5,9 @@ on:
tarball-suffix: tarball-suffix:
required: false required: false
type: string type: string
commit-hash:
required: false
type: string
jobs: jobs:
run-metrics: run-metrics:
@ -20,7 +23,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ inputs.commit-hash }}
- name: get-kata-tarball - name: get-kata-tarball
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3