-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (160 loc) · 5.73 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
181
182
183
184
185
186
187
188
189
name: Build
run-name: "Branch Build (${{ github.run_attempt }}.${{ github.run_number }}) - ${{ github.ref_name }}"
on:
workflow_dispatch:
inputs:
amalgam-build:
description: |
(Optional) Amalgam build or version number. Defaults to the latest release.
Examples:
'6807310618',
'https://github.com/howsoai/amalgam/actions/runs/6807310618',
'57.0.1'
required: false
type: string
default: 'latest'
workflow_call:
inputs:
build-type:
required: false
type: string
optional-release-tag:
required: false
type: string
amalgam-build:
required: false
type: string
default: 'latest'
defaults:
run:
shell: bash
jobs:
metadata:
uses: howsoai/.github/.github/workflows/set-metadata.yml@main
secrets: inherit
with:
build-type: ${{ inputs.build-type }}
optional-release-tag: ${{ inputs.optional-release-tag }}
amalgam-build: ${{ inputs.amalgam-build }}
test:
name: Fuzz tests (${{ matrix.amlg-postfix }})
needs: ["metadata"]
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
amlg-postfix: ['-st-afmi', '-mt-afmi']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Download Amalgam linux-amd64
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
if [[ "$run_type" == "release" ]]; then
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "*linux-amd64.tar.gz" "$run_id"
else
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "*linux-amd64" "$run_id"
fi
# Needed because release/non-release downloads are different structure
cd amalgam/lib/linux/amd64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Extract Amalgam binaries
run: |
cd amalgam/lib
find . -type d -name lib -exec sh -c 'mv {}/* "$(dirname {})"' \;
cd ../..
mv amalgam/lib/linux/amd64/bin/amalgam${{ matrix.amlg-postfix }} amalgam${{ matrix.amlg-postfix }}
chmod +x amalgam${{ matrix.amlg-postfix }}
- name: Print Amalgam version
run: |
./amalgam${{ matrix.amlg-postfix }} --version
- name: Run Evolver
timeout-minutes: 20
id: run
run: |
sudo apt-get update
# Install GDB
sudo apt-get install -y gdb
echo "GDB installation complete"
gdb --version
# Don't immediately fail if GDB exits with a non-zero code
set +e
# Set stack size and run (stack size adjustments cannot be done with cmake on Linux)
ulimit -s 524288
echo "Note: output is supressed due to length. See build artifacts for full logs."
echo "Running..."
# Run Evolver with GDB
# However, sent a SIGINT after 6 minutes (indicating a hanging Evolver) to get a stacktrace
TIMEOUT=360
# Run GDB in the background
gdb_output_file=$(mktemp)
if [[ "${{ matrix.amlg-postfix }}" == *"mt"* ]]; then
gdb -batch -ex run -ex "thread apply all bt" --args ./amalgam${{ matrix.amlg-postfix }} --debug-internal-memory tic_tac_toe_evolver.amlg -target-time 300 > "$gdb_output_file" 2>&1 &
GDB_PID=$!
else
gdb -batch -ex run -ex bt --args ./amalgam${{ matrix.amlg-postfix }} --debug-internal-memory tic_tac_toe_evolver.amlg -target-time 300 > "$gdb_output_file" 2>&1 &
GDB_PID=$!
fi
echo "GDB PID: $GDB_PID"
# Set up a timer to send SIGINT to GDB after the timeout
{
sleep $TIMEOUT
kill -SIGINT $GDB_PID
} &
wait $GDB_PID
gdb_output=$(cat "$gdb_output_file")
# Save output to logs.txt, uploaded later
echo "$gdb_output" >> logs.txt
# Print a reasonable amount of the logs to the console
echo "$gdb_output" | tail -n 400
# Evaluate GDB exit code and exit this workflow accordingly
if echo "$gdb_output" | tail -n 100 | grep -q "exited normally"; then
exit 0
# Else, something failed, exit 1
else
exit 1
fi
- name: Compress 'evolve' directory
if: always()
continue-on-error: true
run: |
tar -czvf evolver${{ matrix.amlg-postfix }}.tar.gz evolver logs.txt
- name: Upload 'evolve' directory
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: evolver${{ matrix.amlg-postfix }}-artifacts
path: evolver${{ matrix.amlg-postfix }}.tar.gz
generate-changelog:
if: inputs.build-type == 'release'
secrets: inherit
needs:
- metadata
uses: "howsoai/.github/.github/workflows/release-notes.yml@main"
release:
if: inputs.build-type == 'release'
needs:
- metadata
- generate-changelog
- test
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.metadata.outputs.version }}
commit: ${{ github.sha }}
name: "${{ github.event.repository.name }} ${{ needs.metadata.outputs.version }}"
artifactErrorsFailBuild: true
body: ${{ needs.generate-changelog.outputs.changelog }}
makeLatest: legacy