Skip to content

Commit 7ad9e7d

Browse files
author
RandomCrocodile
committed
fix(ci): revert test workflow to direct triggers for reliable PR comments
workflow_run doesn't associate with PRs reliably — test results and coverage comments were not posted on PR #79. Reverted to direct push/pull_request triggers with its own build step. Still optimized with: - paths-ignore (skip on docs-only changes) - concurrency (cancel in-progress on new push) - NuGet cache (shared cache key with ci.yml) - Removed build-output artifact from ci.yml (no longer needed)
1 parent 0f4d187 commit 7ad9e7d

2 files changed

Lines changed: 26 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ jobs:
8989
ConfuserEx.zip
9090
Confuser.MSBuild.Tasks/bin/Release/*.nupkg
9191
92-
- name: Upload build output (for test workflow)
93-
uses: actions/upload-artifact@v5
94-
with:
95-
name: build-output
96-
path: '**/bin/Release/'
97-
retention-days: 1
98-
9992
# Pre-release: on push to pre-release branch
10093
pre-release:
10194
needs: build

.github/workflows/test.yml

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
name: test
22

33
on:
4-
workflow_run:
5-
workflows: [ci]
6-
types: [completed]
4+
push:
5+
branches: [master, pre-release, feature/**, fix/**]
6+
paths-ignore: ['**.md', 'docs/**', 'LICENSE*']
7+
pull_request:
8+
branches: [master, pre-release]
9+
paths-ignore: ['**.md', 'docs/**', 'LICENSE*']
710

811
concurrency:
9-
group: test-${{ github.event.workflow_run.head_branch }}
12+
group: test-${{ github.ref }}
1013
cancel-in-progress: true
1114

1215
jobs:
1316
test:
14-
if: github.event.workflow_run.conclusion == 'success'
1517
runs-on: windows-2025
1618
timeout-minutes: 15
1719
permissions:
1820
contents: read
1921
pull-requests: write
20-
actions: read
2122
env:
2223
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
2324
steps:
2425
- uses: actions/checkout@v5
2526
with:
26-
ref: ${{ github.event.workflow_run.head_sha }}
2727
fetch-depth: 0
2828

2929
- name: Setup .NET runtimes for cross-framework tests
@@ -33,12 +33,22 @@ jobs:
3333
6.0.x
3434
8.0.x
3535
36-
- name: Download build output from CI
37-
uses: actions/download-artifact@v5
36+
- name: Setup MSBuild
37+
uses: microsoft/setup-msbuild@v2
38+
39+
- name: Cache NuGet packages
40+
uses: actions/cache@v4
3841
with:
39-
name: build-output
40-
run-id: ${{ github.event.workflow_run.id }}
41-
github-token: ${{ secrets.GITHUB_TOKEN }}
42+
path: ${{ github.workspace }}/.nuget/packages
43+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.vcxproj') }}
44+
restore-keys: |
45+
${{ runner.os }}-nuget-
46+
47+
- name: Restore
48+
run: msbuild Confuser2.sln -t:Restore -verbosity:minimal
49+
50+
- name: Build
51+
run: msbuild Confuser2.sln -p:Configuration=Release -verbosity:minimal
4252

4353
- name: Run tests with coverage
4454
id: tests
@@ -145,8 +155,8 @@ jobs:
145155
Get-Content coverage/report/SummaryGithub.md >> $env:GITHUB_STEP_SUMMARY
146156
}
147157
148-
- name: Build PR comment
149-
if: always() && github.event.workflow_run.event == 'pull_request'
158+
- name: Post PR comment
159+
if: always() && github.event_name == 'pull_request'
150160
shell: pwsh
151161
run: |
152162
$comment = @()
@@ -157,13 +167,12 @@ jobs:
157167
}
158168
$comment -join "`n" | Set-Content -Path 'pr-comment.md' -Encoding utf8
159169
160-
- name: Post PR comment
161-
if: always() && github.event.workflow_run.event == 'pull_request'
170+
- name: Post PR comment (sticky)
171+
if: always() && github.event_name == 'pull_request'
162172
uses: marocchino/sticky-pull-request-comment@v2
163173
with:
164174
header: test-coverage-report
165175
path: pr-comment.md
166-
number: ${{ github.event.workflow_run.pull_requests[0].number }}
167176

168177
- name: Upload test results
169178
if: always()

0 commit comments

Comments
 (0)