-
Notifications
You must be signed in to change notification settings - Fork 22
285 lines (246 loc) · 12.8 KB
/
build_app.yml
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: Build App
on:
push:
branches:
- master
concurrency: ci-${{ github.ref }}
jobs:
build-win:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows Latest MSVC-2022",
os: windows-latest,
artifact: "windows_msvc2022.7z",
build_type: "Release",
cc: "cl",
cxx: "cl",
archiver: "7z a",
generators: "Visual Studio 17 2022"
}
steps:
- name: Check out repository code
uses: actions/[email protected]
with:
submodules: 'true'
- name: Setup Dev Env
uses: ./.github/actions/setup_dev_env
- name: Cache wxWidgets config/build
id: cache-wx-build
uses: actions/cache@v3
with:
path: '${{runner.temp}}/build_${{ runner.os }}_wx_app'
key: ${{ runner.os }}-build-wxapp-${{ hashFiles('**/CMakeLists.txt') }}
#key: ${{ runner.os }}-build-wxapp
- name: Initial wxWidgets config/build
shell: pwsh
env:
LEAFLET_KEY: ${{ secrets.LEAFLET_KEY }}
if: steps.cache-wx-build.outputs.cache-hit != 'true' && runner.os == 'Windows'
working-directory: ${{runner.temp}}
run: |
if (-Not (Test-Path 'build_${{ runner.os }}_wx_app')){ mkdir build_${{ runner.os }}_wx_app }
cd build_${{ runner.os }}_wx_app
#cmake -DInterSpec_FETCH_DEPENDENCIES=OFF -DCMAKE_INSTALL_PREFIX=InterSpec_app_${{runner.os}}_WebView_latest -DCMAKE_PREFIX_PATH="${{runner.temp}}\install" -DNO_CMAKE_SYSTEM_PATH=ON -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF -DCMAKE_C_COMPILER_LAUNCHER=sccache "${{github.workspace}}/target/wxWidgets"
$prefix = "${{runner.temp}}/install"
$install_dir = "InterSpec_app_Windows_WebView_latest"
cmake -DInterSpec_FETCH_DEPENDENCIES=OFF -DUSE_LEAFLET_MAP=ON -DLEAFLET_MAPS_KEY="$env:LEAFLET_KEY" -DUSE_REMOTE_RID=ON -DUSE_REL_ACT_TOOL=ON -DUSE_DETECTION_LIMIT_TOOL=ON -DCMAKE_INSTALL_PREFIX="$install_dir" -DCMAKE_PREFIX_PATH="${{runner.temp}}\install" -DNO_CMAKE_SYSTEM_PATH=ON -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DwxWidgets_ROOT_DIR="$prefix" -DwxWidgets_LIB_DIR="$prefix/lib/vc_x64_lib" -DwxWidgets_CONFIGURATION="msw" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_CONFIGURATION_TYPES="Release" -G "Ninja" "${{github.workspace}}/target/wxWidgets"
# The build -j1 is needed for debug builds to avoid error "fatal error C1041: cannot open program database...", which I think is happening, not because of the "/FS" flag, but because of multiple targets sharing an intermediate directory - maybe
- name: wxWidgets app build
shell: pwsh
if: runner.os == 'Windows'
working-directory: ${{runner.temp}}/build_${{ runner.os }}_wx_app
run: |
if (Test-Path 'InterSpec_app_Windows_WebView_latest'){ Remove-Item 'InterSpec_app_Windows_WebView_latest' -Recurse -Force }
cmake --build . --config Release
cmake --build . --config Release --target install
$notes = "InterSpec_app_${{ runner.os }}_WebView_latest\build_info.txt"
echo "This is an automated build of InterSpec built on the github infrastruction at $(date)" >> $notes
echo "No testing has been performed on this build." >> $notes
echo "InterSpec code git has SHA: ${{ github.sha }}" >> $notes
echo "The Edge browser runtime is required to be installed to run; this will typically already be installed on Windows 10, and may be installed on Windows 7, but this hasnt been tested." >> $notes
echo "Before zipping, files present for the bbuild are:"
ls
Get-ChildItem InterSpec_app_${{ runner.os }}_WebView_latest*.zip | foreach { Remove-Item -Path $_.FullName }
echo "After removing old zip files"
ls
Compress-Archive -CompressionLevel Optimal -Path .\InterSpec_app_${{ runner.os }}_WebView_latest -DestinationPath InterSpec_app_${{ runner.os }}_WebView_latest_$(get-date -f yyyy-MM-dd).zip
echo "After zipping, files present for the build are:"
ls
echo "And files in base dir"
ls ${{runner.temp}}
ls ${{ github.workspace }}
if (Test-Path -Path '${{runner.temp}}\.sccache'){ ls ${{runner.temp}}\.sccache } else { echo "${{runner.temp}}\.sccache Does not exist"}
if (Test-Path -Path 'D:\a\InterSpec'){ ls D:\a\InterSpec } else { echo "D:\a\InterSpec Does not exist"}
if (Test-Path -Path 'D:\a\InterSpec\InterSpec'){ ls D:\a\InterSpec\InterSpec } else { echo "D:\a\InterSpec\InterSpec Does not exist"}
if (Test-Path -Path 'D:\a\InterSpec\InterSpec\.sccache'){ ls D:\a\InterSpec\InterSpec\.sccache } else { echo "D:\a\InterSpec\InterSpec\.sccache Does not exist"}
# sccache --show-stats || & { "ignore failure"; $global:LASTEXITCODE = 0 }
# sccache --stop-server || & { "ignore failure"; $global:LASTEXITCODE = 0 }
- name: Upload wxWidgets app to as GitHub Artifact
uses: actions/[email protected]
if: runner.os == 'Windows'
with:
name: InterSpec_app_${{ runner.os }}_WebView_latest
path: '${{runner.temp}}/build_${{ runner.os }}_wx_app/InterSpec_app_${{ runner.os }}_WebView_latest'
# - name: Upload sccache Artifact
# uses: actions/[email protected]
# if: runner.os == 'Windows'
# with:
# name: sccache_log
# path: '${{runner.temp}}/sccache_log.txt'
- name: Test app build worked
shell: pwsh
working-directory: ${{runner.temp}}/build_${{ runner.os }}_wx_app/InterSpec_app_${{ runner.os }}_WebView_latest
run: |
$p = Start-Process .\InterSpec.exe -ArgumentList @("--test-load", "--mult-instance", "--no-restore") -PassThru
$errTimedOut = $null
$p | Wait-Process -Timeout 120 -ErrorAction SilentlyContinue -ErrorVariable errTimedOut
if ($errTimedOut) { Stop-Process -InputObject $p -Force }
echo "Exit code of InterSpec test load was was" $p.ExitCode
$rval = $p.ExitCode
exit $rval
# If Stop-Process had to be used, the exit code will be -1. If resources didnt load -12. If timed out inside InterSpec -11. If all was okay, 0
# However, some time in Jun 2023, things started timing out (to give return code -11) regularly, even though everything was fine - so we'll allow this, for the moment, but need to look into more.
# Then test file o
#
# Then maybe do a test with something like Puppeteer, by starting the app on a given port, like:
# $p = Start-Process .\Release\InterSpec.exe -ArgumentList @("--no-token", "--port=8088", "--mult-instance", "--no-restore") -PassThru
# Update the bleeding-edge tag to be current commit
- name: Run latest-tag
uses: EndBug/[email protected]
with:
ref: bleeding-edge
description: Latest successful automated build
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
id: artifact-windows-upload-step
with:
name: windows-build
overwrite: true
path: '${{runner.temp}}\build_${{ runner.os }}_wx_app\InterSpec_app_${{ runner.os }}_WebView_latest*.zip'
# - name: Create Release
# uses: ncipollo/[email protected]
# with:
# artifacts: '${{runner.temp}}\build_${{ runner.os }}_wx_app\InterSpec_app_${{ runner.os }}_WebView_latest*.zip'
# draft: false
# prerelease: true
# body: "An automated, and untested build of the latest code pushed to the repository. Requires Windows 10, or may work on Windows 7 with the Edge browser runtime installed."
# allowUpdates: true
# generateReleaseNotes: false
# name: "Development Build"
# removeArtifacts: true
# replacesArtifacts: true
# tag: 'bleeding-edge'
# commit: ${{ github.sha }}
# makeLatest: true
- name: "Cleanup and finish"
run: |
Get-ChildItem InterSpec_app_${{ runner.os }}_WebView_latest*.zip | foreach { Remove-Item -Path $_.FullName }
echo "Job status is ${{ job.status }}."
build-linux:
runs-on: ubuntu-latest # Use the latest Ubuntu environment
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
path: ${{ github.workspace }}/InterSpec_code
submodules: true # Recursively checkout submodules
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ${{runner.temp}}/build_linux_working_dir
key: ${{ runner.os }}-build-npm-${{ hashFiles('target/electron/package.json') }}
restore-keys: |
${{ runner.os }}-build-npm-
- name: Cache c++ dependencies
uses: actions/cache@v3
with:
path: ${{runner.temp}}/build_linux_electron
key: ${{ runner.os }}-build-cpp-${{ hashFiles('cmake/FetchInterSpecDeps.txt') }}
restore-keys: |
${{ runner.os }}-build-cpp-
- name: Make build directories
shell: bash
working-directory: ${{runner.temp}}
run: |
mkdir -p build_linux_electron
mkdir -p build_linux_working_dir
- name: Configure and build in Docker
uses: addnab/docker-run-action@v3
env:
LEAFLET_KEY: ${{ secrets.LEAFLET_KEY }}
with:
image: quay.io/pypa/manylinux_2_28_x86_64
shell: bash
options: --name manylinux-container -v ${{ github.workspace }}/InterSpec_code:/interspec -v ${{runner.temp}}/build_linux_electron/:/build_app -v ${{runner.temp}}/build_linux_working_dir:/build_working_dir -e LEAFLET_KEY=${{ secrets.LEAFLET_KEY }}
run: |
echo "Running Script from within docker"
/interspec/target/electron/build_linux_app_from_docker.sh /interspec /build_app /build_working_dir
- name: Upload Linux artifact
uses: actions/upload-artifact@v4
id: artifact-linux-upload-step
with:
name: linux-build
overwrite: true
path: ${{runner.temp}}/build_linux_working_dir/InterSpec_app_Linux_Electron_latest_*.zip
release:
runs-on: ubuntu-latest
needs: [build-linux, build-win]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
pattern: '*-build'
path: './artifacts'
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R
- name: Get Release ID
id: get_release
run: |
RELEASE_NAME="Development Build"
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases" | \
jq -r ".[] | select(.name == \"$RELEASE_NAME\") | .id")
echo "release_id=$RELEASE_ID" >> $GITHUB_ENV
- name: Delete Previous Assets
run: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
RELEASE_ID=${{ env.release_id }}
PATTERN="InterSpec_app*"
# Get all assets for the release
ASSETS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets")
# Loop through assets and delete those matching the pattern
echo "$ASSETS" | jq -c '.[]' | while read -r asset; do
ASSET_NAME=$(echo "$asset" | jq -r '.name')
ASSET_ID=$(echo "$asset" | jq -r '.id')
# Check if the asset name matches the pattern
if [[ "$ASSET_NAME" == $PATTERN ]]; then
echo "Deleting asset: $ASSET_NAME"
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases/assets/$ASSET_ID"
fi
done
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
fail_on_unmatched_files: true
tag_name: "bleeding-edge"
release_name: "Development Build"
body: "An automated, and untested build of the latest code pushed to the repository.<br />Windows version requires Windows 10 or 11, but may work on Windows 7 with the Edge browser runtime installed.<br />Linux version requires `glibc >=2.28` based distro (e.g., Ubuntu 21.04+, RHEL 9+, Debian 11+, Fedora 34+)."
draft: false
generate_release_notes: false
prerelease: true
make_latest: true
files: "./artifacts/**"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}