[CFX-5210] Implement plugin update check functionality and state management #220
Workflow file for this run
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: On-Demand Smoke Tests | |
| on: | |
| pull_request: | |
| types: [labeled] | |
| jobs: | |
| check-fork: | |
| if: | | |
| github.event.label.name == 'run-smoke-tests' || | |
| github.event.label.name == 'go' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| outputs: | |
| is_fork: ${{ steps.check.outputs.is_fork }} | |
| steps: | |
| - name: Check if PR is from fork | |
| id: check | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request; | |
| const isFork = pr.head.repo.full_name !== pr.base.repo.full_name; | |
| console.log(`Is fork: ${isFork}`); | |
| core.setOutput('is_fork', isFork.toString()); | |
| return isFork; | |
| - name: Notify fork PR cannot use this workflow | |
| if: steps.check.outputs.is_fork == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: '⚠️ **Smoke tests cannot be triggered on forked PRs using this label.**\n\n' + | |
| 'For security reasons, only maintainers can run smoke tests on forked PRs.\n\n' + | |
| '**If you are a maintainer:** Apply the `approved-for-smoke-tests` label after reviewing the code.\n\n' + | |
| '**If you are an external contributor:** Please comment on this PR requesting a maintainer review, and a maintainer will trigger the tests after security review.\n\n' + | |
| 'See the [workflows documentation](.github/workflows/README.md) for more details.' | |
| }); | |
| // Remove the label since it won't work for forks | |
| try { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| name: 'run-smoke-tests' | |
| }); | |
| } catch (error) { | |
| console.log('Label already removed or does not exist'); | |
| } | |
| notify-start: | |
| needs: check-fork | |
| if: needs.check-fork.outputs.is_fork == 'false' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Notify smoke tests starting | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: '🚀 Smoke tests triggered! Running on Linux and Windows...' | |
| }); | |
| build-windows: | |
| needs: check-fork | |
| if: needs.check-fork.outputs.is_fork == 'false' | |
| uses: ./.github/workflows/.build-windows.yaml | |
| with: | |
| go-version: '1.25.8' | |
| artifact-name: 'dr-windows' | |
| secrets: inherit | |
| linux-smoke-tests: | |
| needs: [check-fork, notify-start] | |
| if: needs.check-fork.outputs.is_fork == 'false' | |
| uses: ./.github/workflows/.smoke-tests-matrix.yaml | |
| with: | |
| go-version: '1.25.8' | |
| secrets: | |
| DR_API_TOKEN: ${{ secrets.DR_API_TOKEN }} | |
| windows-smoke-tests: | |
| needs: [check-fork, build-windows, notify-start] | |
| if: needs.check-fork.outputs.is_fork == 'false' | |
| uses: ./.github/workflows/.windows-smoke-test.yaml | |
| with: | |
| artifact-name: 'dr-windows' | |
| secrets: | |
| DR_API_TOKEN: ${{ secrets.DR_API_TOKEN }} | |
| notify-results: | |
| needs: [check-fork, linux-smoke-tests, windows-smoke-tests] | |
| if: always() && needs.check-fork.outputs.is_fork == 'false' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Comment on PR with results | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const linuxStatus = '${{ needs.linux-smoke-tests.result }}'; | |
| const windowsStatus = '${{ needs.windows-smoke-tests.result }}'; | |
| const linuxEmoji = linuxStatus === 'success' ? '✅' : '❌'; | |
| const windowsEmoji = windowsStatus === 'success' ? '✅' : '❌'; | |
| const allPassed = linuxStatus === 'success' && windowsStatus === 'success'; | |
| const overallEmoji = allPassed ? '✅' : '❌'; | |
| const overallMessage = allPassed ? 'All smoke tests passed!' : 'Some smoke tests failed.'; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `${overallEmoji} **${overallMessage}**\n\n` + | |
| `${linuxEmoji} Linux: ${linuxStatus}\n` + | |
| `${windowsEmoji} Windows: ${windowsStatus}\n\n` + | |
| `[View run details](${context.payload.repository.html_url}/actions/runs/${context.runId})` | |
| }); | |
| - name: Remove run-smoke-tests label | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| // Only remove run-smoke-tests label, keep 'go' label for categorization | |
| try { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| name: 'run-smoke-tests' | |
| }); | |
| console.log('Removed label: run-smoke-tests'); | |
| } catch (error) { | |
| console.log('Label run-smoke-tests already removed or does not exist'); | |
| } |