Skip to content

abandon this idea of depending workflows #282

abandon this idea of depending workflows

abandon this idea of depending workflows #282

Workflow file for this run

name: Lints, Tests, Deploy
on:
- push
env:
CARGO_TERM_COLOR: always
jobs:
# ---
# --- Run tests and lints for Rust library
# ---
test:
runs-on: ubuntu-latest
strategy:
matrix:
crate: ["opening-hours-syntax", ".", "compact-calendar"]
toolchain: ["stable", "beta", "nightly"]
defaults:
run:
working-directory: ${{ matrix.crate }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- name: Display rust version
run: |
rustc --version
cargo clippy -- --version
cargo fmt -- --version
- name: Lint
run: cargo clippy -- -D warnings
if: matrix.toolchain != 'nightly'
- name: Format
run: cargo fmt -- --check
if: matrix.toolchain != 'nightly'
- name: Tests
run: cargo test
# ---
# --- Execute tests for python package
# ---
test-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Install dev dependancies
run: poetry install
- name: Build Python package
run: poetry run maturin develop
- name: Run doctests
run: poetry run python/run_doctests.py
# ---
# --- Check that all versions are consistency accross packages
# ---
check-version:
runs-on: ubuntu-latest
defaults:
run:
working-directory: scripts
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Install dependancies
run: poetry install
- name: Check version consistency
run: poetry run ./check-version.py
# ---
# --- Build an deploy Rust packages
# ---
deploy-rust:
runs-on: ubuntu-latest
needs: [check-version, test]
strategy:
max-parallel: 1
matrix:
crate:
- compact-calendar
- opening-hours-syntax
- .
defaults:
run:
working-directory: ${{ matrix.crate }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Login to crates.io
run: cargo login $TOKEN
if: github.ref == 'refs/heads/master'
env:
TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
run: cargo publish
if: github.ref == 'refs/heads/master'
# ---
# --- Build and deploy Python bindings
# ---
# --- This part is autogenerated by maturin v1.1.0
# --- To update, run
# ---
# --- maturin generate-ci --zig --platform=all github
# ---
build-python-linux:
runs-on: ubuntu-latest
needs: [test, test-python]
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
3.9
3.10
3.11
3.12
3.13
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
maturin-version: 1.6.0 # pinned until 1.8.0 is released
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --zig
sccache: "true"
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
build-python-windows:
runs-on: windows-latest
needs: [test, test-python]
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: |
3.9
3.10
3.11
3.12
3.13
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
maturin-version: 1.6.0 # pinned until 1.8.0 is released
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
build-python-macos:
runs-on: macos-latest
needs: [test, test-python]
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: |
3.9
3.10
3.11
3.12
3.13
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
maturin-version: 1.6.0 # pinned until 1.8.0 is released
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
build-python-emscripten:
runs-on: ubuntu-latest
needs: [test, test-python]
steps:
- uses: actions/checkout@v4
- run: pip install pyodide-build
- name: Get Emscripten and Python version info
shell: bash
run: |
echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV
echo PYTHON_VERSION=$(pyodide config get python_version | cut -d '.' -f 1-2) >> $GITHUB_ENV
pip uninstall -y pyodide-build
- uses: mymindstorm/setup-emsdk@v12
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
actions-cache-folder: emsdk-cache
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: pip install pyodide-build
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
maturin-version: 1.6.0 # pinned until 1.8.0 is released
target: wasm32-unknown-emscripten
args: --release --out dist -i ${{ env.PYTHON_VERSION }}
sccache: "true"
rust-toolchain: nightly
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wasm-wheels
path: dist
build-python-sdist:
runs-on: ubuntu-latest
needs: [test, test-python]
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
maturin-version: 1.6.0 # pinned until 1.8.0 is released
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
deploy-python:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs:
- check-version
- build-python-linux
- build-python-windows
- build-python-macos
- build-python-emscripten
- build-python-sdist
permissions:
contents: write # used to upload release artifacts
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing *
- uses: actions/download-artifact@v3
with:
name: wasm-wheels
path: wasm
# ---
# --- Build and deploy Python doc
# ---
deploy-python-doc:
runs-on: ubuntu-latest
needs: deploy-python
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Install dependancies
run: poetry install
- name: Check packaging for pypi.org
run: poetry run maturin develop
- name: Build python documentation
run: poetry run pdoc -o docs -d numpy opening_hours
- name: Publish to github pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs