Skip to content

Commit 3c2bee3

Browse files
committed
Refactor action for maintainability
1 parent 3a204d0 commit 3c2bee3

33 files changed

Lines changed: 3502 additions & 1959 deletions

.github/workflows/ci.yaml

Lines changed: 67 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -2,204 +2,101 @@ name: ci
22

33
on:
44
workflow_dispatch:
5+
pull_request:
56
push:
67
branches:
78
- master
8-
schedule:
9-
- cron: "23 18 * * 0"
9+
tags:
10+
- "v*.*.*"
1011

1112
permissions:
1213
contents: read
1314

1415
jobs:
15-
e2e:
16+
test:
17+
name: build and e2e
1618
runs-on: windows-2025-vs2026
1719
timeout-minutes: 90
1820

1921
steps:
2022
- name: checkout
21-
uses: actions/checkout@v5
23+
uses: actions/checkout@v4
2224

23-
- name: build action bundle
25+
- name: setup node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 24
29+
cache: npm
30+
31+
- name: install dependencies
2432
shell: powershell
25-
run: |
26-
npm.cmd ci
27-
npm.cmd run build
28-
git diff --exit-code -- dist/index.js
33+
run: npm.cmd ci
34+
35+
- name: build bundle
36+
shell: powershell
37+
run: npm.cmd run build
38+
39+
- name: verify checked-in bundle
40+
shell: powershell
41+
run: git diff --exit-code -- dist/index.js
2942

3043
- name: setup wdk7
31-
id: wdk7
3244
uses: ./
3345

34-
- name: verify default setup
46+
- name: run e2e
3547
shell: powershell
36-
run: |
37-
if ("${{ steps.wdk7.outputs.found }}" -ne "true") {
38-
throw "WDK7 was not prepared."
39-
}
40-
41-
"root=${{ steps.wdk7.outputs.root }}"
42-
"source=${{ steps.wdk7.outputs.source }}"
43-
"cache-hit=${{ steps.wdk7.outputs.cache-hit }}"
44-
"dbgeng-found=${{ steps.wdk7.outputs.dbgeng-found }}"
45-
"toolchain-file=${{ steps.wdk7.outputs.toolchain-file }}"
46-
"ddkbuild-cmd=${{ steps.wdk7.outputs.ddkbuild-cmd }}"
47-
48-
if ("${{ steps.wdk7.outputs.dbgeng-found }}" -ne "false") {
49-
throw "DbgEng SDK should not be prepared unless debugger=true."
50-
}
51-
52-
- name: build cmake user e2e targets without debugger
53-
shell: powershell
54-
env:
55-
CMAKE_GENERATOR: ${{ steps.wdk7.outputs.cmake-generator }}
56-
WDK7_TOOLCHAIN_FILE: ${{ steps.wdk7.outputs.toolchain-file }}
57-
run: |
58-
$source = Join-Path $PWD "test\e2e\cmake"
59-
$expected = @(
60-
"e2e_cli.exe",
61-
"e2e_dll.dll",
62-
"e2e_lib.lib",
63-
"e2e_native.exe"
64-
)
65-
66-
foreach ($arch in @("i386", "amd64")) {
67-
$build = Join-Path $PWD ".e2e\cmake-basic-$arch"
68-
69-
cmake -S $source -B $build -G $env:CMAKE_GENERATOR `
70-
"-DCMAKE_TOOLCHAIN_FILE=$env:WDK7_TOOLCHAIN_FILE" `
71-
"-DWDK7_ARCH=$arch" `
72-
"-DCMAKE_BUILD_TYPE=Release"
73-
if ($LASTEXITCODE -ne 0) {
74-
exit $LASTEXITCODE
75-
}
76-
77-
cmake --build $build --config Release
78-
if ($LASTEXITCODE -ne 0) {
79-
exit $LASTEXITCODE
80-
}
81-
82-
foreach ($file in $expected) {
83-
$path = Join-Path $build $file
84-
if (-not (Test-Path -LiteralPath $path)) {
85-
throw "Missing CMake $arch output: $path"
86-
}
87-
}
88-
89-
$dbgengPath = Join-Path $build "e2e_dbgeng.exe"
90-
if (Test-Path -LiteralPath $dbgengPath) {
91-
throw "DbgEng target was built without debugger=true: $dbgengPath"
92-
}
93-
}
48+
run: .\scripts\test-e2e.ps1 -Mode default
9449

9550
- name: setup wdk7 with debugger
96-
id: wdk7_debugger
9751
uses: ./
9852
with:
9953
debugger: true
10054

101-
- name: verify debugger setup
102-
shell: powershell
103-
run: |
104-
if ("${{ steps.wdk7_debugger.outputs.found }}" -ne "true") {
105-
throw "WDK7 was not prepared."
106-
}
107-
if ("${{ steps.wdk7_debugger.outputs.dbgeng-found }}" -ne "true") {
108-
throw "DbgEng SDK was not prepared with debugger=true."
109-
}
110-
111-
"debuggers-root=${{ steps.wdk7_debugger.outputs.debuggers-root }}"
112-
"dbgeng-include-dir=${{ steps.wdk7_debugger.outputs.dbgeng-include-dir }}"
113-
"dbgeng-lib-i386=${{ steps.wdk7_debugger.outputs.dbgeng-lib-i386 }}"
114-
"dbgeng-lib-amd64=${{ steps.wdk7_debugger.outputs.dbgeng-lib-amd64 }}"
115-
116-
- name: build cmake user e2e targets with debugger
117-
shell: powershell
118-
env:
119-
CMAKE_GENERATOR: ${{ steps.wdk7_debugger.outputs.cmake-generator }}
120-
WDK7_TOOLCHAIN_FILE: ${{ steps.wdk7_debugger.outputs.toolchain-file }}
121-
run: |
122-
$source = Join-Path $PWD "test\e2e\cmake"
123-
$expected = @(
124-
"e2e_cli.exe",
125-
"e2e_dll.dll",
126-
"e2e_lib.lib",
127-
"e2e_dbgeng.exe",
128-
"e2e_native.exe"
129-
)
130-
131-
foreach ($arch in @("i386", "amd64")) {
132-
$build = Join-Path $PWD ".e2e\cmake-dbgeng-$arch"
133-
134-
cmake -S $source -B $build -G $env:CMAKE_GENERATOR `
135-
"-DCMAKE_TOOLCHAIN_FILE=$env:WDK7_TOOLCHAIN_FILE" `
136-
"-DWDK7_ARCH=$arch" `
137-
"-DCMAKE_BUILD_TYPE=Release"
138-
if ($LASTEXITCODE -ne 0) {
139-
exit $LASTEXITCODE
140-
}
141-
142-
cmake --build $build --config Release
143-
if ($LASTEXITCODE -ne 0) {
144-
exit $LASTEXITCODE
145-
}
146-
147-
foreach ($file in $expected) {
148-
$path = Join-Path $build $file
149-
if (-not (Test-Path -LiteralPath $path)) {
150-
throw "Missing CMake $arch output: $path"
151-
}
152-
}
153-
}
154-
155-
- name: build cmake sys e2e target
55+
- name: run debugger e2e
15656
shell: powershell
57+
run: .\scripts\test-e2e.ps1 -Mode debugger
58+
59+
release:
60+
name: release
61+
needs: test
62+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
63+
runs-on: ubuntu-latest
64+
permissions:
65+
contents: write
66+
67+
steps:
68+
- name: checkout
69+
uses: actions/checkout@v4
70+
with:
71+
fetch-depth: 0
72+
73+
- name: create release
15774
env:
158-
CMAKE_GENERATOR: ${{ steps.wdk7.outputs.cmake-generator }}
159-
WDK7_TOOLCHAIN_FILE: ${{ steps.wdk7.outputs.toolchain-file }}
75+
GH_TOKEN: ${{ github.token }}
76+
TAG_NAME: ${{ github.ref_name }}
16077
run: |
161-
$source = Join-Path $PWD "test\e2e\cmake-sys"
162-
163-
foreach ($arch in @("i386", "amd64")) {
164-
$build = Join-Path $PWD ".e2e\cmake-sys-$arch"
165-
166-
cmake -S $source -B $build -G $env:CMAKE_GENERATOR `
167-
"-DCMAKE_TOOLCHAIN_FILE=$env:WDK7_TOOLCHAIN_FILE" `
168-
"-DWDK7_ARCH=$arch" `
169-
"-DWDK7_DEFAULT_MODE=KERNEL" `
170-
"-DCMAKE_BUILD_TYPE=Release"
171-
if ($LASTEXITCODE -ne 0) {
172-
exit $LASTEXITCODE
173-
}
174-
175-
cmake --build $build --config Release
176-
if ($LASTEXITCODE -ne 0) {
177-
exit $LASTEXITCODE
178-
}
179-
180-
$path = Join-Path $build "e2e_sys.sys"
181-
if (-not (Test-Path -LiteralPath $path)) {
182-
throw "Missing CMake $arch sys output: $path"
183-
}
184-
}
185-
186-
- name: build ddkbuild e2e target
187-
shell: powershell
78+
if ! [[ "$TAG_NAME" =~ ^v([0-9]+)\.[0-9]+\.[0-9]+$ ]]; then
79+
echo "Skipping release for non-semver tag: $TAG_NAME"
80+
exit 0
81+
fi
82+
83+
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
84+
echo "Release $TAG_NAME already exists."
85+
else
86+
gh release create "$TAG_NAME" --verify-tag --generate-notes --title "$TAG_NAME"
87+
fi
88+
89+
- name: update major tag
18890
env:
189-
DDKBUILD_CMD: ${{ steps.wdk7.outputs.ddkbuild-cmd }}
91+
TAG_NAME: ${{ github.ref_name }}
19092
run: |
191-
$source = "test\e2e\ddkbuild\sys"
192-
193-
foreach ($target in @("-WIN7", "-WIN7A64")) {
194-
cmd /s /c "call ""$env:DDKBUILD_CMD"" $target free $source"
195-
if ($LASTEXITCODE -ne 0) {
196-
exit $LASTEXITCODE
197-
}
198-
}
199-
200-
$sysFiles = @(Get-ChildItem -Path $source -Recurse -Filter e2e_ddkbuild.sys)
201-
if ($sysFiles.Count -lt 2) {
202-
throw "Expected ddkbuild to produce x86 and amd64 .sys files."
203-
}
204-
205-
$sysFiles | ForEach-Object { $_.FullName }
93+
if ! [[ "$TAG_NAME" =~ ^v([0-9]+)\.[0-9]+\.[0-9]+$ ]]; then
94+
exit 0
95+
fi
96+
97+
MAJOR_TAG="v${BASH_REMATCH[1]}"
98+
TARGET_SHA="$(git rev-list -n 1 "$TAG_NAME")"
99+
git config user.name "github-actions[bot]"
100+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
101+
git tag -f "$MAJOR_TAG" "$TARGET_SHA"
102+
git push -f origin "refs/tags/$MAJOR_TAG"

0 commit comments

Comments
 (0)