Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 18 additions & 65 deletions .github/workflows/pr-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,79 +198,58 @@ jobs:
packages: write
id-token: write

uploadPublishedExportsArtifact:
name: Upload published-exports artifact
upload_context:
name: Upload Context Artifact
needs:
- parse
- prepare
- export
if: always() && needs.prepare.outputs.overlay-branch != '' && needs.prepare.outputs.pr-number != ''

concurrency:
group: uploadPublishedExportsArtifact-${{ github.ref_name }}-${{ github.event.issue.number }}
group: upload_context-${{ github.ref_name }}-${{ github.event.issue.number }}
cancel-in-progress: false

if: needs.parse.outputs.command_name == 'publish' && needs.prepare.outputs.overlay-branch != '' && needs.prepare.outputs.workspace != '' && needs.export.outputs.published-exports != ''
runs-on: ubuntu-latest
steps:
- name: Write and stage meta.json
- name: Write meta.json
env:
WORKSPACE: ${{ needs.prepare.outputs.workspace }}
OVERLAY_BRANCH: ${{ needs.prepare.outputs.overlay-branch }}
OVERLAY_REPO: ${{ needs.prepare.outputs.overlay-repo }}
OVERLAY_COMMIT: ${{ needs.prepare.outputs.overlay-commit }}
PR_NUMBER: ${{ needs.prepare.outputs.pr-number }}
run: |
mkdir -p published-exports
cat > published-exports/meta.json <<EOF
mkdir -p context
cat > context/meta.json <<EOF
{"workspace":"${WORKSPACE}","overlayBranch":"${OVERLAY_BRANCH}","overlayRepo":"${OVERLAY_REPO}","overlayCommit":"${OVERLAY_COMMIT}","pr":${PR_NUMBER}}
EOF

- name: Stage published exports content
if: needs.parse.outputs.command_name == 'publish' && needs.prepare.outputs.workspace != '' && needs.export.outputs.published-exports != ''
env:
PUBLISHED_EXPORTS: ${{ needs.export.outputs.published-exports }}
run: |
mkdir -p published-exports
cp context/meta.json published-exports/
printf "%s\n" "$PUBLISHED_EXPORTS" > published-exports/published-exports.txt
- name: Upload published-exports artifact
uses: actions/upload-artifact@v4
with:
name: published-exports
path: published-exports/
if-no-files-found: error
retention-days: 7

- name: Upload context artifact
uses: actions/upload-artifact@v4
with:
name: context-${{ github.run_id }}
path: published-exports/meta.json
path: context/meta.json
if-no-files-found: error
retention-days: 1

create_test_context:
name: Create Test Context
needs:
- parse
- prepare
if: needs.parse.outputs.command_name == 'test' && needs.prepare.outputs.pr-number != ''
runs-on: ubuntu-latest
steps:
- name: Write meta.json for test context
env:
WORKSPACE: ${{ needs.prepare.outputs.workspace }}
OVERLAY_BRANCH: ${{ needs.prepare.outputs.overlay-branch }}
OVERLAY_REPO: ${{ needs.prepare.outputs.overlay-repo }}
OVERLAY_COMMIT: ${{ needs.prepare.outputs.overlay-commit }}
PR_NUMBER: ${{ needs.prepare.outputs.pr-number }}
run: |
mkdir -p context
cat > context/meta.json <<EOF
{"workspace":"${WORKSPACE}","overlayBranch":"${OVERLAY_BRANCH}","overlayRepo":"${OVERLAY_REPO}","overlayCommit":"${OVERLAY_COMMIT}","pr":${PR_NUMBER}}
EOF
- name: Upload test-context artifact
- name: Upload published-exports artifact
if: needs.parse.outputs.command_name == 'publish' && needs.prepare.outputs.workspace != '' && needs.export.outputs.published-exports != ''
uses: actions/upload-artifact@v4
with:
name: context-${{ github.run_id }}
path: context/meta.json
name: published-exports-pr-${{ needs.prepare.outputs.pr-number }}
path: published-exports/
if-no-files-found: error
retention-days: 1
retention-days: 7

checkBackstageCompatibility:
name: Check workspace backstage compatibility
Expand Down Expand Up @@ -430,32 +409,6 @@ jobs:
body: body
})

upload_no_workspace_context:
needs:
- parse
- prepare
if: always() && needs.prepare.outputs.overlay-branch != '' && needs.prepare.outputs.workspace == ''
runs-on: ubuntu-latest
steps:
- name: Write and upload context artifact
env:
OVERLAY_BRANCH: ${{ needs.prepare.outputs.overlay-branch }}
OVERLAY_REPO: ${{ needs.prepare.outputs.overlay-repo }}
OVERLAY_COMMIT: ${{ needs.prepare.outputs.overlay-commit }}
PR_NUMBER: ${{ needs.prepare.outputs.pr-number }}
run: |
mkdir -p context
cat > context/meta.json <<EOF
{"workspace":"","overlayBranch":"${OVERLAY_BRANCH}","overlayRepo":"${OVERLAY_REPO}","overlayCommit":"${OVERLAY_COMMIT}","pr":${PR_NUMBER}}
EOF
- name: Upload context artifact
uses: actions/upload-artifact@v4
with:
name: context-${{ github.run_id }}
path: context/meta.json
if-no-files-found: error
retention-days: 1

checkPRUpToDate:
name: Checks whether the PR is up-to-date with versions.json
needs:
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/workspace-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ jobs:
path: ./context
if_no_artifact_found: fail

- name: Check workspace from context
- name: Check context for workspace and PR
id: context
run: |
workspace=$(jq -r .workspace ./context/meta.json)
workspace=$(jq -r '.workspace // ""' ./context/meta.json)
pr=$(jq -r '.pr // ""' ./context/meta.json)
echo "workspace=$workspace" >> $GITHUB_OUTPUT
echo "pr=$pr" >> $GITHUB_OUTPUT
if [ -z "$workspace" ]; then
echo "No workspace in context - skipping tests"
fi

# note: the 'pr:' filter is intentionally omitted as it is unreliable for comment-triggered
# workflows on forks. PR is verified manually in the next step.
- name: Download latest published-exports artifact
if: steps.context.outputs.workspace != ''
- name: Download published-exports artifact for this PR
if: steps.context.outputs.workspace != '' && steps.context.outputs.pr != ''
uses: dawidd6/action-download-artifact@v6
with:
name: published-exports
name: published-exports-pr-${{ steps.context.outputs.pr }}
workflow: pr-actions.yaml
workflow_conclusion: success
workflow_search: true
Expand All @@ -57,14 +57,8 @@ jobs:
- name: Verify published-exports artifact belongs to triggering PR
if: steps.context.outputs.workspace != ''
run: |
triggering_pr=$(jq -r .pr ./context/meta.json)
artifact_pr=$(jq -r .pr ./meta.json)
if [[ "$triggering_pr" != "$artifact_pr" ]]; then
echo "::error::Mismatch: published-exports artifact does not belong to triggering PR"
echo "Triggering PR: $triggering_pr"
echo "Published-exports artifact PR: $artifact_pr"
exit 1
fi
echo "Triggering PR: $(jq -r .pr ./context/meta.json)"
echo "Artifact PR: $(jq -r .pr ./meta.json)"

- name: Read artifact metadata
id: meta
Expand Down