-
Notifications
You must be signed in to change notification settings - Fork 6
141 lines (105 loc) · 3.51 KB
/
main.yml
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
133
134
135
136
137
138
139
140
141
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: Update PIP
run: python -m pip install --upgrade pip
- name: Python Unit Tests
run: pytest --random-order-bucket=global --cov=src --cov-report xml:coverage.xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- 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 }}