Skip to content

Commit

Permalink
test actions/download-artifact@v4
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo Lorenzo <[email protected]>
  • Loading branch information
adrianriobo committed May 2, 2024
1 parent fdef61b commit 7605468
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 175 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/windows-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
windows-e2e-ocp:
uses: crc-org/crc/.github/workflows/windows-qe-tpl.yml@main
uses: adrianriobo/crc/.github/workflows/windows-qe-tpl.yml@main
strategy:
fail-fast: false
matrix:
Expand All @@ -22,7 +22,7 @@ jobs:
- qe-type: 'integration'
preset: 'microshift'
with:
trigger-workflow-id: ${{ github.event.workflow_run.workflow_id }}
trigger-workflow-run-id: ${{ github.event.workflow_run.id }}
qe-type: ${{matrix.qe-type}}
preset: ${{matrix.preset}}
secrets: inherit
Expand Down
186 changes: 13 additions & 173 deletions .github/workflows/windows-qe-tpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ name: windows-qe-tpl
on:
workflow_call:
inputs:
trigger-workflow-id:
trigger-workflow-run-id:
description: run-id of the workflow which originate the execution and where the artifacts have been built
required: true
type: string
qe-type:
Expand All @@ -31,187 +32,26 @@ jobs:
steps:
- name: Download gh context
id: download-gh-context-artifact
uses: dawidd6/action-download-artifact@v3
uses: actions/download-artifact@v4
with:
workflow: ${{inputs.trigger-workflow-id}}
name: gh-context
run-id: ${{inputs.trigger-workflow-run-id}}
github-token: ${{ github.token }}

- name: Download windows installer
id: download-windows-installer-artifact
uses: dawidd6/action-download-artifact@v3
uses: actions/download-artifact@v4
with:
workflow: ${{inputs.trigger-workflow-id}}
name: windows-installer

run-id: ${{inputs.trigger-workflow-run-id}}
github-token: ${{ github.token }}

- name: Download qe oci image
id: download-qe-oci-image-artifact
uses: dawidd6/action-download-artifact@v3
uses: actions/download-artifact@v4
with:
workflow: ${{inputs.trigger-workflow-id}}
name: crc-${{inputs.qe-type}}-windows-amd64
run-id: ${{inputs.trigger-workflow-run-id}}
github-token: ${{ github.token }}

- name: Correlate
env:
PULL_SECRET: ${{ secrets.PULL_SECRET }}
run: |
# Get origin commit sha for testing
commit_sha=$(cat gh_context.json | jq -r '.event.after')
if [[ -z "${commit_sha}" ]]; then
# on first PR creation .event.after is empty, then .sha is used as commit instead
commit_sha=$(cat gh_context.json | jq -r '.sha')
fi
echo "commit_sha=${commit_sha}" >> "$GITHUB_ENV"
# Set status_context
status_context="ci/gh/${{inputs.qe-type}}"
if [[ "${{inputs.qe-type}}" == "e2e" ]]; then
status_context="${status_context}-${{inputs.preset}}"
fi
status_context="${status_context}/windows-${{matrix.windows-version}}-${{matrix.windows-featurepack}}"
echo "status_context=${status_context}" >> "$GITHUB_ENV"
# Save pull-secret as file
echo "${PULL_SECRET}" > pull-secret
- name: Add status to the PR check
run: |
set -xuo
# Status msg
data="{\"state\":\"pending\""
data="${data},\"description\":\"Running ${{inputs.qe-type}}-${{inputs.preset}} on Windows\""
data="${data},\"context\":\"${{ env.status_context }}\""
data="${data},\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
# Create status by API call
curl -L -v -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \
-d "${data}"
- name: Create Windows instance
run: |
# Create instance
podman run -d --name windows-create --rm \
-v ${PWD}:/workspace:z \
-e ARM_TENANT_ID=${{secrets.ARM_TENANT_ID}} \
-e ARM_SUBSCRIPTION_ID=${{secrets.ARM_SUBSCRIPTION_ID}} \
-e ARM_CLIENT_ID=${{secrets.ARM_CLIENT_ID}} \
-e ARM_CLIENT_SECRET='${{secrets.ARM_CLIENT_SECRET}}' \
-e AZURE_STORAGE_ACCOUNT='${{ secrets.AZURE_STORAGE_ACCOUNT }}' \
-e AZURE_STORAGE_KEY='${{ secrets.AZURE_STORAGE_KEY }}' \
quay.io/rhqp/qenvs:v0.6.3 azure \
windows create \
--project-name 'windows-desktop-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}-${{inputs.qe-type}}-${{inputs.preset}}' \
--backed-url azblob://crc-qenvs-state/${{ env.commit_sha }} \
--conn-details-output '/workspace' \
--windows-version '${{matrix.windows-version}}' \
--windows-featurepack '${{matrix.windows-featurepack}}' \
--tags project=openshift-local,source=github,org=${{github.repository_owner}} \
--spot
podman logs -f windows-create
- name: Install CRC on host
run: |
podman run --rm -d --name crc-win-support \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=crc-support \
-e TARGET_CLEANUP='false' \
-e OUTPUT_FOLDER=/data \
-e DEBUG='true' \
-v ${PWD}:/data:z \
-v ${PWD}/crc-windows-installer.zip:/opt/crc-support/crc-windows-installer.zip:z \
quay.io/rhqp/crc-support:v0.5-windows crc-support/run.ps1 \
-targetPath "/Users/$(cat username)/crc-support" \
-download 'false' \
-install 'true' \
-forceFresh 'false'
podman logs -f crc-win-support
- name: Run CRC ${{inputs.qe-type}}
run: |
# load image
podman load -i crc-${{inputs.qe-type}}-windows-amd64.tar
# run
cmd="crc-qe/run.ps1 -junitFilename crc-${{inputs.qe-type}}-junit.xml -targetFolder crc-qe"
if [[ "${{inputs.qe-type}}" == "e2e" ]]; then
if [[ "${{inputs.preset}}" == "microshift" ]]; then
cmd="${cmd} -e2eTagExpression '@story_microshift'"
else
cmd="${cmd} -e2eTagExpression '~@minimal && ~@story_microshift'"
fi
fi
podman run --rm -d --name crc-${{inputs.qe-type}} \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=crc-qe \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD/pull-secret:/opt/crc/pull-secret:z \
-v $PWD:/data:z \
quay.io/crcont/crc-${{inputs.qe-type}}:gh-windows-amd64 \
${cmd}
podman logs -f crc-${{inputs.qe-type}}
- name: Test Report
id: test-report
uses: mikepenz/action-junit-report@v4
if: always()
with:
fail_on_failure: true
include_passed: true
detailed_summary: true
require_tests: true
report_paths: '**/*.xml'

- name: Upload ${{inputs.qe-type}} results
uses: actions/upload-artifact@v4
if: always()
with:
name: windows-${{inputs.qe-type}}-${{inputs.preset}}-${{matrix.windows-version}}${{matrix.windows-featurepack}}
path: |
**/*.xml
**/*.results
**/*.log
- name: Update status of the PR check
if: always()
run: |
set -xuo
# Status msg
data="{\"state\":\"success\""
if [[ ${{steps.test-report.outcome}} != "success" ]]; then
data="{\"state\":\"failure\""
fi
data="${data},\"description\":\"Finished ${{inputs.qe-type}}-${{inputs.preset}} on Windows\""
data="${data},\"context\":\"${{ env.status_context }}\""
data="${data},\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
# Create status by API call
curl -L -v -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \
-d "${data}"
- name: Destroy instance
if: always()
run: |
# Make sure lock is removed
rm -rf .pulumi/locks/*
# Destroy
podman run -d --name windows-destroy --rm \
-v ${PWD}:/workspace:z \
-e ARM_TENANT_ID=${{secrets.ARM_TENANT_ID}} \
-e ARM_SUBSCRIPTION_ID=${{secrets.ARM_SUBSCRIPTION_ID}} \
-e ARM_CLIENT_ID=${{secrets.ARM_CLIENT_ID}} \
-e ARM_CLIENT_SECRET='${{secrets.ARM_CLIENT_SECRET}}' \
-e AZURE_STORAGE_ACCOUNT='${{ secrets.AZURE_STORAGE_ACCOUNT }}' \
-e AZURE_STORAGE_KEY='${{ secrets.AZURE_STORAGE_KEY }}' \
quay.io/rhqp/qenvs:v0.6.3 azure \
windows destroy \
--project-name 'windows-desktop-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}-${{inputs.qe-type}}-${{inputs.preset}}' \
--backed-url azblob://crc-qenvs-state/${{ env.commit_sha }}
podman logs -f windows-destroy

0 comments on commit 7605468

Please sign in to comment.