Add initial Rust implementation #9
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: | |
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' | |
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: Build local package | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: develop | |
args: --release | |
sccache: 'true' | |
- name: Save cache | |
uses: actions/cache/save@v4 | |
with: | |
# The cache key is the current commit sha | |
key: sedpackvenv-${{ 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: Echo the cache key | |
shell: bash | |
run: | | |
echo ${{ github.event.pull_request.head.sha }} | |
echo "$(echo ${{github.event.pull_request.head.sha }})" | |
- name: Use cached venv with installed sedpack | |
uses: actions/cache/restore@v4 | |
with: | |
# The cache key is the current commit sha | |
key: sedpackvenv-${{ 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 pytest | |
pytest |