-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (150 loc) · 5.55 KB
/
build.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
name: Build
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]
jobs:
build:
runs-on: windows-2022
defaults:
run:
shell: pwsh
env:
DOTNET_INSTALL_DIR: D:\dotnet
GH_TOKEN: ${{ github.token }}
NUGET_PACKAGES: ${{ github.workspace }}\.nuget\packages
bizhawk_hash: ''
bizhawk_required_files: |
lib/BizHawk/output/dll/BizHawk.*.dll
lib/BizHawk/output/EmuHawk.exe
skip_benchmarks: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Get BizHawk submodule SHA
run: echo "bizhawk_hash=$(git rev-parse HEAD:lib/BizHawk)" >> $env:GITHUB_ENV
- name: Restore BizHawk binaries from cache
id: bizhawk-binaries-cache-restore
uses: actions/cache/restore@v4
with:
path: ${{ env.bizhawk_required_files }}
key: bizhawk-binaries-${{ env.bizhawk_hash }}
- name: Download BizHawk binaries
if: ${{ steps.bizhawk-binaries-cache-restore.outputs.cache-hit != 'true' }}
run: |
git submodule update --init --depth 1
git -C lib/BizHawk fetch --tags
$tag = $(git -C lib/BizHawk tag --points-at HEAD)
if ([string]::IsNullOrEmpty($tag))
{
exit 0
}
else
{
gh release download -R TASVideos/BizHawk -p BizHawk*$tag*.zip
Expand-Archive -Path ./BizHawk*$tag*.zip -DestinationPath lib/BizHawk/output
}
- name: Build BizHawk
if: ${{ hashFiles(env.bizhawk_required_files) == '' }}
run: QuickTestBuildAndPackage_Release.bat
shell: cmd
working-directory: lib/BizHawk/Dist
- name: Save BizHawk binaries to cache
if: ${{ steps.bizhawk-binaries-cache-restore.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: ${{ env.bizhawk_required_files }}
key: ${{ steps.bizhawk-binaries-cache-restore.outputs.cache-primary-key }}
- name: Build external tool
run: dotnet build -c:Release -t:CreateZip
working-directory: src/SHME.ExternalTool
- name: Check for [skip benchmarks]
run: |
$pr = "${{ github.event_name == 'pull_request' }}" -eq 'true'
# rev-list is necessary because the HEAD~X syntax doesn't actually go in
# order one commit at a time, instead traversing by parent, so merge
# commits cause big jumps that throw off one's expectations.
foreach ($sha in $(git rev-list HEAD))
{
# Powershell treats command output as a string if it's one line, but as
# an array of strings if it's multiline. That then changes the behavior
# of things like StartsWith or the -match operator. Piping through this
# commandlet concatenates arrays into one big string, avoiding that.
$msg = $(git show -s --format=%B $sha) | Out-String
$skip = $msg -match '\[skip benchmarks?\]'
# In case of a force push to a pull request, Github will add an
# invisible merge commit that doesn't contain the expected newest
# commit message. Merge commits should otherwise be rare in a PR,
# so simply checking the message for the word "Merge" handles this.
if ((-not $skip) -and $pr -and $msg.StartsWith('Merge'))
{
continue
}
echo "skip_benchmarks=$skip" >> $env:GITHUB_ENV
break
}
- name: Run benchmarks
if: ${{ env.skip_benchmarks != 'true' }}
run: dotnet run -c Release -- -f * -e json -a ../../artifacts/test/benchmark
working-directory: test/Benchmark
- name: Rename benchmark results
if: ${{ env.skip_benchmarks != 'true' }}
run: Rename-Item -Path BenchmarkRun*.json -NewName benchmark-results.json
working-directory: artifacts/test/benchmark/results
- name: Upload benchmark results
if: ${{ github.event_name != 'pull_request' && env.skip_benchmarks != 'true' }}
uses: benchmark-action/github-action-benchmark@v1
with:
name: SHME BenchmarkDotNet results
tool: 'benchmarkdotnet'
output-file-path: artifacts/test/benchmark/results/benchmark-results.json
gh-repository: github.com/ItEndsWithTens/PerfTrendsWithTens
benchmark-data-dir-path: SHME/bench
github-token: ${{ secrets.PERF_REPO_WRITE_TOKEN }}
auto-push: true
- name: Upload .zip
uses: actions/upload-artifact@v4
with:
name: zip
path: artifacts/dist/*.zip
compression-level: 0
create-release:
needs: build
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Download zip file
uses: actions/download-artifact@v4
with:
name: zip
- name: Release latest dev build
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
uses: crowbarmaster/[email protected]
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: 'latest'
title: 'Latest dev build'
prerelease: false
generate_notes: true
files: |
*.zip
- name: Prepare draft release of tag
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: crowbarmaster/[email protected]
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
draft: true
prerelease: false
generate_notes: true
files: |
*.zip