|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | + |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + os: [ubuntu-latest] |
| 14 | + python: ["3.10", "3.11", "3.12", "3.13", "3.14", "pypy-3.10"] |
| 15 | + include: |
| 16 | + # CPython 3.9 is built for the runner images up to Ubuntu 24.04. |
| 17 | + - { os: ubuntu-24.04, python: "3.9" } |
| 18 | + - { os: macos-latest, python: "3.10" } |
| 19 | + - { os: macos-latest, python: "3.14" } |
| 20 | + - { os: windows-latest, python: "3.9" } |
| 21 | + - { os: windows-latest, python: "3.14" } |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v7 |
| 25 | + - uses: actions/setup-python@v7 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python }} |
| 28 | + - name: Test the source tree, warnings are errors |
| 29 | + run: python -W error -X dev -m unittest discover -s tests -t . |
| 30 | + |
| 31 | + # The source distribution and the wheel build, the wheel holds the package only, and the |
| 32 | + # tests of the source distribution pass against the installed wheel. |
| 33 | + package: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v7 |
| 37 | + - uses: actions/setup-python@v7 |
| 38 | + with: |
| 39 | + python-version: "3.13" |
| 40 | + - name: Build |
| 41 | + run: | |
| 42 | + python -m pip install build |
| 43 | + python -m build |
| 44 | + - name: The wheel holds the package only, the source distribution the tests and the vectors |
| 45 | + run: | |
| 46 | + python - <<'PY' |
| 47 | + import glob, tarfile, zipfile |
| 48 | + (wheel,) = glob.glob("dist/*.whl") |
| 49 | + names = zipfile.ZipFile(wheel).namelist() |
| 50 | + assert all(n.startswith(("humanized_hash/", "humanized_hash-")) for n in names), names |
| 51 | + assert "humanized_hash/py.typed" in names |
| 52 | + (sdist,) = glob.glob("dist/*.tar.gz") |
| 53 | + members = {n.split("/", 1)[1] for n in tarfile.open(sdist).getnames() if "/" in n} |
| 54 | + for needed in ("LICENSE", "testdata/SOURCE", "testdata/vectors.tsv", |
| 55 | + "testdata/golden/sampler-universal-128.png", "tests/test_vectors.py", |
| 56 | + "tools/crosscheck.sh", "tools/edge-cases.txt", "docs/INTEGRATION.md", |
| 57 | + "CHANGELOG.md"): |
| 58 | + assert needed in members, needed |
| 59 | + PY |
| 60 | + - name: Install the wheel into a clean environment and test it |
| 61 | + run: | |
| 62 | + python -m venv /tmp/clean |
| 63 | + /tmp/clean/bin/pip install dist/*.whl |
| 64 | + mkdir /tmp/sdist && tar -xzf dist/*.tar.gz -C /tmp/sdist --strip-components=1 |
| 65 | + cd /tmp/sdist && rm -rf src |
| 66 | + HH_TEST_INSTALLED=1 /tmp/clean/bin/python -W error -X dev -m unittest discover -s tests -t . |
| 67 | + /tmp/clean/bin/humanized-hash 0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed \ |
| 68 | + --out /tmp/address.png |
| 69 | + cmp /tmp/address.png testdata/golden/evm-1-universal-128.png |
| 70 | +
|
| 71 | + # testdata/ must be the vectors of the hh-cpp release that testdata/SOURCE names. |
| 72 | + provenance: |
| 73 | + runs-on: ubuntu-latest |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v7 |
| 76 | + - name: Read testdata/SOURCE |
| 77 | + id: source |
| 78 | + run: | |
| 79 | + echo "tag=$(sed -n 's/^tag: //p' testdata/SOURCE)" >> "$GITHUB_OUTPUT" |
| 80 | + echo "commit=$(sed -n 's/^commit: //p' testdata/SOURCE)" >> "$GITHUB_OUTPUT" |
| 81 | + - uses: actions/checkout@v7 |
| 82 | + with: |
| 83 | + repository: censync/hh-cpp |
| 84 | + ref: ${{ steps.source.outputs.tag }} |
| 85 | + path: hh-cpp |
| 86 | + - name: The tag is the recorded commit |
| 87 | + run: test "$(git -C hh-cpp rev-parse HEAD)" = "${{ steps.source.outputs.commit }}" |
| 88 | + - name: The copy is byte-identical |
| 89 | + run: | |
| 90 | + diff -r -x SOURCE hh-cpp/testdata testdata |
| 91 | + (cd testdata && grep -E '^[0-9a-f]{64} ' SOURCE | sha256sum --check --quiet) |
| 92 | +
|
| 93 | + # Pseudo-random and hand-made cases beyond the vector set, against hh_cli built from the same |
| 94 | + # release, on the oldest supported Python. |
| 95 | + differential: |
| 96 | + runs-on: ubuntu-24.04 |
| 97 | + steps: |
| 98 | + - uses: actions/checkout@v7 |
| 99 | + - uses: actions/setup-python@v7 |
| 100 | + with: |
| 101 | + python-version: "3.9" |
| 102 | + - name: Read testdata/SOURCE |
| 103 | + id: source |
| 104 | + run: | |
| 105 | + echo "tag=$(sed -n 's/^tag: //p' testdata/SOURCE)" >> "$GITHUB_OUTPUT" |
| 106 | + - uses: actions/checkout@v7 |
| 107 | + with: |
| 108 | + repository: censync/hh-cpp |
| 109 | + ref: ${{ steps.source.outputs.tag }} |
| 110 | + path: hh-cpp |
| 111 | + - name: Build hh_cli |
| 112 | + run: | |
| 113 | + cmake -S hh-cpp -B hh-cpp/build -DCMAKE_BUILD_TYPE=Release -DHH_BUILD_TESTS=OFF |
| 114 | + cmake --build hh-cpp/build --parallel --target hh_cli |
| 115 | + - name: Crosscheck |
| 116 | + run: | |
| 117 | + PYTHON=python tools/crosscheck.sh hh-cpp/build/examples/hh_cli 2000 1 |
| 118 | + PYTHON=python tools/crosscheck.sh hh-cpp/build/examples/hh_cli 2000 2 |
0 commit comments