Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
35 changes: 32 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -50,15 +52,38 @@ 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: |
version=$(cargo metadata --no-deps --locked --format-version 1 \
| 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
Expand All @@ -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
Expand All @@ -92,6 +119,7 @@ jobs:
with:
name: wheels-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.manylinux || 'native' }}
path: dist
retention-days: 7

sdist:
needs: checks
Expand All @@ -107,6 +135,7 @@ jobs:
with:
name: sdist
path: dist
retention-days: 7

publish:
needs: [release-please, wheels, sdist]
Expand Down
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
13 changes: 9 additions & 4 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading