Skip to content

Commit f62b4ac

Browse files
committed
Add roundtrip enwik8 hash to CI tests.
1 parent bb9374e commit f62b4ac

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

.github/workflows/tests.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ jobs:
104104
path: ~/.cache/pre-commit/
105105
key: pre-commit-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}
106106

107+
- name: Cache enwik8 dataset
108+
uses: actions/cache@v4
109+
with:
110+
path: build/enwik8.zip
111+
key: enwik8-dataset-${{ hashFiles('Makefile') }}
112+
113+
- name: Download enwik8 dataset
114+
run: make download-enwik8
115+
107116
- name: Pre-commit run
108117
run: |
109118
source ${{ env.ACTIVATE_PYTHON_VENV }}
@@ -116,6 +125,23 @@ jobs:
116125
belay run micropython -X heapsize=200M -m unittest tests/*.py
117126
coverage report
118127
128+
- name: Verify CLI compression/decompression integrity
129+
run: |
130+
source ${{ env.ACTIVATE_PYTHON_VENV }}
131+
make download-enwik8
132+
original_hash=$(sha256sum build/enwik8 | cut -d' ' -f1)
133+
roundtrip_hash=$(tamp compress build/enwik8 | tamp decompress | sha256sum | cut -d' ' -f1)
134+
if [ "$original_hash" = "$roundtrip_hash" ]; then
135+
echo "✓ Compression/decompression integrity verified"
136+
echo "Original hash: $original_hash"
137+
echo "Roundtrip hash: $roundtrip_hash"
138+
else
139+
echo "✗ Compression/decompression integrity check failed"
140+
echo "Original hash: $original_hash"
141+
echo "Roundtrip hash: $roundtrip_hash"
142+
exit 1
143+
fi
144+
119145
- name: Upload coverage to Codecov
120146
if: steps.check_test_files.outputs.files_exists == 'true'
121147
uses: codecov/codecov-action@v4

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,20 @@ clean: clean-cython
5353
@rm -rf build
5454
@rm -rf dist
5555

56-
build/enwik8:
57-
if [ ! -f build/enwik8 ]; then \
56+
build/enwik8.zip:
57+
if [ ! -f build/enwik8.zip ]; then \
5858
mkdir -p build; \
5959
cd build; \
6060
curl -O https://mattmahoney.net/dc/enwik8.zip; \
61+
cd ..; \
62+
fi
63+
64+
download-enwik8-zip: build/enwik8.zip
65+
66+
build/enwik8: build/enwik8.zip
67+
if [ ! -f build/enwik8 ]; then \
68+
cd build; \
6169
unzip -q enwik8.zip; \
62-
rm enwik8.zip; \
6370
cd ..; \
6471
fi
6572

0 commit comments

Comments
 (0)