Skip to content

Commit c3cd9bb

Browse files
committed
test: isolate release fixtures from workflow changes
1 parent f7dceb8 commit c3cd9bb

2 files changed

Lines changed: 45 additions & 5 deletions

File tree

‎.github/workflows/__test-action-release-create.yml‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,32 @@ jobs:
2626
const tag = `test-release-create-${context.runId}-${context.runAttempt}`;
2727
core.setOutput('tag', tag);
2828
29+
// A release fixture must not introduce workflows relative to a moving main.
30+
// Keep the checked-out action code, but omit workflows from the target tree.
31+
const { data: source } = await github.rest.git.getCommit({
32+
...context.repo,
33+
commit_sha: context.sha,
34+
});
35+
const { data: tree } = await github.rest.git.createTree({
36+
...context.repo,
37+
base_tree: source.tree.sha,
38+
tree: [{ path: '.github/workflows', mode: '040000', type: 'tree', sha: null }],
39+
});
40+
const { data: fixture } = await github.rest.git.createCommit({
41+
...context.repo,
42+
message: `test: release fixture for ${context.runId}/${context.runAttempt}`,
43+
tree: tree.sha,
44+
parents: [context.sha],
45+
});
46+
// No branch is created or moved. Only the disposable release tags reference this commit.
47+
core.setOutput('target-sha', fixture.sha);
48+
2949
- name: Act - Create explicit draft release
3050
id: create-release
3151
uses: $/actions/release/create
3252
with:
3353
tag: ${{ steps.test-release.outputs.tag }}
34-
target-ref: ${{ github.sha }}
54+
target-ref: ${{ steps.test-release.outputs.target-sha }}
3555
config-overrides: |
3656
name-template: Configured release
3757
prerelease: "true"
@@ -44,7 +64,7 @@ jobs:
4464
env:
4565
CREATED_TAG: ${{ steps.test-release.outputs.tag }}
4666
OUTPUT_TAG: ${{ steps.create-release.outputs.tag }}
47-
EXPECTED_RELEASE_SHA: ${{ github.sha }}
67+
EXPECTED_RELEASE_SHA: ${{ steps.test-release.outputs.target-sha }}
4868
with:
4969
github-token: ${{ github.token }}
5070
script: |
@@ -163,7 +183,7 @@ jobs:
163183
env:
164184
RELEASE_ID: ${{ steps.draft-release.outputs.release-id }}
165185
EXPECTED_TAG: ${{ steps.test-release.outputs.tag }}
166-
EXPECTED_SHA: ${{ github.sha }}
186+
EXPECTED_SHA: ${{ steps.test-release.outputs.target-sha }}
167187
with:
168188
script: |
169189
const assert = require('node:assert/strict');

‎.github/workflows/__test-action-release-delete.yml‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,31 @@ jobs:
2626
core.setOutput('draft-tag', `test-release-delete-draft-${context.runId}-${context.runAttempt}`);
2727
core.setOutput('published-tag', `test-release-delete-published-${context.runId}-${context.runAttempt}`);
2828
29+
// A release fixture must not introduce workflows relative to a moving main.
30+
// Keep the checked-out action code, but omit workflows from the target tree.
31+
const { data: source } = await github.rest.git.getCommit({
32+
...context.repo,
33+
commit_sha: context.sha,
34+
});
35+
const { data: tree } = await github.rest.git.createTree({
36+
...context.repo,
37+
base_tree: source.tree.sha,
38+
tree: [{ path: '.github/workflows', mode: '040000', type: 'tree', sha: null }],
39+
});
40+
const { data: fixture } = await github.rest.git.createCommit({
41+
...context.repo,
42+
message: `test: release fixture for ${context.runId}/${context.runAttempt}`,
43+
tree: tree.sha,
44+
parents: [context.sha],
45+
});
46+
// No branch is created or moved. Only the disposable release tags reference this commit.
47+
core.setOutput('target-sha', fixture.sha);
48+
2949
- name: Arrange - Create explicit draft release
3050
uses: $/actions/release/create
3151
with:
3252
tag: ${{ steps.test-releases.outputs.draft-tag }}
33-
target-ref: ${{ github.sha }}
53+
target-ref: ${{ steps.test-releases.outputs.target-sha }}
3454
publish: "false"
3555
github-token: ${{ github.token }}
3656

@@ -102,7 +122,7 @@ jobs:
102122
uses: $/actions/release/create
103123
with:
104124
tag: ${{ steps.test-releases.outputs.published-tag }}
105-
target-ref: ${{ github.sha }}
125+
target-ref: ${{ steps.test-releases.outputs.target-sha }}
106126
publish: "true"
107127
github-token: ${{ github.token }}
108128

0 commit comments

Comments
 (0)