-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.cirrus.yml
More file actions
191 lines (185 loc) · 7.36 KB
/
.cirrus.yml
File metadata and controls
191 lines (185 loc) · 7.36 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
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
# .cirrus.yml — FreeBSD build sanity for restoHack
freebsd_build_task:
name: FreeBSD build (curses sanity)
skip: "changesIncludeOnly('docs/**', '**.md')"
freebsd_instance:
image_family: freebsd-14-3
env:
CIRRUS_CLONE_DEPTH: "1"
install_script: |
set -euxo pipefail
pkg update -f
pkg install -y cmake ninja pkgconf ncurses expect perl5
build_script: |
set -euxo pipefail
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
verify_script: |
set -euxo pipefail
file build/hack
# Verify a minimal curses link works
printf '#include <curses.h>\nint main(){initscr(); endwin(); return 0;}\n' > /tmp/t.c
cc /tmp/t.c -lcurses -o /tmp/t
/tmp/t
interactive_test_script: |
set -euxo pipefail
cd build
export TERM=vt100
echo "Verifying hack binary exists and is executable..."
test -x ./hack || { echo "hack binary not found"; exit 1; }
test -d ./hackdir || { echo "hackdir not found"; exit 1; }
test -f ./hackdir/data || { echo "data file not found in hackdir"; exit 1; }
test -f ./hackdir/rumors || { echo "rumors file not found in hackdir"; exit 1; }
echo "Running interactive expect test..."
# Outer safety timeout (60s) in case expect itself hangs
# Using perl alarm -- portable across macOS/Linux/BSD
perl -e 'alarm 60; exec @ARGV' expect -f ../.github/scripts/smoke-test.exp || {
echo "Interactive test failed (expect exit code: $?)"
echo "===== Expect session log ====="
cat /tmp/hack-expect.log 2>/dev/null || echo "(no log file found)"
echo "===== End log ====="
exit 1
}
echo ""
echo "===== Expect session log ====="
cat /tmp/hack-expect.log 2>/dev/null || echo "(no log file found)"
echo "===== End log ====="
echo ""
echo "Interactive test: game started successfully"
verify_map_script: |
set -euxo pipefail
sh .github/scripts/verify-map.sh /tmp/hack-expect.log
always:
artifacts:
build_logs:
path: build/**
type: ARCHIVE
source_tarball_test_task:
name: Test source tarball build
only_if: $CIRRUS_TAG =~ '^v[0-9].+'
freebsd_instance:
image_family: freebsd-14-3
env:
CIRRUS_CLONE_DEPTH: "1"
depends_on:
- FreeBSD build (curses sanity)
install_script: |
set -euxo pipefail
pkg update -f
pkg install -y cmake ninja pkgconf ncurses curl jq ca_root_nss
download_source_tarball_script: |
set -euxo pipefail
echo "Attempting to download source tarball for tag: ${CIRRUS_TAG:-<unset>}"
# Add retry logic and better debugging
for i in 1 2 3; do
echo "Attempt $i: Fetching release info..."
API_JSON="$(curl -sf https://api.github.com/repos/Critlist/restoHack/releases/tags/${CIRRUS_TAG})" && break
echo "API call failed, retrying in 30s..."
sleep 30
done
echo "Release API response received, parsing assets..."
echo "$API_JSON" | jq -r '.assets[]?.name' || true # Debug: show all asset names
# Look for source tarball (new naming pattern)
SOURCE_URL="$(echo "$API_JSON" | jq -r '.assets[]?.browser_download_url | select(test("restoHack-.*-source\\.tar\\.gz$"))' | head -n1)"
test -n "$SOURCE_URL" || {
echo "No matching source tarball found for ${CIRRUS_TAG}"
echo "Available assets:"
echo "$API_JSON" | jq -r '.assets[]?.name' || echo "Failed to parse assets"
exit 1
}
echo "Found source tarball URL: $SOURCE_URL"
curl -fL -o source-tarball.tar.gz "$SOURCE_URL"
ls -la source-tarball.tar.gz
test_source_extraction_script: |
set -euxo pipefail
mkdir source_test && cd source_test
tar -xzf ../source-tarball.tar.gz --strip-components=1
ls -la # Show tarball contents
verify_source_contents_script: |
set -euxo pipefail
cd source_test
echo "Checking for required source files..."
test -f CMakeLists.txt || { echo "✗ CMakeLists.txt missing"; exit 1; }
echo "✓ CMakeLists.txt present"
test -f config.h.in || { echo "✗ config.h.in missing"; exit 1; }
echo "✓ config.h.in present"
test -d src || { echo "✗ src/ directory missing"; exit 1; }
echo "✓ src/ directory present"
test -f README.md || { echo "✗ README.md missing"; exit 1; }
echo "✓ README.md present"
test -f LICENSE || { echo "✗ LICENSE missing"; exit 1; }
echo "✓ LICENSE present"
test -f data || { echo "✗ data file missing"; exit 1; }
echo "✓ data file present"
test -f help || { echo "✗ help file missing"; exit 1; }
echo "✓ help file present"
test -f hh || { echo "✗ hh file missing"; exit 1; }
echo "✓ hh file present"
test -f rumors || { echo "✗ rumors file missing"; exit 1; }
echo "✓ rumors file present"
test_source_build_script: |
set -euxo pipefail
cd source_test
echo "Testing build from source tarball..."
cmake -S . -B test_build -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake --build test_build --parallel
file test_build/hack
# Quick smoke test
test_build/hack -s || true
binary_tarball_test_task:
name: Test static binary tarball
only_if: $CIRRUS_TAG =~ '^v[0-9].+'
container:
image: alpine:3.20
env:
CIRRUS_CLONE_DEPTH: "1"
install_script: |
apk add --no-cache curl jq tar file
download_binary_tarball_script: |
set -eux
echo "Attempting to download binary tarball for tag: ${CIRRUS_TAG:-<unset>}"
# Add retry logic
for i in 1 2 3; do
echo "Attempt $i: Fetching release info..."
API_JSON="$(curl -sf https://api.github.com/repos/Critlist/restoHack/releases/tags/${CIRRUS_TAG})" && break
echo "API call failed, retrying in 30s..."
sleep 30
done
echo "Release API response received, parsing assets..."
echo "$API_JSON" | jq -r '.assets[]?.name' || true # Debug: show all asset names
# Look for static binary tarball
BINARY_URL="$(echo "$API_JSON" | jq -r '.assets[]?.browser_download_url | select(test("restoHack-.*-linux-x86_64-static\\.tar\\.gz$"))' | head -n1)"
test -n "$BINARY_URL" || {
echo "No matching binary tarball found for ${CIRRUS_TAG}"
echo "Available assets:"
echo "$API_JSON" | jq -r '.assets[]?.name' || echo "Failed to parse assets"
exit 1
}
echo "Found binary tarball URL: $BINARY_URL"
curl -fL -o binary-tarball.tar.gz "$BINARY_URL"
ls -la binary-tarball.tar.gz
test_binary_extraction_script: |
set -eux
mkdir binary_test && cd binary_test
tar -xzf ../binary-tarball.tar.gz
ls -la # Show tarball contents
verify_binary_contents_script: |
set -eux
cd binary_test
echo "Checking for required binary files..."
test -f hack || { echo "✗ hack binary missing"; exit 1; }
echo "✓ hack binary present"
test -d hackdir || { echo "✗ hackdir/ directory missing"; exit 1; }
echo "✓ hackdir/ directory present"
test -f run-hack.sh || { echo "✗ run-hack.sh launcher missing"; exit 1; }
echo "✓ run-hack.sh launcher present"
test -f README.md || { echo "✗ README.md missing"; exit 1; }
echo "✓ README.md present"
test -f LICENSE || { echo "✗ LICENSE missing"; exit 1; }
echo "✓ LICENSE present"
# Verify it's actually a static binary
file hack | grep -q "statically linked" || { echo "✗ Binary is not statically linked"; exit 1; }
echo "✓ Binary is statically linked"
# Test that it runs
./hack -s || true
echo "✓ Binary executes successfully"