|
7 | 7 | push: |
8 | 8 | branches: [main] |
9 | 9 |
|
| 10 | +permissions: |
| 11 | + actions: read |
| 12 | + contents: read |
| 13 | + |
10 | 14 | concurrency: |
11 | 15 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
12 | 16 | cancel-in-progress: true |
13 | 17 |
|
14 | 18 | jobs: |
15 | | - python-ci: |
| 19 | + python-ci-capi: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout ladybug |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + repository: LadybugDB/ladybug |
| 26 | + fetch-depth: 1 |
| 27 | + path: ladybug |
| 28 | + |
| 29 | + - name: Update submodules |
| 30 | + working-directory: ladybug |
| 31 | + run: git submodule update --init --recursive dataset |
| 32 | + |
| 33 | + - name: Checkout ladybug-python into ladybug/tools/python_api |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + fetch-depth: 1 |
| 37 | + path: ladybug/tools/python_api |
| 38 | + |
| 39 | + - name: Setup ccache |
| 40 | + uses: hendrikmuhs/ccache-action@v1.2 |
| 41 | + with: |
| 42 | + key: python-${{ runner.os }}-${{ runner.arch }}-${{ github.ref }} |
| 43 | + max-size: 2G |
| 44 | + create-symlink: true |
| 45 | + restore-keys: | |
| 46 | + python-${{ runner.os }}-${{ runner.arch }}-refs/heads/main |
| 47 | + python-${{ runner.os }}-${{ runner.arch }}- |
| 48 | +
|
| 49 | + - name: Install uv |
| 50 | + uses: astral-sh/setup-uv@v3 |
| 51 | + with: |
| 52 | + version: "latest" |
| 53 | + |
| 54 | + - name: Set up Python |
| 55 | + uses: actions/setup-python@v5 |
| 56 | + with: |
| 57 | + python-version: "3.12" |
| 58 | + |
| 59 | + - name: Install dependencies |
| 60 | + working-directory: ladybug/tools/python_api |
| 61 | + run: | |
| 62 | + uv venv .venv |
| 63 | + uv pip install -e .[dev] |
| 64 | +
|
| 65 | + - name: Resolve compatible lbug artifact run |
| 66 | + working-directory: ladybug |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ github.token }} |
| 69 | + run: | |
| 70 | + SHA="$(git rev-parse HEAD)" |
| 71 | + API_URL="https://api.github.com/repos/LadybugDB/ladybug/actions/workflows/build-and-deploy.yml/runs" |
| 72 | + AUTH_HEADER="Authorization: Bearer $GITHUB_TOKEN" |
| 73 | + ACCEPT_HEADER="Accept: application/vnd.github+json" |
| 74 | + VERSION_HEADER="X-GitHub-Api-Version: 2022-11-28" |
| 75 | +
|
| 76 | + RUN_ID="$( |
| 77 | + curl -fsSL \ |
| 78 | + -H "$AUTH_HEADER" \ |
| 79 | + -H "$ACCEPT_HEADER" \ |
| 80 | + -H "$VERSION_HEADER" \ |
| 81 | + "$API_URL?head_sha=$SHA&status=success&per_page=1" \ |
| 82 | + | python -c 'import json,sys; data=json.load(sys.stdin); runs=data.get("workflow_runs") or []; print(runs[0]["id"] if runs else "")' |
| 83 | + )" |
| 84 | +
|
| 85 | + if [ -z "$RUN_ID" ]; then |
| 86 | + RUN_ID="$( |
| 87 | + curl -fsSL \ |
| 88 | + -H "$AUTH_HEADER" \ |
| 89 | + -H "$ACCEPT_HEADER" \ |
| 90 | + -H "$VERSION_HEADER" \ |
| 91 | + "$API_URL?branch=main&status=success&per_page=1" \ |
| 92 | + | python -c 'import json,sys; data=json.load(sys.stdin); runs=data.get("workflow_runs") or []; print(runs[0]["id"] if runs else "")' |
| 93 | + )" |
| 94 | + fi |
| 95 | +
|
| 96 | + if [ -z "$RUN_ID" ]; then |
| 97 | + echo "Could not find a successful LadybugDB/ladybug build-and-deploy run." >&2 |
| 98 | + exit 1 |
| 99 | + fi |
| 100 | +
|
| 101 | + echo "Using Ladybug build-and-deploy RUN_ID=$RUN_ID for SHA=$SHA" |
| 102 | + echo "LBUG_BUILD_RUN_ID=$RUN_ID" >> "$GITHUB_ENV" |
| 103 | +
|
| 104 | + - name: Download shared lbug library |
| 105 | + working-directory: ladybug/tools/python_api |
| 106 | + env: |
| 107 | + GH_TOKEN: ${{ github.token }} |
| 108 | + run: | |
| 109 | + gh --version |
| 110 | + LBUG_PRECOMPILED_RUN_ID="$LBUG_BUILD_RUN_ID" LBUG_LIB_KIND=shared bash scripts/download_lbug.sh .cache/lbug-capi.env |
| 111 | + cat .cache/lbug-capi.env >> "$GITHUB_ENV" |
| 112 | +
|
| 113 | + - name: Check formatting (black) |
| 114 | + working-directory: ladybug/tools/python_api |
| 115 | + run: | |
| 116 | + uv pip install black |
| 117 | + .venv/bin/black --check src_py test |
| 118 | +
|
| 119 | + - name: Run ruff check |
| 120 | + working-directory: ladybug/tools/python_api |
| 121 | + run: | |
| 122 | + .venv/bin/ruff check src_py test |
| 123 | +
|
| 124 | + - name: Run pytest (C API backend) |
| 125 | + working-directory: ladybug/tools/python_api |
| 126 | + env: |
| 127 | + LBUG_PYTHON_BACKEND: capi |
| 128 | + run: | |
| 129 | + .venv/bin/python -m pytest -vv ./test |
| 130 | +
|
| 131 | + python-ci-pybind: |
16 | 132 | runs-on: ubuntu-latest |
17 | 133 | steps: |
18 | 134 | - name: Checkout ladybug |
@@ -79,8 +195,10 @@ jobs: |
79 | 195 | make python |
80 | 196 | cp tools/python_api/src_py/*.py tools/python_api/build/ladybug/ |
81 | 197 |
|
82 | | - - name: Run pytest |
| 198 | + - name: Run pytest (pybind backend) |
83 | 199 | working-directory: ladybug/tools/python_api |
| 200 | + env: |
| 201 | + LBUG_PYTHON_BACKEND: pybind |
84 | 202 | run: | |
85 | 203 | export PYTHONPATH=./build |
86 | 204 | .venv/bin/python -m pytest -vv ./test |
0 commit comments