Skip to content

Restructure Rust plugin monorepo and CI #13

Restructure Rust plugin monorepo and CI

Restructure Rust plugin monorepo and CI #13

name: CI Rust Python Package Plugins
on:
push:
paths:
- "Cargo.toml"
- "Cargo.lock"
- "Makefile"
- "plugins/rust/python-package/**"
- "tests/**"
- "tools/**"
- ".github/workflows/ci-rust-python-package.yaml"
- ".github/workflows/release-rust-python-package.yaml"
- "README.md"
- "DEVELOPING.md"
- "TESTING.md"
pull_request:
branches: [main]
paths:
- "Cargo.toml"
- "Cargo.lock"
- "Makefile"
- "plugins/rust/python-package/**"
- "tests/**"
- "tools/**"
- ".github/workflows/ci-rust-python-package.yaml"
- ".github/workflows/release-rust-python-package.yaml"
- "README.md"
- "DEVELOPING.md"
- "TESTING.md"
permissions:
contents: read
jobs:
validate-and-detect:
runs-on: ubuntu-latest
outputs:
plugins: ${{ steps.detect.outputs.plugins }}
has_plugins: ${{ steps.detect.outputs.has_plugins }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run catalog tests
run: python3 -m unittest tests/test_plugin_catalog.py
- id: detect
shell: bash
run: |
set -euo pipefail
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
json=$(python3 tools/plugin_catalog.py ci-selection . diff "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}")
elif [[ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]]; then
json=$(python3 tools/plugin_catalog.py ci-selection . all)
else
json=$(python3 tools/plugin_catalog.py ci-selection . diff "${{ github.event.before }}" "${{ github.sha }}")
fi
plugins=$(JSON_INPUT="$json" python3 - <<'PY'
import json
import os
payload = json.loads(os.environ["JSON_INPUT"])
plugins = payload["plugins"]
print(json.dumps(plugins))
PY
)
echo "plugins=${plugins}" >> "$GITHUB_OUTPUT"
if [[ "$(JSON_INPUT="$json" python3 - <<'PY'
import json
import os
print(str(json.loads(os.environ["JSON_INPUT"])["has_plugins"]).lower())
PY
)" == "false" ]]; then
echo "has_plugins=false" >> "$GITHUB_OUTPUT"
else
echo "has_plugins=true" >> "$GITHUB_OUTPUT"
fi
build-test:
needs: validate-and-detect
if: needs.validate-and-detect.outputs.has_plugins == 'true'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
plugin: ${{ fromJson(needs.validate-and-detect.outputs.plugins) }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Verify Rust toolchain
run: |
rustc --version
cargo --version
- name: Install uv
run: python -m pip install uv
- name: Sync plugin environment
working-directory: plugins/rust/python-package/${{ matrix.plugin }}
run: make sync
- name: Plugin CI verification
working-directory: plugins/rust/python-package/${{ matrix.plugin }}
run: make ci