|
| 1 | +--- |
| 2 | +name: FDO container test |
| 3 | + |
| 4 | +on: |
| 5 | + issue_comment: |
| 6 | + types: |
| 7 | + - created |
| 8 | + |
| 9 | +jobs: |
| 10 | + pr-info: |
| 11 | + if: ${{ github.event.issue.pull_request && |
| 12 | + (startsWith(github.event.comment.body, '/test-all') || |
| 13 | + startsWith(github.event.comment.body, '/test-container')) }} |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Query author repository permissions |
| 17 | + uses: octokit/request-action@v2.x |
| 18 | + id: user_permission |
| 19 | + with: |
| 20 | + route: GET /repos/${{ github.repository }}/collaborators/${{ github.event.sender.login }}/permission |
| 21 | + env: |
| 22 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + |
| 24 | + # restrict running of tests to users with admin or write permission for the repository |
| 25 | + # see https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-permissions-for-a-user |
| 26 | + - name: Check if user does have correct permissions |
| 27 | + if: contains('admin write', fromJson(steps.user_permission.outputs.data).permission) |
| 28 | + id: check_user_perm |
| 29 | + run: | |
| 30 | + echo "User '${{ github.event.sender.login }}' has permission '${{ fromJson(steps.user_permission.outputs.data).permission }}' allowed values: 'admin', 'write'" |
| 31 | + echo "allowed_user=true" >> $GITHUB_OUTPUT |
| 32 | + - name: Get information for pull request |
| 33 | + uses: octokit/request-action@v2.x |
| 34 | + id: pr-api |
| 35 | + with: |
| 36 | + route: GET /repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} |
| 37 | + env: |
| 38 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + outputs: |
| 41 | + allowed_user: ${{ steps.check_user_perm.outputs.allowed_user }} |
| 42 | + sha: ${{ fromJson(steps.pr-api.outputs.data).head.sha }} |
| 43 | + |
| 44 | + pre-fido-container: |
| 45 | + needs: pr-info |
| 46 | + if: ${{ needs.pr-info.outputs.allowed_user == 'true' }} && |
| 47 | + (startsWith(github.event.comment.body, '/test-all') || |
| 48 | + startsWith(github.event.comment.body, '/test-container'))}} |
| 49 | + runs-on: ubuntu-latest |
| 50 | + env: |
| 51 | + STATUS_NAME: fido-container-test |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Get Current Job Log URL |
| 55 | + id: job-log-url |
| 56 | + run: | |
| 57 | + JOB_HTML_URL=$(curl --get -Ss -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/fedora-iot/fido-device-onboard-rs/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=30" | jq -r --arg job_name "pre-fido-container" '.jobs | map(select(.name == "pre-fido-container")) | .[0].html_url') |
| 58 | + echo "html_url=$JOB_HTML_URL" >> $GITHUB_OUTPUT |
| 59 | + env: |
| 60 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + |
| 62 | + - name: Create in-progress status |
| 63 | + uses: octokit/request-action@v2.x |
| 64 | + with: |
| 65 | + route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' |
| 66 | + context: ${{ env.STATUS_NAME }} |
| 67 | + state: pending |
| 68 | + description: 'CentOS Stream 9 - Runner has been deploying...' |
| 69 | + target_url: ${{ steps.job-log-url.outputs.html_url }} |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + |
| 73 | + fido-container: |
| 74 | + needs: [pr-info, pre-fido-container] |
| 75 | + if: ${{ needs.pr-info.outputs.allowed_user == 'true' }} && |
| 76 | + (startsWith(github.event.comment.body, '/test-all') || |
| 77 | + startsWith(github.event.comment.body, '/test-container'))}} |
| 78 | + runs-on: [kite, x86_64, gcp, centos-stream-9, medium] |
| 79 | + env: |
| 80 | + STATUS_NAME: fido-container-test |
| 81 | + |
| 82 | + steps: |
| 83 | + - name: Get Current Job Log URL |
| 84 | + id: job-log-url |
| 85 | + run: | |
| 86 | + JOB_HTML_URL=$(curl --get -Ss -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/fedora-iot/fido-device-onboard-rs/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=30" | jq -r --arg job_name "fido-container" '.jobs | map(select(.name == "fido-container")) | .[0].html_url') |
| 87 | + echo "html_url=$JOB_HTML_URL" >> $GITHUB_OUTPUT |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + |
| 91 | + - name: Create in-progress status |
| 92 | + uses: octokit/request-action@v2.x |
| 93 | + with: |
| 94 | + route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' |
| 95 | + context: ${{ env.STATUS_NAME }} |
| 96 | + state: pending |
| 97 | + description: 'CentOS Stream 9 - Test has been running...' |
| 98 | + target_url: ${{ steps.job-log-url.outputs.html_url }} |
| 99 | + env: |
| 100 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 101 | + |
| 102 | + - name: Install required packages |
| 103 | + run: sudo dnf install -y make gcc openssl openssl-devel findutils golang git tpm2-tss-devel swtpm swtpm-tools git clevis clevis-luks cryptsetup cryptsetup-devel clang-devel cracklib-dicts rust-toolset rpmdevtools python3-docutils createrepo_c podman buildah skopeo |
| 104 | + |
| 105 | + - name: Clone repository |
| 106 | + uses: actions/checkout@v3 |
| 107 | + with: |
| 108 | + ref: ${{ needs.pr-info.outputs.sha }} |
| 109 | + fetch-depth: 0 |
| 110 | + |
| 111 | + - name: Build fido containers |
| 112 | + uses: ./.github/actions/build_containers |
| 113 | + |
| 114 | + - name: Build fido PRM pakcages |
| 115 | + run: make rpm |
| 116 | + |
| 117 | + - name: Prepare |
| 118 | + run: | |
| 119 | + sudo mkdir -p /var/www/html/source |
| 120 | + sudo cp ./rpmbuild/RPMS/x86_64/* /var/www/html/source/ 2>/dev/null || : |
| 121 | + sudo createrepo_c /var/www/html/source |
| 122 | + sudo ls -al /var/www/html/source |
| 123 | +
|
| 124 | + - name: Run fdo-container.sh test |
| 125 | + run: ./fdo-container.sh |
| 126 | + working-directory: tests |
| 127 | + timeout-minutes: 100 |
| 128 | + |
| 129 | + - name: Set non cancelled result status |
| 130 | + if: ${{ !cancelled() }} |
| 131 | + uses: octokit/request-action@v2.x |
| 132 | + with: |
| 133 | + route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' |
| 134 | + context: ${{ env.STATUS_NAME }} |
| 135 | + state: ${{ job.status }} |
| 136 | + description: 'CentOS Stream 9 - Test got ${{ job.status }}' |
| 137 | + target_url: ${{ steps.job-log-url.outputs.html_url }} |
| 138 | + env: |
| 139 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 140 | + |
| 141 | + - name: Set cancelled result status |
| 142 | + if: ${{ cancelled() }} |
| 143 | + uses: octokit/request-action@v2.x |
| 144 | + with: |
| 145 | + route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' |
| 146 | + context: ${{ env.STATUS_NAME }} |
| 147 | + state: ${{ job.status }} |
| 148 | + description: 'CentOS Stream 9 - Test got error' |
| 149 | + target_url: ${{ steps.job-log-url.outputs.html_url }} |
| 150 | + env: |
| 151 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 152 | + |
| 153 | + - uses: actions/upload-artifact@v3 |
| 154 | + if: ${{ always() }} |
| 155 | + with: |
| 156 | + name: fido-container |
| 157 | + path: | |
| 158 | + *.json |
| 159 | + *.log |
0 commit comments