Add initial Rust implementation #24
Workflow file for this run
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
# Workflows which need Python cache | |
name: Python CI | |
on: | |
push: | |
paths: | |
- '**/*.py' | |
- '**/*.rs' | |
- 'pytest.ini' | |
merge_group: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
schedule: | |
- cron: 0 5 * * 1 # Every Monday at 5:00 UTC | |
permissions: | |
contents: read | |
jobs: | |
# Build cache for pip package dependencies (low frequency) | |
dependencies: | |
name: Pip dependencies cache | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
# Build a virtualenv cache | |
- name: Get venv cache | |
uses: actions/cache/restore@v4 | |
id: sedpack_venv_dependencies | |
with: | |
# The cache key depends on requirements.txt | |
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('**/requirements*.txt') }} | |
path: .venv | |
# Build a virtualenv, but only if it doesn't already exist | |
- name: Populate pip cache | |
run: | | |
python -m venv .venv | |
source .venv/bin/activate | |
python -m pip install --require-hashes --no-deps -r requirements.txt | |
if: steps.sedpack_venv_dependencies.outputs.cache-hit != 'true' | |
- name: Save cache | |
uses: actions/cache/save@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('**/requirements*.txt') }} | |
path: .venv | |
if: steps.sedpack_venv_dependencies.outputs.cache-hit != 'true' | |
# Build cache for current code (every commit) | |
local: | |
name: Local install | |
needs: [dependencies] | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
cache: 'pip' | |
- name: Use cached venv with dependencies | |
uses: actions/cache/restore@v4 | |
id: sedpack_venv_cache | |
with: | |
# The cache key depends on requirements.txt | |
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('**/requirements*.txt') }} | |
path: .venv | |
fail-on-cache-miss: true | |
- name: Source venv | |
run: source .venv/bin/activate | |
- name: Install local | |
run: python -m pip install --editable . | |
- name: Build local package | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: develop | |
args: --release | |
sccache: 'true' | |
- name: Try import | |
run: python -c "from sedpack import _sedpack_rs" | |
- name: Save cache | |
uses: actions/cache/save@v4 | |
with: | |
# The cache key is the current commit sha | |
key: sedpackvenv-$${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-{{ github.event.pull_request.head.sha }} | |
path: .venv | |
pytest: | |
name: Pytest | |
needs: [local] | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
steps: | |
# Restore venv | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
cache: 'pip' | |
- name: Use cached venv with installed sedpack | |
uses: actions/cache/restore@v4 | |
with: | |
# The cache key is the current commit sha | |
key: sedpackvenv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ github.event.pull_request.head.sha }} | |
path: .venv | |
fail-on-cache-miss: true | |
# Pytest | |
- name: Run Pytest | |
shell: bash | |
run: | | |
source .venv/bin/activate | |
pip install -r test_requirements.txt | |
python -m pip install --editable . | |
pytest | |
coverage: | |
name: Coverage | |
needs: [local] | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
steps: | |
# Restore venv | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
cache: 'pip' | |
- name: Use cached venv with installed sedpack | |
uses: actions/cache/restore@v4 | |
with: | |
# The cache key is the current commit sha | |
key: sedpackvenv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ github.event.pull_request.head.sha }} | |
path: .venv | |
fail-on-cache-miss: true | |
# Coverage | |
- name: Source | |
shell: bash | |
run: | | |
source .venv/bin/activate | |
pip install -r test_requirements.txt | |
python -m pip install --editable . | |
- name: Install workflow dependencies | |
run: pip install --upgrade pytest coverage | |
- name: Running unit tests with coverage | |
env: | |
DISABLE_AUTOGRAPH: 1 | |
# TODO remove the -i (ignore errors) | |
run: | | |
coverage run -m pytest | |
coverage xml -i | |
- name: Upload results | |
uses: coverallsapp/github-action@v2 | |
with: | |
file: coverage.xml |