|
| 1 | +name: CI Rust Python Package Plugins |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "Cargo.toml" |
| 8 | + - "Cargo.lock" |
| 9 | + - "Makefile" |
| 10 | + - "plugins/rust/python-package/**" |
| 11 | + - "tests/**" |
| 12 | + - "tools/**" |
| 13 | + - ".github/workflows/ci-rust-python-package.yaml" |
| 14 | + - ".github/workflows/release-rust-python-package.yaml" |
| 15 | + - "README.md" |
| 16 | + - "DEVELOPING.md" |
| 17 | + - "TESTING.md" |
| 18 | + pull_request: |
| 19 | + paths: |
| 20 | + - "Cargo.toml" |
| 21 | + - "Cargo.lock" |
| 22 | + - "Makefile" |
| 23 | + - "plugins/rust/python-package/**" |
| 24 | + - "tests/**" |
| 25 | + - "tools/**" |
| 26 | + - ".github/workflows/ci-rust-python-package.yaml" |
| 27 | + - ".github/workflows/release-rust-python-package.yaml" |
| 28 | + - "README.md" |
| 29 | + - "DEVELOPING.md" |
| 30 | + - "TESTING.md" |
| 31 | + |
| 32 | +permissions: |
| 33 | + contents: read |
| 34 | + |
| 35 | +jobs: |
| 36 | + validate-and-detect: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + outputs: |
| 39 | + plugins: ${{ steps.detect.outputs.plugins }} |
| 40 | + has_plugins: ${{ steps.detect.outputs.has_plugins }} |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + fetch-depth: 0 |
| 45 | + |
| 46 | + - uses: actions/setup-python@v5 |
| 47 | + with: |
| 48 | + python-version: "3.12" |
| 49 | + |
| 50 | + - name: Run catalog tests |
| 51 | + run: python3 -m unittest tests/test_plugin_catalog.py |
| 52 | + |
| 53 | + - id: detect |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + set -euo pipefail |
| 57 | + if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then |
| 58 | + json=$(python3 tools/plugin_catalog.py ci-selection . diff "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}") |
| 59 | + elif [[ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]]; then |
| 60 | + json=$(python3 tools/plugin_catalog.py ci-selection . all) |
| 61 | + else |
| 62 | + json=$(python3 tools/plugin_catalog.py ci-selection . diff "${{ github.event.before }}" "${{ github.sha }}") |
| 63 | + fi |
| 64 | +
|
| 65 | + plugins=$(JSON_INPUT="$json" python3 - <<'PY' |
| 66 | +import json |
| 67 | +import os |
| 68 | + |
| 69 | +payload = json.loads(os.environ["JSON_INPUT"]) |
| 70 | +plugins = payload["plugins"] |
| 71 | +print(json.dumps(plugins)) |
| 72 | +PY |
| 73 | +) |
| 74 | + echo "plugins=${plugins}" >> "$GITHUB_OUTPUT" |
| 75 | + if [[ "$(JSON_INPUT="$json" python3 - <<'PY' |
| 76 | +import json |
| 77 | +import os |
| 78 | +print(str(json.loads(os.environ["JSON_INPUT"])["has_plugins"]).lower()) |
| 79 | +PY |
| 80 | +)" == "false" ]]; then |
| 81 | + echo "has_plugins=false" >> "$GITHUB_OUTPUT" |
| 82 | + else |
| 83 | + echo "has_plugins=true" >> "$GITHUB_OUTPUT" |
| 84 | + fi |
| 85 | + |
| 86 | + build-test: |
| 87 | + needs: validate-and-detect |
| 88 | + if: needs.validate-and-detect.outputs.has_plugins == 'true' |
| 89 | + strategy: |
| 90 | + fail-fast: false |
| 91 | + matrix: |
| 92 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 93 | + plugin: ${{ fromJson(needs.validate-and-detect.outputs.plugins) }} |
| 94 | + runs-on: ${{ matrix.os }} |
| 95 | + defaults: |
| 96 | + run: |
| 97 | + shell: bash |
| 98 | + working-directory: plugins/rust/python-package/${{ matrix.plugin }} |
| 99 | + steps: |
| 100 | + - uses: actions/checkout@v4 |
| 101 | + |
| 102 | + - uses: actions/setup-python@v5 |
| 103 | + with: |
| 104 | + python-version: "3.12" |
| 105 | + |
| 106 | + - uses: dtolnay/rust-toolchain@stable |
| 107 | + |
| 108 | + - name: Install uv |
| 109 | + run: python -m pip install uv |
| 110 | + |
| 111 | + - name: Sync plugin environment |
| 112 | + run: make sync |
| 113 | + |
| 114 | + - name: Plugin CI verification |
| 115 | + run: make ci |
0 commit comments