| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
pull_request: |
| 6 |
branches: [ "main" ] |
| 7 |
|
| 8 |
# Allows you to run this workflow manually from the Actions tab |
| 9 |
workflow_dispatch: |
| 10 |
|
| 11 |
permissions: |
| 12 |
contents: read |
| 13 |
|
| 14 |
env: |
| 15 |
PACKAGE: bpack |
| 16 |
|
| 17 |
jobs: |
| 18 |
build: |
| 19 |
runs-on: ubuntu-latest |
| 20 |
|
| 21 |
steps: |
| 22 |
- uses: actions/checkout@v4 |
| 23 |
with: |
| 24 |
submodules: 'true' |
| 25 |
|
| 26 |
- name: Set up Python |
| 27 |
uses: actions/setup-python@v5 |
| 28 |
with: |
| 29 |
python-version: "3.x" |
| 30 |
|
| 31 |
- name: Install build dependencies |
| 32 |
run: | |
| 33 |
python -m pip install --upgrade pip |
| 34 |
python -m pip install build twine |
| 35 |
|
| 36 |
- name: Build the package |
| 37 |
run: | |
| 38 |
python -m build |
| 39 |
python -m twine check dist/* |
| 40 |
|
| 41 |
- name: Upload build artifacts |
| 42 |
uses: actions/upload-artifact@v4 |
| 43 |
with: |
| 44 |
name: dist |
| 45 |
path: | |
| 46 |
dist/*.tar.gz |
| 47 |
dist/*.whl |
| 48 |
|
| 49 |
test: |
| 50 |
runs-on: ${{ matrix.os }} |
| 51 |
name: ${{ matrix.os }} ${{ matrix.python-version }} |
| 52 |
needs: build |
| 53 |
strategy: |
| 54 |
matrix: |
| 55 |
python-version: ["3.9", "3.x"] # pypy3.9 |
| 56 |
os: [ubuntu-latest, macos-latest, windows-latest] |
| 57 |
|
| 58 |
steps: |
| 59 |
- name: Get distribution |
| 60 |
uses: actions/[email protected] |
| 61 |
with: |
| 62 |
name: dist |
| 63 |
path: dist |
| 64 |
|
| 65 |
- name: Set up Python ${{ matrix.python-version }} |
| 66 |
uses: actions/setup-python@v5 |
| 67 |
with: |
| 68 |
python-version: ${{ matrix.python-version }} |
| 69 |
|
| 70 |
- name: Install |
| 71 |
shell: bash |
| 72 |
run: | |
| 73 |
VERSION=$(echo dist/*.whl | cut -d '-' -f 2) |
| 74 |
python -m pip install --upgrade pip |
| 75 |
python -m pip install dist/${PACKAGE}-${VERSION}-py3-none-any.whl[full] |
| 76 |
|
| 77 |
- name: Install test dependencies |
| 78 |
shell: bash |
| 79 |
run: | |
| 80 |
python -m pip install pytest pytest-cov |
| 81 |
if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi |
| 82 |
|
| 83 |
- name: Test |
| 84 |
shell: bash |
| 85 |
run: | |
| 86 |
python -m pytest --cov=${PACKAGE} --cov-report=html --cov-report=term --pyargs ${PACKAGE} |