-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (130 loc) · 5.51 KB
/
e2e.yaml
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
name: End to End Test
on:
push: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo build --release --locked
- uses: actions/upload-artifact@v4
with:
name: binary
path: target/release/mrpack-container
e2e:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
mrpackfile: [quilt-simple.mrpack, fabric-simple.mrpack]
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
tests/mrpacks
- uses: actions/download-artifact@v4
with:
name: binary
path: /usr/local/bin
merge-multiple: true
- name: Install mrpack-container
run: chmod +x /usr/local/bin/mrpack-container
- name: Build Container
run: mrpack-container --arches amd64 --output ./output "tests/mrpacks/${{ matrix.mrpackfile }}"
- name: Run Container
run: |
wget --no-verbose "https://piston-data.mojang.com/v1/objects/84194a2f286ef7c14ed7ce0090dba59902951553/server.jar"
container_id=$(tar cf - -C ./output . | podman load | awk '{ print $3 }')
mkdir /tmp/world
chmod a+rwx /tmp/world
echo "eula=true" > eula.txt
podman run \
--detach \
--publish 25565:25565 \
--volume /tmp/world:/var/minecraft/world \
--volume "$(pwd)"/server.jar:/usr/local/minecraft/server.jar:ro \
--volume "$(pwd)"/eula.txt:/var/minecraft/eula.txt:ro \
"$container_id" > running_container_id
- name: Verify Container is hosting a Minecraft Server
run: |
python3 -m pip install mcstatus
sleep 60
podman logs $(cat running_container_id)
mcstatus localhost status
- name: Verify world save
run: |
if [ -f /tmp/world/level.dat ]; then
echo "Level file found in expected location"
else
echo "Level file not found!"
false
fi
# The stability test verifies that the output of mrpack-container is "stable". That is, if we build the same image
# multiple times do we get the same output byte-for-byte each time? We don't guarantee stability between different
# versions of mrpack-container (obviously), so this runs the same build on the same version three times, records the
# digests, and compares them.
stability-test:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
instance: [1, 2, 3]
outputs:
digest_amd64_1: ${{ steps.digest.outputs.digest_amd64_1 }}
digest_arm64_1: ${{ steps.digest.outputs.digest_arm64_1 }}
digest_amd64_2: ${{ steps.digest.outputs.digest_amd64_2 }}
digest_arm64_2: ${{ steps.digest.outputs.digest_arm64_2 }}
digest_amd64_3: ${{ steps.digest.outputs.digest_amd64_3 }}
digest_arm64_3: ${{ steps.digest.outputs.digest_arm64_3 }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
tests/mrpacks
- uses: actions/download-artifact@v4
with:
name: binary
path: /usr/local/bin
merge-multiple: true
- name: Install mrpack-container
run: chmod +x /usr/local/bin/mrpack-container
- name: Build Container
run: mrpack-container --arch amd64 --arch arm64 --output ./output "tests/mrpacks/fabric-simple.mrpack"
- name: Debug Output for Investigations
run: |
tree output/
ls -l output/blobs/sha256
jq <output/index.json
jq <"output/blobs/sha256/$(jq <output/index.json -r '.manifests[0].digest' | awk '{split($0,a,":"); print a[2]}')"
jq <"output/blobs/sha256/$(jq <output/index.json -r '.manifests[1].digest' | awk '{split($0,a,":"); print a[2]}')"
# We can record and then compare just the digest reported in the index.json file. By definition, it will be the
# SHA256 sum of the manifest of the image, which itself contains the SHA256 sums of each layer tarball and the
# JSON config file.
- name: Report Image Digests
id: digest
run: |
echo "digest_arm64_${{matrix.instance}}=$(jq -r <output/index.json '.manifests[] | select(.platform.architecture == "arm64") | .digest')" >> "$GITHUB_OUTPUT"
echo "digest_amd64_${{matrix.instance}}=$(jq -r <output/index.json '.manifests[] | select(.platform.architecture == "amd64") | .digest')" >> "$GITHUB_OUTPUT"
verify-stability:
runs-on: ubuntu-latest
needs: stability-test
steps:
- name: Compare artifacts
run: |
echo '${{ toJSON(needs.stability-test.outputs) }}'
if [ '${{ needs.stability-test.outputs.digest_amd64_1 }}' != '${{ needs.stability-test.outputs.digest_amd64_2 }}' ]; then
echo 'Comparsion failure. Containers did not match!'
exit 1
fi
if [ '${{ needs.stability-test.outputs.digest_amd64_1 }}' != '${{ needs.stability-test.outputs.digest_amd64_3 }}' ]; then
echo 'Comparsion failure. Containers did not match!'
exit 1
fi
if [ '${{ needs.stability-test.outputs.digest_arm64_1 }}' != '${{ needs.stability-test.outputs.digest_arm64_2 }}' ]; then
echo 'Comparsion failure. Containers did not match!'
exit 1
fi
if [ '${{ needs.stability-test.outputs.digest_arm64_1 }}' != '${{ needs.stability-test.outputs.digest_arm64_3 }}' ]; then
echo 'Comparsion failure. Containers did not match!'
exit 1
fi