Tests for kratix/c6612da by ChunyiLyu/web-flow #217
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Kratix | |
| run-name: Tests for kratix/${{github.event.inputs.shortSHA}} by ${{github.event.inputs.author}} | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| shortSHA: | |
| description: 'Short commit sha of Kratix' | |
| required: false | |
| sha: | |
| description: 'Commit sha of Kratix' | |
| required: true | |
| message: | |
| description: 'Commit message' | |
| required: false | |
| author: | |
| description: 'The author(s) of the commit' | |
| required: false | |
| jobs: | |
| set-pending-status: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate GitHub App token | |
| id: generate-token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ secrets.AUTOMATION_APP_ID }} | |
| private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }} | |
| repositories: kratix | |
| - name: Set pending status | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ steps.generate-token.outputs.token }} | |
| script: | | |
| const statusContext = 'ci-tests'; | |
| const runId = process.env.GITHUB_RUN_ID || 'unknown'; | |
| const sha = '${{ github.event.inputs.sha }}' | |
| try { | |
| await github.rest.repos.createCommitStatus({ | |
| owner: 'syntasso', | |
| repo: 'kratix', | |
| sha: sha, | |
| state: 'pending', | |
| target_url: `https://github.com/syntasso/ci/actions/runs/${runId}`, | |
| description: 'CI tests in progress', | |
| context: statusContext | |
| }); | |
| core.info('Successfully set pending status'); | |
| } catch (error) { | |
| core.setFailed(`Failed to set pending status: ${error.message}`); | |
| } | |
| - name: Generate Summary | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const sha = ${{ toJson(github.event.inputs.sha) }} | |
| const message = ${{ toJson(github.event.inputs.message) }} | |
| const author = ${{ toJson(github.event.inputs.author) }} | |
| const rows = [ [sha] ] // always include SHA | |
| const headers = [ { data: 'Commit SHA', header: true } ] | |
| // Add author column only if provided | |
| if (author && author.trim() !== '') { | |
| headers.push({ data: 'Author', header: true }) | |
| rows[0].push(author) | |
| } | |
| // Add message column only if provided | |
| if (message && message.trim() !== '') { | |
| const maxLen = 200 | |
| const shortMessage = | |
| message.length > maxLen ? message.slice(0, maxLen) + '…' : message | |
| headers.push({ data: 'Message', header: true }) | |
| rows[0].push(shortMessage) | |
| } | |
| await core.summary | |
| .addHeading('Run Summary') | |
| .addTable([headers, rows[0]]) | |
| .addLink('View Commit on Github', `https://github.com/syntasso/kratix/commit/${sha}`) | |
| .write() | |
| test-kratix: | |
| needs: [set-pending-status] | |
| uses: | |
| syntasso/ci/.github/workflows/test-kratix.yaml@main | |
| with: | |
| sha: ${{ github.event.inputs.sha }} | |
| release-kratix: | |
| needs: [test-kratix] | |
| uses: | |
| syntasso/ci/.github/workflows/release-kratix.yaml@main | |
| with: | |
| sha: ${{ github.event.inputs.sha }} | |
| secrets: inherit | |
| test-ske: | |
| needs: [ set-pending-status ] | |
| uses: | |
| syntasso/ci/.github/workflows/test-ske.yaml@main | |
| with: | |
| sha: ${{ github.event.inputs.sha }} | |
| secrets: inherit | |
| update-read-only-kratix: | |
| runs-on: ubuntu-latest | |
| needs: [ test-kratix, test-ske ] | |
| if: "${{ github.event.inputs.sha != '' }}" | |
| steps: | |
| - name: Check out enterprise kratix | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: syntasso/enterprise-kratix | |
| submodules: recursive | |
| ssh-key: ${{ secrets.ENTERPRISE_KRATIX_DEPLOY_KEY_READ_PUSH }} | |
| - name: update-read-only-kratix | |
| env: | |
| KRATIX_COMMIT_SHA: ${{ github.event.inputs.sha }} | |
| run: | | |
| git config user.name "syntassodev" | |
| git config user.email "kratix@syntasso.io" | |
| pushd read-only-kratix | |
| git checkout "${KRATIX_COMMIT_SHA}" | |
| popd | |
| if [ -z "$(git status --porcelain)" ]; then | |
| echo "no changes to commit; exiting" | |
| exit 0 | |
| fi | |
| git add read-only-kratix | |
| git commit -m "from test-ske workflow: pushing read-only-kratix at ${KRATIX_COMMIT_SHA} [skip ci]" | |
| git push origin main | |
| final-status-check: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - set-pending-status | |
| - test-kratix | |
| - release-kratix | |
| - test-ske | |
| - update-read-only-kratix | |
| if: always() | |
| steps: | |
| - name: Generate GitHub App token | |
| id: generate-token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ secrets.AUTOMATION_APP_ID }} | |
| private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }} | |
| repositories: kratix | |
| - name: Update Kratix commit status | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ steps.generate-token.outputs.token }} | |
| script: | | |
| const statusContext = 'ci-tests'; | |
| const runId = process.env.GITHUB_RUN_ID || 'unknown'; | |
| const sha = '${{ github.event.inputs.sha }}' | |
| // Collect job results from workflow context | |
| const jobResults = [ | |
| '${{ needs.test-kratix.result }}', | |
| '${{ needs.release-kratix.result }}', | |
| '${{ needs.test-ske.result }}', | |
| ]; | |
| const hasFailed = jobResults.some(result => | |
| result === 'failure' || | |
| result === 'timed_out' || | |
| result === 'cancelled' | |
| ); | |
| const state = hasFailed ? 'failure' : 'success'; | |
| const description = hasFailed ? 'CI workflow failed' : 'CI workflow passed'; | |
| try { | |
| await github.rest.repos.createCommitStatus({ | |
| owner: 'syntasso', | |
| repo: 'kratix', | |
| sha: sha, | |
| state: state, | |
| target_url: `https://github.com/syntasso/ci/actions/runs/${runId}`, | |
| description: description, | |
| context: statusContext | |
| }); | |
| core.info(`Successfully set final status to ${state}`); | |
| } catch (error) { | |
| core.setFailed(`Failed to set final status: ${error.message}`); | |
| } |