|
| 1 | +name: linux-qe-template |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + trigger-workflow-run-id: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + qe-type: |
| 10 | + description: type of test; allowed values e2e or integration |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + preset: |
| 14 | + description: preset type only required if qe-type is e2e |
| 15 | + type: string |
| 16 | + |
| 17 | +jobs: |
| 18 | + linux-qe: |
| 19 | + runs-on: [self-hosted, linux, testing-farm] |
| 20 | + permissions: |
| 21 | + statuses: write # needed to update commit status (pending/failure/sucess) |
| 22 | + checks: write # as documented in https://github.com/mikepenz/action-junit-report?tab=readme-ov-file#pr-run-permissions |
| 23 | + steps: |
| 24 | + - name: prepare env |
| 25 | + run: | |
| 26 | + sudo yum install podman openssh-server -y |
| 27 | +
|
| 28 | + commit_sha=$(cat gh_context.json | jq -r '.event.after') |
| 29 | + if [[ -z "${commit_sha}" ]] || [[ "${commit_sha}" == null ]]; then |
| 30 | + # on first PR creation .event.after is empty, then .sha is used as commit instead |
| 31 | + commit_sha=$(cat gh_context.json | jq -r '.event.pull_request.head.sha') |
| 32 | + fi |
| 33 | + echo "commit_sha=${commit_sha}" >> "$GITHUB_ENV" |
| 34 | + mkdir ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 35 | + cd ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 36 | +
|
| 37 | + ssh-keygen -t rsa -N '' -f id_rsa -q |
| 38 | + eval $(ssh-agent -s) |
| 39 | + echo $SSH_AUTH_SOCK > ssh_auth_sock |
| 40 | + echo $SSH_AGENT_PID > ssh_agent_pid |
| 41 | + ssh-add id_rsa |
| 42 | +
|
| 43 | + - name: reserve machine from testing farm |
| 44 | + working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 45 | + env: |
| 46 | + TESTING_FARM_API_TOKEN: ${{ secrets.TESTING_FARM_API_TOKEN }} |
| 47 | + PULL_SECRET: ${{ secrets.PULL_SECRET }} |
| 48 | + run: | |
| 49 | + echo "${PULL_SECRET}" > pull-secret |
| 50 | + export TESTING_FARM_API_TOKEN=${TESTING_FARM_API_TOKEN} |
| 51 | + testing-farm reserve --compose Fedora-40 --duration 240 --arch aarch64 --ssh-public-key id_rsa.pub --no-autoconnect | tee info |
| 52 | + machine=`tail -n 1 info` |
| 53 | + echo ${machine##*@} > host |
| 54 | + echo root > username |
| 55 | + echo proxy > bastion_username |
| 56 | + echo testing-farm.io > bastion_host |
| 57 | + |
| 58 | + - name: Download linux binary |
| 59 | + working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 60 | + uses: actions/download-artifact@v4 |
| 61 | + with: |
| 62 | + name: linux-binary |
| 63 | + run-id: ${{inputs.trigger-workflow-run-id}} |
| 64 | + github-token: ${{ github.token }} |
| 65 | + |
| 66 | + - name: Download qe oci image |
| 67 | + working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 68 | + id: download-qe-oci-image-artifact |
| 69 | + uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + name: crc-${{inputs.qe-type}}-linux-arm64 |
| 72 | + run-id: ${{inputs.trigger-workflow-run-id}} |
| 73 | + github-token: ${{ github.token }} |
| 74 | + |
| 75 | + - name: Download integration qe oci image |
| 76 | + working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 77 | + id: download-qe-oci-image-artifact |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + name: crc-integration-linux-arm64 |
| 81 | + run-id: ${{ github.event.workflow_run.id }} |
| 82 | + github-token: ${{ github.token }} |
| 83 | + |
| 84 | + - name: Install CRC on host |
| 85 | + working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 86 | + run: | |
| 87 | + podman run --rm -d --privileged --name crc-linux-install-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} \ |
| 88 | + -e TARGET_HOST=$(cat host) \ |
| 89 | + -e TARGET_HOST_USERNAME=$(cat username) \ |
| 90 | + -e TARGET_HOST_KEY_PATH=/data/id_rsa \ |
| 91 | + -e BASTION_HOST_USERNAME=$(cat bastion_username) \ |
| 92 | + -e BASTION_HOST=$(cat bastion_host) \ |
| 93 | + -e TARGET_FOLDER=crc-support \ |
| 94 | + -e TARGET_CLEANUP='false' \ |
| 95 | + -e OUTPUT_FOLDER=/data \ |
| 96 | + -e DEBUG='true' \ |
| 97 | + -e SSH_AUTH_SOCK=$(cat ssh_auth_sock) \ |
| 98 | + -v "$(cat ssh_auth_sock):$(cat ssh_auth_sock)" \ |
| 99 | + -v ${PWD}:/data:z \ |
| 100 | + -v ${PWD}/crc:/opt/crc-support/crc:z \ |
| 101 | + quay.io/rhqp/crc-support:v0.5.1-linux crc-support/install.sh crc-support/crc |
| 102 | + podman logs -f crc-linux-install-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 103 | +
|
| 104 | + - name: Run CRC ${{inputs.qe-type}} test |
| 105 | + working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 106 | + run: | |
| 107 | + # load image |
| 108 | + podman load -i crc-${{inputs.qe-type}}-linux-arm64.tar |
| 109 | + # run |
| 110 | + cmd="crc-qe/run.sh -junitFilename crc-${{inputs.qe-type}}-junit.xml -targetFolder crc-qe" |
| 111 | + if [[ "${{inputs.qe-type}}" == "e2e" ]]; then |
| 112 | + if [[ "${{inputs.preset}}" == "microshift" ]]; then |
| 113 | + cmd="${cmd} -e2eTagExpression '@story_microshift'" |
| 114 | + else |
| 115 | + cmd="${cmd} -e2eTagExpression '~@minimal && ~@story_microshift'" |
| 116 | + fi |
| 117 | + fi |
| 118 | + podman run --rm -d --privileged --name crc-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} \ |
| 119 | + -e TARGET_HOST=$(cat host) \ |
| 120 | + -e TARGET_HOST_USERNAME=$(cat username) \ |
| 121 | + -e TARGET_HOST_KEY_PATH=/data/id_rsa \ |
| 122 | + -e BASTION_HOST_USERNAME=$(cat bastion_username) \ |
| 123 | + -e BASTION_HOST=$(cat bastion_host) \ |
| 124 | + -e TARGET_FOLDER=crc-qe \ |
| 125 | + -e TARGET_RESULTS=results \ |
| 126 | + -e OUTPUT_FOLDER=/data \ |
| 127 | + -e DEBUG=true \ |
| 128 | + -e SSH_AUTH_SOCK=$(cat ssh_auth_sock) \ |
| 129 | + -v "$(cat ssh_auth_sock):$(cat ssh_auth_sock)" \ |
| 130 | + -v $PWD/pull-secret:/opt/crc/pull-secret:z \ |
| 131 | + -v $PWD:/data:z \ |
| 132 | + quay.io/crcont/crc-${{inputs.qe-type}}:gh-linux-arm64 \ |
| 133 | + ${cmd} |
| 134 | + podman logs -f crc-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 135 | +
|
| 136 | + - name: Test Report |
| 137 | + working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 138 | + id: test-report |
| 139 | + uses: mikepenz/action-junit-report@v4 |
| 140 | + if: always() |
| 141 | + with: |
| 142 | + fail_on_failure: true |
| 143 | + include_passed: true |
| 144 | + detailed_summary: true |
| 145 | + require_tests: true |
| 146 | + report_paths: '**/*.xml' |
| 147 | + |
| 148 | + - name: Upload e2e results |
| 149 | + working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 150 | + uses: actions/upload-artifact@v4 |
| 151 | + if: always() |
| 152 | + with: |
| 153 | + name: linux-${{inputs.qe-type}}-${{inputs.preset}} |
| 154 | + path: | |
| 155 | + **/*.xml |
| 156 | + **/*.results |
| 157 | + **/*.log |
| 158 | +
|
| 159 | + - name: Update status of the PR check |
| 160 | + if: always() |
| 161 | + run: | |
| 162 | + set -xuo |
| 163 | + # Status msg |
| 164 | + data="{\"state\":\"success\"" |
| 165 | + if [[ ${{steps.test-report.outcome}} != "success" ]]; then |
| 166 | + data="{\"state\":\"failure\"" |
| 167 | + fi |
| 168 | + data="${data},\"description\":\"Finished ${{inputs.qe-type}}-${{inputs.preset}} on Linux\"" |
| 169 | + data="${data},\"context\":\"${{ env.status_context }}\"" |
| 170 | + data="${data},\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" |
| 171 | + # Create status by API call |
| 172 | + curl -L -v -X POST \ |
| 173 | + -H "Accept: application/vnd.github+json" \ |
| 174 | + -H "Authorization: Bearer ${{ github.token }}" \ |
| 175 | + https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \ |
| 176 | + -d "${data}" |
| 177 | +
|
| 178 | + - name: Env clear |
| 179 | + working-directory: ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 180 | + run: | |
| 181 | + podman run --rm -d --privileged --name crc-linux-return-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} \ |
| 182 | + -e TARGET_HOST=$(cat host) \ |
| 183 | + -e TARGET_HOST_USERNAME=$(cat username) \ |
| 184 | + -e TARGET_HOST_KEY_PATH=/data/id_rsa \ |
| 185 | + -e BASTION_HOST_USERNAME=$(cat bastion_username) \ |
| 186 | + -e BASTION_HOST=$(cat bastion_host) \ |
| 187 | + -e TARGET_FOLDER=crc-support \ |
| 188 | + -e TARGET_CLEANUP='false' \ |
| 189 | + -e OUTPUT_FOLDER=/data \ |
| 190 | + -e DEBUG='true' \ |
| 191 | + -e SSH_AUTH_SOCK=$(cat ssh_auth_sock) \ |
| 192 | + -v "$(cat ssh_auth_sock):$(cat ssh_auth_sock)" \ |
| 193 | + -v ${PWD}:/data:z \ |
| 194 | + quay.io/rhqp/crc-support:v0.5.1-linux return2testingfarm |
| 195 | + podman logs -f crc-linux-return-${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 196 | + kill $(cat ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}}/ssh_agent_pid) |
| 197 | + cd .. |
| 198 | + rm -r ${{ env.commit_sha }}-${{inputs.qe-type}}-${{inputs.preset}} |
| 199 | +
|
| 200 | +
|
0 commit comments