forked from PathOfBuildingCommunity/PathOfBuilding-PoE2
-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (98 loc) · 3.58 KB
/
Copy pathtest.yml
File metadata and controls
106 lines (98 loc) · 3.58 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
name: Run Tests
on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
workflow_dispatch:
jobs:
run_tests:
runs-on: ubuntu-latest
container: ghcr.io/pathofbuildingcommunity/pathofbuilding-tests:latest
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run tests
run: |
set -eu
shard_count=3
shard="${{ matrix.shard }}"
index=0
found=0
for spec in $(find spec/System -name '*_spec.lua' | sort); do
if [ $((index % shard_count)) -eq "$shard" ]; then
found=1
echo "::group::$spec"
if ! busted --lua=luajit "../$spec"; then
echo "::endgroup::"
exit 1
fi
echo "::endgroup::"
fi
index=$((index + 1))
done
[ "$found" -eq 1 ]
check_modcache:
name: check ModCache is up-to-date
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Check out the PR head branch so we can push back to it.
# On push events github.head_ref is empty; fall back to the pushed ref.
ref: ${{ github.head_ref || github.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache test image
id: image-cache
uses: actions/cache@v4
with:
path: /tmp/pob-test-image.tar
key: pob-test-image-${{ hashFiles('docker-compose.yml') }}
restore-keys: pob-test-image-
- name: Pull or restore image
run: |
if [[ "${{ steps.image-cache.outputs.cache-hit }}" == "true" ]]; then
echo "Restoring image from cache"
docker load < /tmp/pob-test-image.tar
else
echo "Cache miss — pulling from GHCR"
docker pull ghcr.io/pathofbuildingcommunity/pathofbuilding-tests:latest
docker save ghcr.io/pathofbuildingcommunity/pathofbuilding-tests:latest \
-o /tmp/pob-test-image.tar
fi
- name: Regenerate ModCache
# Run on the host (not via container:) so git credentials are available
# for the auto-commit step. Mount the workspace read-write so the
# regenerated ModCache.lua lands in the workspace.
run: |
docker run --rm \
-e HOME=/tmp \
-e "LUA_PATH=../runtime/lua/?.lua;../runtime/lua/?/init.lua" \
-e REGENERATE_MOD_CACHE=1 \
-v "${{ github.workspace }}:/workdir" \
-w /workdir/src \
ghcr.io/pathofbuildingcommunity/pathofbuilding-tests:latest \
luajit HeadlessWrapper.lua
- name: Auto-commit ModCache if stale
run: |
if git diff --quiet src/Data/ModCache.lua; then
echo "ModCache.lua is up to date ✓"
exit 0
fi
echo "ModCache.lua was out of date — committing regenerated version"
git diff --stat src/Data/ModCache.lua
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add src/Data/ModCache.lua
git commit -m "chore: auto-regenerate ModCache.lua"
# Push back to the PR branch (head_ref) or the pushed branch (ref_name).
TARGET="${{ github.head_ref || github.ref_name }}"
git push origin "HEAD:${TARGET}"
echo "::notice::ModCache.lua was regenerated and committed automatically."