Skip to content

add pyauditor build workflow, adjust python unit test workflow #1

add pyauditor build workflow, adjust python unit test workflow

add pyauditor build workflow, adjust python unit test workflow #1

name: build-pyauditor
on:
pull_request:
push:
branches:
- main
tags:
- v*
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
prefix-key: cache-dependencies-linux
# We need to somehow get the SQLX_OFFLINE env variable into the container.
# Since `maturin-action` doesn't enable us to do that, we have to tell cargo
# via its configuration.
- name: Create fake .cargo/config.toml
run: |
mkdir -p .cargo
echo -e "[env]\nSQLX_OFFLINE = \"true\"" >> .cargo/config.toml
- name: Maturin
uses: messense/maturin-action@v1
with:
target: x86_64
manylinux: auto
command: build
args: --release --sdist -o dist --interpreter python${{ matrix.python-version }} --manifest-path pyauditor/Cargo.toml
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: linux-wheel-${{ matrix.python-version }}
path: dist
windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
prefix-key: cache-dependencies-windows
# We need to somehow get the SQLX_OFFLINE env variable into the container.
# Since `maturin-action` doesn't enable us to do that, we have to tell cargo
# via its configuration.
# I don't know how to script this on windows (and I don't care). Therefore
# I'll just copy the config.toml from the pyauditor directory. This may lead to
# problems when there is a .cargo/config.toml, which will then be overwritten.
- name: Create fake .cargo\config.toml
run: |
copy pyauditor\.cargo\config.toml .cargo\config.toml
# echo "[env]" >> .cargo\config.toml
# Fails here, saying "echo." doesn't exist.
# echo. >> .cargo\config.toml
# echo "SQLX_OFFLINE = \"true\"" >> .cargo\config.toml
# type .cargo\config.toml
- uses: messense/maturin-action@v1
with:
command: build
args: --release -o dist --interpreter python${{ matrix.python-version }} --manifest-path pyauditor/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: windows-wheel-${{ matrix.python-version }}
path: dist
macos:
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
prefix-key: cache-dependencies-macos
# We need to somehow get the SQLX_OFFLINE env variable into the container.
# Since `maturin-action` doesn't enable us to do that, we have to tell cargo
# via its configuration.
- name: Create fake .cargo/config.toml
run: |
mkdir -p .cargo
echo -e "[env]\nSQLX_OFFLINE = \"true\"" >> .cargo/config.toml
- uses: messense/maturin-action@v1
with:
command: build
args: --release -o dist --target universal2-apple-darwin --interpreter python${{ matrix.python-version }} --manifest-path pyauditor/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: mac-wheel-${{ matrix.python-version }}
path: dist