diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62b05c2..01b0318 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,11 @@ on: branches: [main] pull_request: +# A new push to a PR cancels its older run; every push to main runs. +concurrency: + group: ci-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} + cancel-in-progress: true + jobs: test: runs-on: ubuntu-latest @@ -15,6 +20,13 @@ jobs: toolchain: "1.98.0" components: clippy, rustfmt - uses: astral-sh/setup-uv@v6 + with: + cache-dependency-glob: tests/fixtures/uv.lock + # One cache for this job and release.yml's `checks`, saved only from main: a cache per + # branch fills the repository's 10 GB cache quota. - uses: Swatinem/rust-cache@v2 + with: + shared-key: test + save-if: ${{ github.ref == 'refs/heads/main' }} - run: cargo clippy --workspace --all-targets --locked -- -D warnings - - run: cargo test --workspace --locked + - run: cargo test --workspace --locked --profile ci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 38bcff9..d5d2aa0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,9 @@ # (after approval in the `pypi` environment) and attaches them to the GitHub release. # Everything stays in this one workflow: tags made with GITHUB_TOKEN don't trigger other # workflows, and PyPI trusts this file by name. -# Pull requests that touch packaging build the wheels without publishing; so does a manual run. +# Pull requests that touch packaging build and smoke-test one Linux wheel, uploading nothing +# (ci.yml runs the tests). A manual run tests and builds every wheel without publishing. +# Artifacts live 7 days: long enough for the `pypi` approval, short enough for the storage quota. name: Release on: @@ -41,7 +43,7 @@ jobs: checks: needs: release-please - if: ${{ !cancelled() && (needs.release-please.outputs.created == 'true' || github.event_name != 'push') }} + if: ${{ !cancelled() && (needs.release-please.outputs.created == 'true' || github.event_name == 'workflow_dispatch') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -50,7 +52,14 @@ jobs: toolchain: "1.98.0" components: clippy - uses: astral-sh/setup-uv@v6 + with: + cache-dependency-glob: tests/fixtures/uv.lock + save-cache: false + # ci.yml's cache; ci.yml saves it. - uses: Swatinem/rust-cache@v2 + with: + shared-key: test + save-if: false - name: Tag matches the workspace version if: needs.release-please.outputs.created == 'true' run: | @@ -58,7 +67,23 @@ jobs: | jq -r '.packages[] | select(.name == "hydroid") | .version') test "v$version" = "${{ needs.release-please.outputs.tag }}" - run: cargo clippy --workspace --all-targets --locked -- -D warnings - - run: cargo test --workspace --locked + - run: cargo test --workspace --locked --profile ci + + wheel-smoke: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: PyO3/maturin-action@v1 + with: + target: x86_64 + manylinux: auto + args: --release --locked --out dist + - uses: astral-sh/setup-uv@v6 + with: + enable-cache: false + - name: Smoke test the wheel + run: uvx --no-index --find-links dist --from hydroid-cli hydroid --version wheels: needs: checks @@ -84,6 +109,8 @@ jobs: args: --release --locked --out dist - if: matrix.smoke uses: astral-sh/setup-uv@v6 + with: + enable-cache: false - name: Smoke test the wheel if: matrix.smoke shell: bash @@ -92,6 +119,7 @@ jobs: with: name: wheels-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.manylinux || 'native' }} path: dist + retention-days: 7 sdist: needs: checks @@ -107,6 +135,7 @@ jobs: with: name: sdist path: dist + retention-days: 7 publish: needs: [release-please, wheels, sdist] diff --git a/Cargo.toml b/Cargo.toml index 6ed1e89..88b9fac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,3 +47,12 @@ inherits = "release" lto = false codegen-units = 16 incremental = true + +# CI tests (`--profile ci`): ty is far too slow unoptimized, so dependencies are optimized while +# the workspace keeps fast builds and debug assertions. Less debug info keeps `target/` small. +[profile.ci] +inherits = "dev" +debug = "line-tables-only" + +[profile.ci.package."*"] +opt-level = 2 diff --git a/README.md b/README.md index 0b38e96..b22ca57 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,7 @@ method, so the real implementation can be missed. What hydroid knowingly misses, ```sh cargo test --workspace # needs `uv`; syncs tests/fixtures/.venv from uv.lock +cargo test --workspace --profile ci # what CI runs: optimized deps, much faster tests scripts/corpus.sh [names] # Polar, mealie, lnbits, dispatch, litellm, open-webui, template ``` diff --git a/docs/RELEASING.md b/docs/RELEASING.md index b0b404e..ab02e8a 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -16,13 +16,18 @@ to PyPI as `hydroid-cli` by `.github/workflows/release.yml`. clippy and the tests, builds the wheels and the sdist, waits for approval in the `pypi` environment, publishes to PyPI and attaches the files to the GitHub release. -The release PR is created with `GITHUB_TOKEN`, so CI does not run on it; the release run -repeats clippy and the tests before anything is published. +CI runs clippy and the tests on every PR, the release PR too. The release PR is opened with +`GITHUB_TOKEN`, so its CI waits until you select **Approve workflows to run** on it. The release +run repeats clippy and the tests on the tagged commit before anything is published. + +Approve the `pypi` deployment within 7 days of the release run: the wheels and the sdist expire +7 days after upload, and the publish jobs then fail. ## Dry run -Run the **Release** workflow by hand (Actions → Release → Run workflow), or open a PR that -touches packaging: it builds and smoke-tests every wheel without publishing. +Run the **Release** workflow by hand (Actions → Release → Run workflow): it runs the tests and +builds every wheel and the sdist without publishing. A PR that touches packaging builds and +smoke-tests only the Linux x86_64 wheel, and uploads nothing. ## Setup (done once)