From 57a8adc750a149e437fc3fc0ab9d0aad7abd2aa2 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Mon, 8 Jul 2024 14:34:32 -0600 Subject: [PATCH] Improve pool and Rust CI --- .github/Makefile | 4 + .github/workflows.src/tests-pool.targets.yml | 1 + .github/workflows.src/tests-pool.tpl.yml | 50 +++ .github/workflows.src/tests.inc.yml | 6 +- .github/workflows/test-pool.yml | 72 ---- .github/workflows/tests-ha.yml | 6 +- .github/workflows/tests-managed-pg.yml | 14 +- .github/workflows/tests-patches.yml | 6 +- .github/workflows/tests-pg-versions.yml | 6 +- .github/workflows/tests-pool.yml | 358 +++++++++++++++++++ .github/workflows/tests.yml | 8 +- setup.py | 19 +- 12 files changed, 447 insertions(+), 103 deletions(-) create mode 100644 .github/workflows.src/tests-pool.targets.yml create mode 100644 .github/workflows.src/tests-pool.tpl.yml delete mode 100644 .github/workflows/test-pool.yml create mode 100644 .github/workflows/tests-pool.yml diff --git a/.github/Makefile b/.github/Makefile index e494748be53d..83f48c74d483 100644 --- a/.github/Makefile +++ b/.github/Makefile @@ -8,6 +8,7 @@ all: workflows/nightly.yml \ workflows/dryrun.yml \ workflows/ls-nightly.yml \ workflows/tests.yml \ + workflows/tests-pool.yml \ workflows/tests-managed-pg.yml \ workflows/tests-ha.yml \ workflows/tests-pg-versions.yml \ @@ -19,6 +20,9 @@ workflows/%.yml: workflows.src/%.tpl.yml workflows.src/%.targets.yml workflows.s workflows.src/tests.tpl.yml: workflows.src/tests.inc.yml touch $(ROOT)/workflows.src/tests.tpl.yml +workflows.src/tests-pool.tpl.yml: workflows.src/tests.inc.yml + touch $(ROOT)/workflows.src/tests-pool.tpl.yml + workflows.src/tests-managed-pg.tpl.yml: workflows.src/tests.inc.yml touch $(ROOT)/workflows.src/tests-managed-pg.tpl.yml diff --git a/.github/workflows.src/tests-pool.targets.yml b/.github/workflows.src/tests-pool.targets.yml new file mode 100644 index 000000000000..99d4a714ac79 --- /dev/null +++ b/.github/workflows.src/tests-pool.targets.yml @@ -0,0 +1 @@ +data: diff --git a/.github/workflows.src/tests-pool.tpl.yml b/.github/workflows.src/tests-pool.tpl.yml new file mode 100644 index 000000000000..f6456d5ff023 --- /dev/null +++ b/.github/workflows.src/tests-pool.tpl.yml @@ -0,0 +1,50 @@ +<% from "tests.inc.yml" import build, calc_cache_key -%> + +name: Pool Simulation Test + +on: + push: + branches: + - master + - pool-test + paths: + - 'edb/server/connpool/**' + - 'edb/server/conn_pool/**' + - 'tests/test_server_pool.py' + - '.github/workflows/tests-pool.yml' + pull_request: + branches: + - master + paths: + - 'edb/server/connpool/**' + - 'edb/server/conn_pool/**' + - 'tests/test_server_pool.py' + - '.github/workflows/tests-pool.yml' + +jobs: + test: + runs-on: ubuntu-latest + concurrency: pool-test + steps: + <%- call build() -%> + - name: Compute cache keys + run: | + << calc_cache_key()|indent >> + <%- endcall %> + + - name: Run the pool simulation test + env: + PYTHONPATH: . + SIMULATION_CI: yes + TIME_SCALE: 10 + run: | + python tests/test_server_pool.py + + - uses: EndBug/add-and-commit@v7.0.0 + if: ${{ always() }} + continue-on-error: true + with: + branch: main + cwd: pool-simulation + author_name: github-actions + author_email: 41898282+github-actions[bot]@users.noreply.github.com \ No newline at end of file diff --git a/.github/workflows.src/tests.inc.yml b/.github/workflows.src/tests.inc.yml index 64ed19f077e9..14b8de83c269 100644 --- a/.github/workflows.src/tests.inc.yml +++ b/.github/workflows.src/tests.inc.yml @@ -80,9 +80,9 @@ id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} restore-keys: | - edb-rust-v3- + edb-rust-v4- - name: Handle cached Cython extensions uses: actions/cache@v4 @@ -368,7 +368,7 @@ id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 diff --git a/.github/workflows/test-pool.yml b/.github/workflows/test-pool.yml deleted file mode 100644 index bd2ae256adfe..000000000000 --- a/.github/workflows/test-pool.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Pool Simulation Test - -on: - push: - branches: - - master - - pool-test - paths: - - 'edb/server/connpool/**' - - 'tests/test_server_pool.py' - - '.github/workflows/test-pool.yml' - pull_request: - branches: - - master - paths: - - 'edb/server/connpool/**' - - 'tests/test_server_pool.py' - - '.github/workflows/test-pool.yml' - -jobs: - test: - runs-on: ubuntu-latest - concurrency: pool-test - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: false - - - uses: actions/checkout@v4 - if: startsWith(github.ref, 'refs/heads') - with: - repository: edgedb/edgedb-pool-simulation - path: pool-simulation - token: ${{ secrets.GITHUB_CI_BOT_TOKEN }} - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.12.2' - - - name: Generate requirements.txt - run: | - echo 'uvloop==0.19.0' > requirements.txt - mkdir -p pool-simulation/reports - - - name: Handle virtualenv - uses: syphar/restore-virtualenv@v1.1 - id: venv-cache - - - name: Install Python dependencies - if: steps.venv-cache.outputs.cache-hit != 'true' - run: | - pip install -r requirements.txt - - - name: Run the pool simulation test - env: - PYTHONPATH: . - SIMULATION_CI: yes - TIME_SCALE: 10 - run: | - python tests/test_server_pool.py - - - uses: EndBug/add-and-commit@v7.0.0 - if: ${{ always() }} - continue-on-error: true - with: - branch: main - cwd: pool-simulation - author_name: github-actions - author_email: 41898282+github-actions[bot]@users.noreply.github.com diff --git a/.github/workflows/tests-ha.yml b/.github/workflows/tests-ha.yml index 90770bdc80fe..9b2cacdd2105 100644 --- a/.github/workflows/tests-ha.yml +++ b/.github/workflows/tests-ha.yml @@ -121,9 +121,9 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} restore-keys: | - edb-rust-v3- + edb-rust-v4- - name: Handle cached Cython extensions uses: actions/cache@v4 @@ -422,7 +422,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 diff --git a/.github/workflows/tests-managed-pg.yml b/.github/workflows/tests-managed-pg.yml index fe6f25898073..eb935fe8493d 100644 --- a/.github/workflows/tests-managed-pg.yml +++ b/.github/workflows/tests-managed-pg.yml @@ -106,9 +106,9 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} restore-keys: | - edb-rust-v3- + edb-rust-v4- - name: Handle cached Cython extensions uses: actions/cache@v4 @@ -453,7 +453,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 @@ -681,7 +681,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 @@ -957,7 +957,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 @@ -1199,7 +1199,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 @@ -1429,7 +1429,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 diff --git a/.github/workflows/tests-patches.yml b/.github/workflows/tests-patches.yml index 6564c9b931f5..ba0d3c2943ec 100644 --- a/.github/workflows/tests-patches.yml +++ b/.github/workflows/tests-patches.yml @@ -108,9 +108,9 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} restore-keys: | - edb-rust-v3- + edb-rust-v4- - name: Handle cached Cython extensions uses: actions/cache@v4 @@ -422,7 +422,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 diff --git a/.github/workflows/tests-pg-versions.yml b/.github/workflows/tests-pg-versions.yml index 4ad826b2fae3..78aec09e589b 100644 --- a/.github/workflows/tests-pg-versions.yml +++ b/.github/workflows/tests-pg-versions.yml @@ -106,9 +106,9 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} restore-keys: | - edb-rust-v3- + edb-rust-v4- - name: Handle cached Cython extensions uses: actions/cache@v4 @@ -446,7 +446,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 diff --git a/.github/workflows/tests-pool.yml b/.github/workflows/tests-pool.yml new file mode 100644 index 000000000000..15e4cc82ff84 --- /dev/null +++ b/.github/workflows/tests-pool.yml @@ -0,0 +1,358 @@ +name: Pool Simulation Test + +on: + push: + branches: + - master + - pool-test + paths: + - 'edb/server/connpool/**' + - 'edb/server/conn_pool/**' + - 'tests/test_server_pool.py' + - '.github/workflows/tests-pool.yml' + pull_request: + branches: + - master + paths: + - 'edb/server/connpool/**' + - 'edb/server/conn_pool/**' + - 'tests/test_server_pool.py' + - '.github/workflows/tests-pool.yml' + +jobs: + test: + runs-on: ubuntu-latest + concurrency: pool-test + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: false + + - uses: actions/checkout@v4 + with: + fetch-depth: 50 + submodules: true + + - name: Set up Python + uses: actions/setup-python@v5 + id: setup-python + with: + python-version: '3.12.2' + cache: 'pip' + cache-dependency-path: | + pyproject.toml + + # The below is technically a lie as we are technically not + # inside a virtual env, but there is really no reason to bother + # actually creating and activating one as below works just fine. + - name: Export $VIRTUAL_ENV + run: | + venv="$(python -c 'import sys; sys.stdout.write(sys.prefix)')" + echo "VIRTUAL_ENV=${venv}" >> $GITHUB_ENV + + - name: Set up uv cache + uses: actions/cache@v4 + with: + path: ~/.cache/uv + key: uv-cache-${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }} + + - name: Cached requirements.txt + uses: actions/cache@v4 + id: requirements-cache + with: + path: requirements.txt + key: edb-requirements-${{ hashFiles('pyproject.toml') }} + + - name: Compute requirements.txt + if: steps.requirements-cache.outputs.cache-hit != 'true' + run: | + python -m pip install pip-tools + pip-compile --no-strip-extras --all-build-deps \ + --extra test,language-server \ + --output-file requirements.txt pyproject.toml + + - name: Install Python dependencies + run: | + python -c "import sys; print(sys.prefix)" + python -m pip install uv~=0.1.0 && uv pip install -U -r requirements.txt + + - name: Compute cache keys + run: | + mkdir -p .tmp + python setup.py -q ci_helper --type cli > .tmp/edgedbcli_git_rev.txt + python setup.py -q ci_helper --type rust >.tmp/rust_cache_key.txt + python setup.py -q ci_helper --type ext >.tmp/ext_cache_key.txt + python setup.py -q ci_helper --type parsers >.tmp/parsers_cache_key.txt + python setup.py -q ci_helper --type postgres >.tmp/postgres_git_rev.txt + python setup.py -q ci_helper --type libpg_query >.tmp/libpg_query_git_rev.txt + echo 'f8cd94309eaccbfba5dea7835b88c78377608a37' >.tmp/stolon_git_rev.txt + python setup.py -q ci_helper --type bootstrap >.tmp/bootstrap_cache_key.txt + echo EDGEDBCLI_GIT_REV=$(cat .tmp/edgedbcli_git_rev.txt) >> $GITHUB_ENV + echo POSTGRES_GIT_REV=$(cat .tmp/postgres_git_rev.txt) >> $GITHUB_ENV + echo LIBPG_QUERY_GIT_REV=$(cat .tmp/libpg_query_git_rev.txt) >> $GITHUB_ENV + echo STOLON_GIT_REV=$(cat .tmp/stolon_git_rev.txt) >> $GITHUB_ENV + echo BUILD_LIB=$(python setup.py -q ci_helper --type build_lib) >> $GITHUB_ENV + echo BUILD_TEMP=$(python setup.py -q ci_helper --type build_temp) >> $GITHUB_ENV + + - name: Upload shared artifacts + uses: actions/upload-artifact@v4 + with: + name: shared-artifacts + path: .tmp + retention-days: 1 + + # Restore binary cache + + - name: Handle cached EdgeDB CLI binaries + uses: actions/cache@v4 + id: cli-cache + with: + path: build/cli + key: edb-cli-v3-${{ env.EDGEDBCLI_GIT_REV }} + + - name: Handle cached Rust extensions + uses: actions/cache@v4 + id: rust-cache + with: + path: build/rust_extensions + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} + restore-keys: | + edb-rust-v4- + + - name: Handle cached Cython extensions + uses: actions/cache@v4 + id: ext-cache + with: + path: build/extensions + key: edb-ext-v5-${{ hashFiles('.tmp/ext_cache_key.txt') }} + + - name: Handle cached PostgreSQL build + uses: actions/cache@v4 + id: postgres-cache + with: + path: build/postgres/install + key: edb-postgres-v2-${{ env.POSTGRES_GIT_REV }} + + - name: Handle cached Stolon build + uses: actions/cache@v4 + id: stolon-cache + with: + path: build/stolon/bin + key: edb-stolon-v2-${{ env.STOLON_GIT_REV }} + + - name: Handle cached libpg_query build + uses: actions/cache@v4 + id: libpg-query-cache + with: + path: edb/pgsql/parser/libpg_query/libpg_query.a + key: edb-libpg_query-v1-${{ env.LIBPG_QUERY_GIT_REV }} + + # Install system dependencies for building + + - name: Install system deps + if: | + steps.cli-cache.outputs.cache-hit != 'true' || + steps.rust-cache.outputs.cache-hit != 'true' || + steps.ext-cache.outputs.cache-hit != 'true' || + steps.stolon-cache.outputs.cache-hit != 'true' || + steps.postgres-cache.outputs.cache-hit != 'true' + run: | + sudo apt-get update + sudo apt-get install -y uuid-dev libreadline-dev bison flex + + - name: Install rust toolchain + if: | + steps.cli-cache.outputs.cache-hit != 'true' || + steps.rust-cache.outputs.cache-hit != 'true' + uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 + with: + components: "cargo,rustc,rust-std" + toolchain: "stable" + + # Build EdgeDB CLI + + - name: Handle EdgeDB CLI build cache + uses: actions/cache@v4 + if: steps.cli-cache.outputs.cache-hit != 'true' + with: + path: ${{ env.BUILD_TEMP }}/rust/cli + key: edb-cli-build-v7-${{ env.EDGEDBCLI_GIT_REV }} + restore-keys: | + edb-cli-build-v7- + + - name: Build EdgeDB CLI + env: + CARGO_HOME: ${{ env.BUILD_TEMP }}/rust/cli/cargo_home + CACHE_HIT: ${{ steps.cli-cache.outputs.cache-hit }} + run: | + if [[ "$CACHE_HIT" == "true" ]]; then + cp -v build/cli/bin/edgedb edb/cli/edgedb + else + python setup.py -v build_cli + fi + + # Build Rust extensions + + - name: Handle Rust extensions build cache + uses: actions/cache@v4 + if: steps.rust-cache.outputs.cache-hit != 'true' + with: + path: ${{ env.BUILD_TEMP }}/rust/extensions + key: edb-rust-build-v1-${{ hashFiles('.tmp/rust_cache_key.txt') }} + restore-keys: | + edb-rust-build-v1- + + - name: Build Rust extensions + env: + CARGO_HOME: ${{ env.BUILD_TEMP }}/rust/extensions/cargo_home + CACHE_HIT: ${{ steps.rust-cache.outputs.cache-hit }} + run: | + if [[ "$CACHE_HIT" != "true" ]]; then + rm -rf ${BUILD_LIB} + mkdir -p build/rust_extensions + rsync -av ./build/rust_extensions/ ${BUILD_LIB}/ + python setup.py -v build_rust + rsync -av ${BUILD_LIB}/ build/rust_extensions/ + rm -rf ${BUILD_LIB} + fi + rsync -av ./build/rust_extensions/edb/ ./edb/ + + # Build libpg_query + + - name: Build libpg_query + if: | + steps.libpg-query-cache.outputs.cache-hit != 'true' && + steps.ext-cache.outputs.cache-hit != 'true' + run: | + python setup.py build_libpg_query + + # Build extensions + + - name: Handle Cython extensions build cache + uses: actions/cache@v4 + if: steps.ext-cache.outputs.cache-hit != 'true' + with: + path: ${{ env.BUILD_TEMP }}/edb + key: edb-ext-build-v3-${{ hashFiles('.tmp/ext_cache_key.txt') }} + + - name: Build Cython extensions + env: + CACHE_HIT: ${{ steps.ext-cache.outputs.cache-hit }} + BUILD_EXT_MODE: py-only + run: | + if [[ "$CACHE_HIT" != "true" ]]; then + rm -rf ${BUILD_LIB} + mkdir -p ./build/extensions + rsync -av ./build/extensions/ ${BUILD_LIB}/ + BUILD_EXT_MODE=py-only python setup.py -v build_ext + rsync -av ${BUILD_LIB}/ ./build/extensions/ + rm -rf ${BUILD_LIB} + fi + rsync -av ./build/extensions/edb/ ./edb/ + + # Build parsers + + - name: Handle compiled parsers cache + uses: actions/cache@v4 + id: parsers-cache + with: + path: build/lib + key: edb-parsers-v3-${{ hashFiles('.tmp/parsers_cache_key.txt') }} + restore-keys: | + edb-parsers-v3- + + - name: Build parsers + env: + CACHE_HIT: ${{ steps.parsers-cache.outputs.cache-hit }} + run: | + if [[ "$CACHE_HIT" != "true" ]]; then + rm -rf ${BUILD_LIB} + mkdir -p ./build/lib + rsync -av ./build/lib/ ${BUILD_LIB}/ + python setup.py -v build_parsers + rsync -av ${BUILD_LIB}/ ./build/lib/ + rm -rf ${BUILD_LIB} + fi + rsync -av ./build/lib/edb/ ./edb/ + + # Build PostgreSQL + + - name: Build PostgreSQL + env: + CACHE_HIT: ${{ steps.postgres-cache.outputs.cache-hit }} + run: | + if [[ "$CACHE_HIT" == "true" ]]; then + cp build/postgres/install/stamp build/postgres/ + else + python setup.py build_postgres + cp build/postgres/stamp build/postgres/install/ + fi + + # Build Stolon + + - name: Set up Go + if: steps.stolon-cache.outputs.cache-hit != 'true' + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - uses: actions/checkout@v4 + if: steps.stolon-cache.outputs.cache-hit != 'true' + with: + repository: edgedb/stolon + path: build/stolon + ref: ${{ env.STOLON_GIT_REV }} + fetch-depth: 0 + submodules: false + + - name: Build Stolon + if: steps.stolon-cache.outputs.cache-hit != 'true' + run: | + mkdir -p build/stolon/bin/ + curl -fsSL https://releases.hashicorp.com/consul/1.10.1/consul_1.10.1_linux_amd64.zip | zcat > build/stolon/bin/consul + chmod +x build/stolon/bin/consul + cd build/stolon && make + + # Install edgedb-server and populate egg-info + + - name: Install edgedb-server + env: + BUILD_EXT_MODE: skip + run: | + # --no-build-isolation because we have explicitly installed all deps + # and don't want them to be reinstalled in an "isolated env". + pip install --no-build-isolation --no-deps -e .[test,docs] + + # Refresh the bootstrap cache + + - name: Handle bootstrap cache + uses: actions/cache@v4 + id: bootstrap-cache + with: + path: build/cache + key: edb-bootstrap-v2-${{ hashFiles('.tmp/bootstrap_cache_key.txt') }} + restore-keys: | + edb-bootstrap-v2- + + - name: Bootstrap EdgeDB Server + if: steps.bootstrap-cache.outputs.cache-hit != 'true' + run: | + edb server --bootstrap-only + + - name: Run the pool simulation test + env: + PYTHONPATH: . + SIMULATION_CI: yes + TIME_SCALE: 10 + run: | + python tests/test_server_pool.py + + - uses: EndBug/add-and-commit@v7.0.0 + if: ${{ always() }} + continue-on-error: true + with: + branch: main + cwd: pool-simulation + author_name: github-actions + author_email: 41898282+github-actions[bot]@users.noreply.github.com diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5397155f30d7..71747b1db0c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -118,9 +118,9 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} restore-keys: | - edb-rust-v3- + edb-rust-v4- - name: Handle cached Cython extensions uses: actions/cache@v4 @@ -505,7 +505,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 @@ -667,7 +667,7 @@ jobs: id: rust-cache with: path: build/rust_extensions - key: edb-rust-v3-${{ hashFiles('.tmp/rust_cache_key.txt') }} + key: edb-rust-v4-${{ hashFiles('.tmp/rust_cache_key.txt') }} - name: Restore cached Cython extensions uses: actions/cache@v4 diff --git a/setup.py b/setup.py index 60ac4cea557b..a5fd3d394450 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ import shutil import subprocess import textwrap +import tomllib import setuptools from setuptools import extension as setuptools_extension @@ -562,14 +563,16 @@ def run(self): print(binascii.hexlify(bootstrap_hash).decode()) elif self.type == 'rust': - rust_hash = hash_dirs([ - (pkg_dir / 'edgeql-parser', '.rs'), - (pkg_dir / 'graphql-rewrite', '.rs'), - ], extra_files=[ - pkg_dir / 'edgeql-parser/Cargo.toml', - pkg_dir / 'edgeql-parser/edgeql-parser-python/Cargo.toml', - pkg_dir / 'graphql-rewrite/Cargo.toml', - ]) + dirs = [] + # Read the list of Rust projects from Cargo.toml + with open(pkg_dir.parent / 'Cargo.toml', 'rb') as f: + root = tomllib.load(f) + for member in root['workspace']['members']: + dirs.append(pkg_dir.parent / member) + rust_hash = hash_dirs( + [(dir, '.rs') for dir in dirs], + extra_files=[dir / 'Cargo.toml' for dir in dirs] + + [pkg_dir.parent / 'Cargo.lock']) print(binascii.hexlify(rust_hash).decode()) elif self.type == 'ext':