Merge pull request #89 from relateby/release/v0.6.0 #303
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| permissions: | |
| contents: read | |
| jobs: | |
| workflow-validation: | |
| name: Workflow Validation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: rhysd/actionlint@v1.7.11 | |
| rust-validation: | |
| name: Rust Validation | |
| runs-on: ubuntu-latest | |
| if: "${{ github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'release: prepare v') }}" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Format | |
| run: cargo fmt --all -- --check | |
| - name: Lint | |
| run: cargo clippy --workspace --exclude pattern-wasm -- -D warnings | |
| - name: Build | |
| run: cargo build --workspace --exclude pattern-wasm | |
| - name: Test | |
| run: cargo test --workspace --exclude pattern-wasm | |
| - name: Docs | |
| run: cargo doc --no-deps -p relateby-pattern -p relateby-gram | |
| - name: Cargo publish dry-run | |
| run: | | |
| VERSION="$(python - <<'PY' | |
| import re | |
| from pathlib import Path | |
| cargo_toml = Path("Cargo.toml").read_text(encoding="utf-8") | |
| match = re.search(r'^\[workspace\.package\]\n(?:.*\n)*?version = "([^"]+)"', cargo_toml, re.M) | |
| if not match: | |
| raise SystemExit("workspace version not found") | |
| print(match.group(1)) | |
| PY | |
| )" | |
| cargo publish -p relateby-pattern --dry-run --allow-dirty | |
| if python - "$VERSION" <<'PY' | |
| import json | |
| import sys | |
| import urllib.error | |
| import urllib.request | |
| version = sys.argv[1] | |
| try: | |
| with urllib.request.urlopen("https://crates.io/api/v1/crates/relateby-pattern") as response: | |
| payload = json.load(response) | |
| except urllib.error.URLError: | |
| raise SystemExit(1) | |
| versions = {item["num"] for item in payload.get("versions", [])} | |
| raise SystemExit(0 if version in versions else 1) | |
| PY | |
| then | |
| cargo publish -p relateby-gram --dry-run --allow-dirty | |
| else | |
| echo "relateby-pattern ${VERSION} is not yet on crates.io; using cargo package --list fallback for relateby-gram" | |
| cargo package -p relateby-gram --allow-dirty --list >/dev/null | |
| fi | |
| wasm-validation: | |
| name: WASM Validation | |
| runs-on: ubuntu-latest | |
| if: "${{ github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'release: prepare v') }}" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-wasm-${{ hashFiles('**/Cargo.lock') }} | |
| - run: cargo build --target wasm32-unknown-unknown -p relateby-pattern -p relateby-gram -p pattern-wasm | |
| npm-validation: | |
| name: npm Validation | |
| runs-on: ubuntu-latest | |
| if: "${{ github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'release: prepare v') }}" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-wasm-ts-${{ hashFiles('**/Cargo.lock') }} | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build npm packages | |
| run: | | |
| npm run build --workspace=@relateby/pattern | |
| npm run build --workspace=@relateby/graph | |
| npm run build --workspace=@relateby/gram | |
| - name: Test npm packages | |
| run: | | |
| npm run test --workspace=@relateby/pattern | |
| npm run test --workspace=@relateby/graph | |
| npm run test --workspace=@relateby/gram | |
| - name: Verify @relateby/pattern public exports | |
| run: npm run test:public-api --workspace=@relateby/pattern | |
| - name: Typecheck @relateby/pattern public consumer | |
| run: npm run test:public-api:types --workspace=@relateby/pattern | |
| - name: Pack npm artifacts | |
| run: | | |
| mkdir -p target/npm-packages | |
| npm run pack:release --workspace=@relateby/pattern | |
| npm run pack:release --workspace=@relateby/graph | |
| npm run pack:release --workspace=@relateby/gram | |
| - name: Smoke-test packed npm artifact | |
| run: | | |
| cd ./scripts/release/npm-smoke | |
| npm install | |
| npm run smoke | |
| interop-validation: | |
| name: Cross-language Interop | |
| runs-on: ubuntu-latest | |
| if: "${{ github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'release: prepare v') }}" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - uses: astral-sh/setup-uv@v6 | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-interop-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install build tooling | |
| run: pip install maturin | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack | |
| - name: Install npm dependencies | |
| run: npm ci | |
| - name: Build TypeScript (WASM + JS) | |
| run: | | |
| npm run build --workspace=@relateby/pattern | |
| npm run build --workspace=@relateby/gram | |
| - name: Build and install Python wheel | |
| run: | | |
| cd python/packages/relateby | |
| python -m pip wheel . -w dist --no-deps | |
| pip install dist/*.whl | |
| - name: Cross-language interop test | |
| run: ./tests/interop/run.sh | |
| python-validation: | |
| name: Python Validation | |
| runs-on: ubuntu-latest | |
| if: "${{ github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'release: prepare v') }}" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - uses: astral-sh/setup-uv@v6 | |
| - name: Install build tooling | |
| run: pip install maturin pytest twine | |
| - name: Resolve Python package directory | |
| run: echo "PY_PACKAGE_DIR=python/packages/relateby" >> "$GITHUB_ENV" | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-python-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Validate Python public API stubs | |
| run: python -m pytest "$PY_PACKAGE_DIR/tests/test_public_api.py" | |
| - name: Build combined wheel | |
| run: | | |
| cd "$PY_PACKAGE_DIR" | |
| python -m pip wheel . -w dist --no-deps | |
| - name: Check wheel metadata | |
| run: twine check "$PY_PACKAGE_DIR"/dist/* | |
| - name: Smoke-test combined wheel | |
| run: bash ./scripts/release/smoke-python.sh --wheel ./"$PY_PACKAGE_DIR"/dist/*.whl |