kata-deploy: for testing, make sure we use the PR branch

Since we are already checking that only an admin is triggering the job,
let's go ahead and make sure we are testing against the PR itself. This
will ensure that we are exercising changes to kata-deploy tooling, which
is important for this test.

While at it, cleanup and simplify some of the tarball creation.

Fixes: #3586

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
Eric Ernst 2022-02-01 10:53:28 -08:00
parent a31cde1224
commit 24796d2f25

View File

@ -48,18 +48,16 @@ jobs:
- rootfs-initrd - rootfs-initrd
- shim-v2 - shim-v2
steps: steps:
# As Github action event `issue_comment` does not provide the right ref - name: get-PR-ref
# (commit/branch) to be tested, let's use this third part action to work id: get-PR-ref
# this limitation around. run: |
- name: resolve pr refs ref=$(cat $GITHUB_EVENT_PATH | jq -r '.issue.pull_request.url' | sed 's#^.*\/pulls#refs\/pull#' | sed 's#$#\/merge#')
id: refs echo "reference for PR: " ${ref}
uses: kata-containers/resolve-pr-refs@v0.0.3 echo "##[set-output name=pr-ref;]${ref}"
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
ref: ${{ steps.refs.outputs.base_ref }} ref: ${{ steps.get-PR-ref.outputs.pr-ref }}
- name: Install docker - name: Install docker
run: | run: |
curl -fsSL https://test.docker.com -o test-docker.sh curl -fsSL https://test.docker.com -o test-docker.sh
@ -86,17 +84,15 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build-asset needs: build-asset
steps: steps:
# As Github action event `issue_comment` does not provide the right ref - name: get-PR-ref
# (commit/branch) to be tested, let's use this third part action to work id: get-PR-ref
# this limitation around. run: |
- name: resolve pr refs ref=$(cat $GITHUB_EVENT_PATH | jq -r '.issue.pull_request.url' | sed 's#^.*\/pulls#refs\/pull#' | sed 's#$#\/merge#')
id: refs echo "reference for PR: " ${ref}
uses: kata-containers/resolve-pr-refs@v0.0.3 echo "##[set-output name=pr-ref;]${ref}"
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
ref: ${{ steps.refs.outputs.base_ref }} ref: ${{ steps.get-PR-ref.outputs.pr-ref }}
- name: get-artifacts - name: get-artifacts
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
@ -115,17 +111,15 @@ jobs:
needs: create-kata-tarball needs: create-kata-tarball
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# As Github action event `issue_comment` does not provide the right ref - name: get-PR-ref
# (commit/branch) to be tested, let's use this third part action to work id: get-PR-ref
# this limitation around. run: |
- name: resolve pr refs ref=$(cat $GITHUB_EVENT_PATH | jq -r '.issue.pull_request.url' | sed 's#^.*\/pulls#refs\/pull#' | sed 's#$#\/merge#')
id: refs echo "reference for PR: " ${ref}
uses: kata-containers/resolve-pr-refs@v0.0.3 echo "##[set-output name=pr-ref;]${ref}"
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
ref: ${{ steps.refs.outputs.base_ref }} ref: ${{ steps.get-PR-ref.outputs.pr-ref }}
- name: get-kata-tarball - name: get-kata-tarball
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
@ -133,18 +127,14 @@ jobs:
- name: build-and-push-kata-deploy-ci - name: build-and-push-kata-deploy-ci
id: build-and-push-kata-deploy-ci id: build-and-push-kata-deploy-ci
run: | run: |
tag=$(echo $GITHUB_REF | cut -d/ -f3-) PR_SHA=$(git log --format=format:%H -n1)
pushd $GITHUB_WORKSPACE
git checkout $tag
pkg_sha=$(git rev-parse HEAD)
popd
mv kata-static.tar.xz $GITHUB_WORKSPACE/tools/packaging/kata-deploy/kata-static.tar.xz mv kata-static.tar.xz $GITHUB_WORKSPACE/tools/packaging/kata-deploy/kata-static.tar.xz
docker build --build-arg KATA_ARTIFACTS=kata-static.tar.xz -t quay.io/kata-containers/kata-deploy-ci:$pkg_sha $GITHUB_WORKSPACE/tools/packaging/kata-deploy docker build --build-arg KATA_ARTIFACTS=kata-static.tar.xz -t quay.io/kata-containers/kata-deploy-ci:$PR_SHA $GITHUB_WORKSPACE/tools/packaging/kata-deploy
docker login -u ${{ secrets.QUAY_DEPLOYER_USERNAME }} -p ${{ secrets.QUAY_DEPLOYER_PASSWORD }} quay.io docker login -u ${{ secrets.QUAY_DEPLOYER_USERNAME }} -p ${{ secrets.QUAY_DEPLOYER_PASSWORD }} quay.io
docker push quay.io/kata-containers/kata-deploy-ci:$pkg_sha docker push quay.io/kata-containers/kata-deploy-ci:$PR_SHA
mkdir -p packaging/kata-deploy mkdir -p packaging/kata-deploy
ln -s $GITHUB_WORKSPACE/tools/packaging/kata-deploy/action packaging/kata-deploy/action ln -s $GITHUB_WORKSPACE/tools/packaging/kata-deploy/action packaging/kata-deploy/action
echo "::set-output name=PKG_SHA::${pkg_sha}" echo "::set-output name=PKG_SHA::${PR_SHA}"
- name: test-kata-deploy-ci-in-aks - name: test-kata-deploy-ci-in-aks
uses: ./packaging/kata-deploy/action uses: ./packaging/kata-deploy/action
with: with: