diff --git a/.github/actions/download-pr-data-artifact/action.yaml b/.github/actions/download-pr-data-artifact/action.yaml deleted file mode 100644 index 989f0b2fa8..0000000000 --- a/.github/actions/download-pr-data-artifact/action.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# yaml-language-server: $schema=https://www.schemastore.org/github-action.json ---- -name: Download PR number saved as an artifact -description: | - This action can be used together with save-pr-as-artifact custom action which uploads the PR number as an artifact. - This action downloads the artifact to retrieve the PR number. -outputs: - "pr_number": - value: ${{ steps.set-pr-number.outputs.pr_number }} - description: The PR number downloaded from the artifact -runs: - using: composite - steps: - - name: Download artifact - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "pr_number" - })[0]; - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data)); - - - name: Unzip artifact - shell: bash - run: unzip pr_number.zip - - - name: Set PR number - id: set-pr-number - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - let fs = require('fs'); - PR_NUMBER=fs.readFileSync('./pr_number').toString(); - console.log(`Setting output: pr_number=${PR_NUMBER}`); - core.setOutput('pr_number', PR_NUMBER); diff --git a/.github/workflows/functional-test-cloud.yaml b/.github/workflows/functional-test-cloud.yaml index 5ff5ef4e32..a9947b04a6 100644 --- a/.github/workflows/functional-test-cloud.yaml +++ b/.github/workflows/functional-test-cloud.yaml @@ -36,10 +36,11 @@ on: # src_image: Source image in ACR (e.g. radiusdeploymentengine.azurecr.io/deployment-engine) # dest_image: Destination image in GHCR (e.g. ghcr.io/radius-project/deployment-engine) # tag: Tag for the image (e.g. latest, 0.1, 0.1.0-rc1, pr-123) - workflow_run: - workflows: [Approve Functional Tests] - types: - - completed + pull_request: + branches: + - main + - features/* + - release/* permissions: {} @@ -91,7 +92,7 @@ jobs: timeout-minutes: 5 if: github.event_name == 'repository_dispatch' || (github.event_name == 'schedule' && github.repository == 'radius-project/radius') || - (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || + github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' permissions: contents: read # Required for listing the commits @@ -99,8 +100,6 @@ jobs: env: DE_IMAGE: ghcr.io/radius-project/deployment-engine DE_TAG: latest - # Head branch, only populated for workflow_run dispatch. - HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} outputs: REL_VERSION: ${{ steps.gen-id.outputs.REL_VERSION }} UNIQUE_ID: ${{ steps.gen-id.outputs.UNIQUE_ID }} @@ -115,27 +114,6 @@ jobs: - name: Log Event Information run: | echo "Event Name: ${{ github.event_name }}" - - # Additional logging is temporary for debugging purposes - # https://github.com/radius-project/radius/issues/7782 - if [[ "${{ github.event_name }}" == "workflow_run" ]]; then - echo "Triggered by workflow_run." - echo "Ref: ${{ github.ref }}" - echo "Head Branch Name: $HEAD_BRANCH" - echo "SHA Value: ${{ github.event.workflow_run.head_sha }}" - echo "Github Repository: ${{ github.repository }}" - echo "Event Repository ID: ${{ github.event.workflow_run.repository.id }}" - echo "Event Repository Name: ${{ github.event.workflow_run.repository.name }}" - echo "Event Repository Full Name: ${{ github.event.workflow_run.repository.full_name }}" - echo "Workflow ID: ${{ github.event.workflow_run.workflow_id }}" - echo "Workflow Run ID: ${{ github.event.workflow_run.id }}" - echo "Workflow Name: ${{ github.event.workflow_run.name }}" - echo "Run Number: ${{ github.event.workflow_run.run_number }}" - echo "Conclusion: ${{ github.event.workflow_run.conclusion }}" - echo "Status: ${{ github.event.workflow_run.status }}" - echo "Created At: ${{ github.event.workflow_run.created_at }}" - echo "Updated At: ${{ github.event.workflow_run.updated_at }}" - fi - name: Set up checkout target (scheduled) if: github.event_name == 'schedule' run: | @@ -152,8 +130,8 @@ jobs: if: github.event_name == 'pull_request' run: | { - echo "CHECKOUT_REPO=${{ github.repository }}" - echo "CHECKOUT_REF=${{ github.ref }}" + echo "CHECKOUT_REPO=${{ github.event.pull_request.head.repo.full_name }}" + echo "CHECKOUT_REF=${{ github.event.pull_request.head.sha }}" echo "PR_NUMBER=${{ github.event.pull_request.number }}" echo "BASE_SHA=${{ github.event.pull_request.base.sha }}" } >> "${GITHUB_ENV}" @@ -172,75 +150,6 @@ jobs: submodules: recursive persist-credentials: false - - name: Download PR data artifacts - if: github.event_name == 'workflow_run' - uses: ./.github/actions/download-pr-data-artifact - id: get-pr-number - - - name: Set PR context (workflow_run) - if: github.event_name == 'workflow_run' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - env: - PR_NUMBER: ${{ steps.get-pr-number.outputs.pr_number }} - with: - github-token: ${{ github.token }} - script: | - const payload = context.payload.workflow_run; - const fs = require('fs'); - // Use env var to avoid syntax errors from newlines in the output - const prNumber = (process.env.PR_NUMBER || '').trim(); - - let baseSha = ''; - let checkoutRepo = payload.head_repository.full_name; - let checkoutRef = payload.head_sha; - - // For fork PRs, payload.pull_requests is empty due to GitHub security restrictions. - // We need to fetch the PR details using the API to get the base SHA for change detection. - if (prNumber) { - try { - const { data: pr } = await github.rest.pulls.get({ - ...context.repo, - pull_number: parseInt(prNumber, 10) - }); - - baseSha = pr.base?.sha || baseSha; - - // Use PR head info which works for both fork and non-fork PRs - if (pr.head && pr.head.repo) { - checkoutRepo = pr.head.repo.full_name; - checkoutRef = pr.head.sha; - } else { - console.log(`PR #${prNumber} head repo missing; falling back to workflow_run payload data.`); - } - - console.log(`Fetched PR #${prNumber}: base_sha=${baseSha}, head_repo=${checkoutRepo}, head_sha=${checkoutRef}`); - } catch (error) { - console.log(`Warning: Could not fetch PR #${prNumber}: ${error.message}`); - // Fall back to workflow_run payload data - if (payload.pull_requests && payload.pull_requests.length > 0) { - baseSha = payload.pull_requests[0].base.sha; - } - } - } else if (payload.pull_requests && payload.pull_requests.length > 0) { - // Fallback for cases where PR number artifact is not available - baseSha = payload.pull_requests[0].base.sha; - } - - if (!baseSha) { - console.log( - `Warning: BASE_SHA is empty for workflow_run (PR: ${prNumber || 'n/a'}). Change detection may be skipped.` - ); - } - - // Set environment variables - fs.appendFileSync( - process.env.GITHUB_ENV, - `CHECKOUT_REPO=${checkoutRepo}\n` + - `CHECKOUT_REF=${checkoutRef}\n` + - `PR_NUMBER=${prNumber}\n` + - `BASE_SHA=${baseSha}\n` - ); - - name: Set DE image and tag (repository_dispatch from deployment-engine.run-functional-tests) if: github.event_name == 'repository_dispatch' shell: bash @@ -570,7 +479,7 @@ jobs: needs: [setup, build] if: github.event_name == 'repository_dispatch' || (github.event_name == 'schedule' && github.repository == 'radius-project/radius') || - (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || + github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' strategy: fail-fast: true @@ -582,6 +491,7 @@ jobs: permissions: id-token: write # Required for requesting the JWT contents: read # Required for listing the commits + checks: write # Required for publishing test results env: UNIQUE_ID: ${{ needs.setup.outputs.UNIQUE_ID }} REL_VERSION: ${{ needs.setup.outputs.REL_VERSION }} diff --git a/.github/workflows/functional-tests-approval.yaml b/.github/workflows/functional-tests-approval.yaml deleted file mode 100644 index ece44a8d21..0000000000 --- a/.github/workflows/functional-tests-approval.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json ---- -name: Approve Functional Tests - -on: - pull_request: - branches: - - main - - features/* - - release/* - -permissions: {} - -jobs: - approve-functional-tests-run: - name: Approve Functional Tests - runs-on: ubuntu-24.04 - timeout-minutes: 5 - environment: functional-tests - permissions: - contents: read - steps: - - name: Checkout Radius repository - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - with: - persist-credentials: false - - - name: Get PR number - run: | - mkdir -p ./pr - echo "${PR_NUMBER}" > ./pr/pr_number - env: - PR_NUMBER: ${{ github.event.number }} - - - name: Save PR number - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 - with: - name: pr_number - path: pr/