-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (110 loc) · 4.03 KB
/
Copy pathtest-windows.yml
File metadata and controls
128 lines (110 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Test Windows C++ Compilation
on:
push:
branches: [main, feature/*]
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
test-windows-compilation:
name: Test ${{ matrix.program }} MSVC${{ matrix.msvc }} ${{ matrix.arch }} /${{ matrix.opt }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
msvc: ['2019'] # Only MSVC 2019 toolset available on windows-latest
arch: [x86, x64]
opt: [Od, O2]
program: [simple, complex]
env:
SOURCE_FILE: tests/fixtures/sources/${{ matrix.program }}.cpp
OUTPUT_EXE: ${{ matrix.program }}.exe
ORIGINAL_EXE: ${{ matrix.program }}-original.exe
REF_NAME: ${{ matrix.program }}-msvc${{ matrix.msvc }}-${{ matrix.arch }}-${{ matrix.opt }}.exe
REF_PATH: tests/fixtures/references/${{ matrix.program }}-msvc${{ matrix.msvc }}-${{ matrix.arch }}-${{ matrix.opt }}.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
toolset: ${{ matrix.msvc == '2017' && '14.1' || matrix.msvc == '2019' && '14.2' || '14.3' }}
- name: Compile C++ program
shell: cmd
run: |
cl.exe /std:c++17 /${{ matrix.opt }} /Zi %SOURCE_FILE% /Fe:%OUTPUT_EXE% /link /DEBUG:FULL /Brepro
if errorlevel 1 exit /b 1
if not exist %OUTPUT_EXE% (
echo ERROR: Compilation succeeded but %OUTPUT_EXE% not found
exit /b 1
)
echo Compiled %OUTPUT_EXE% successfully
- name: Backup original binary
shell: cmd
run: |
copy %OUTPUT_EXE% %ORIGINAL_EXE%
echo Backed up original binary to %ORIGINAL_EXE%
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install msvcpp-normalize-pe
shell: bash
run: |
# Install uv if not present
command -v uv >/dev/null 2>&1 || pip install uv
uv pip install --system .
echo "Installed msvcpp-normalize-pe"
- name: Patch binary
shell: bash
run: |
msvcpp-normalize-pe "$OUTPUT_EXE" --timestamp 1 --verbose
if [ $? -ne 0 ]; then
echo "ERROR: Patching failed"
exit 1
fi
echo "Patched $OUTPUT_EXE successfully"
- name: Verify reproducibility
shell: bash
run: |
if [ -f "$REF_PATH" ]; then
echo "Reference binary found, comparing hashes..."
ACTUAL_HASH=$(sha256sum "$OUTPUT_EXE" | cut -d' ' -f1)
EXPECTED_HASH=$(sha256sum "$REF_PATH" | cut -d' ' -f1)
echo "Expected: $EXPECTED_HASH"
echo "Actual: $ACTUAL_HASH"
if [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then
echo "ERROR: Hash mismatch - reproducibility test failed!"
echo "This indicates the patched binary differs from the reference."
exit 1
fi
echo "SUCCESS: Hashes match - build is reproducible"
else
echo "WARNING: Reference binary not found: $REF_NAME"
echo "This is expected for initial setup."
echo "Download artifacts from this run to generate references."
exit 1
fi
- name: Test runtime execution
shell: cmd
run: |
echo Testing patched binary execution...
%OUTPUT_EXE%
if errorlevel 1 (
echo ERROR: Patched binary failed to execute correctly
exit /b 1
)
echo SUCCESS: Patched binary executed correctly
- name: Upload binaries as artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.program }}-msvc${{ matrix.msvc }}-${{ matrix.arch }}-${{ matrix.opt }}
path: |
${{ env.ORIGINAL_EXE }}
${{ env.OUTPUT_EXE }}
retention-days: 30