hatchling build #97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [ released ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.sha }} | |
# # # # c++ | |
- name: CMake | |
run: cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_FLAGS=" -O " . | |
- name: Make | |
run: make all | |
- name: C++ Unit Tests | |
run: make test | |
- name: C++ Performance Tests | |
run: make perf | |
# # # # python: | |
- name: Set up latest Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.x | |
- name: Update PIP | |
run: python -m pip install --upgrade pip | |
- name: Install requirements | |
run: pip install --requirement requirements.txt | |
- name: Python Unit Tests | |
run: pytest --random-order-bucket=global --cov=src --cov-report xml:xmlcov/coverage.xml | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: xmlcov/coverage.xml | |
- name: Python Performance Test | |
run: python -m perf | |
- name: Build package | |
run: python -m build | |
- name: Install package | |
run: python -m pip install $(find dist -type f -wholename "*.whl") | |
# # # # cross tests | |
- name: Make random bytes | |
run: dd if=/dev/urandom of=orig.dat bs=1 count=$RANDOM | |
- name: Encode with python | |
run: python -m base91x -e orig.dat py.txt | |
- name: Encode with cpp | |
run: ./base91x -e orig.dat cpp.txt | |
- name: Compare text | |
run: diff py.txt cpp.txt | |
- name: Decode with cpp | |
run: ./base91x -d py.txt cpp.dat | |
- name: Decode with python | |
run: python -m base91x -d cpp.txt py.dat | |
- name: Compare refurbish data | |
run: | | |
HASH_ORIG=$(sha256sum orig.dat | cut -c -64) | |
echo "HASH_ORIG='${HASH_ORIG}'" | |
HASH_CPP=$(sha256sum cpp.dat | cut -c -64) | |
echo "HASH_CPP='${HASH_CPP}'" | |
HASH_PY=$(sha256sum py.dat | cut -c -64) | |
echo "HASH_PY='${HASH_PY}'" | |
if [ -n "${HASH_ORIG}" ] && [ "${HASH_ORIG}" == "${HASH_CPP}" ] && [ "${HASH_ORIG}" == "${HASH_PY}" ]; then | |
echo "OK" | |
else | |
echo "FAIL" | |
exit 1 | |
fi | |
- name: Trash decoding with python | |
run: python -m base91x -d orig.dat trash_py.dat | |
- name: Trash decoding with cpp | |
run: ./base91x -d orig.dat trash_cpp.dat | |
- name: Compare trash data | |
run: | | |
TRASH_HASH_CPP=$(sha256sum trash_cpp.dat | cut -c -64) | |
echo "TRASH_HASH_CPP='${TRASH_HASH_CPP}'" | |
TRASH_HASH_PY=$(sha256sum trash_py.dat | cut -c -64) | |
echo "TRASH_HASH_PY='${TRASH_HASH_PY}'" | |
if [ -n "${TRASH_HASH_CPP}" ] && [ "${TRASH_HASH_CPP}" == "${TRASH_HASH_PY}" ]; then | |
echo "OK" | |
else | |
echo "FAIL" | |
exit 1 | |
fi | |
- name: Failure data upload | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: crash_data | |
path: ./*.dat | |
# # # # deploy if release | |
- name: Publish | |
if: ${{ 'release' == github.event_name }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} |