diff --git a/.github/workflows/anydoc.yml b/.github/workflows/anydoc.yml new file mode 100644 index 00000000..4c2892c8 --- /dev/null +++ b/.github/workflows/anydoc.yml @@ -0,0 +1,79 @@ +name: Anydoc + +# Compiles the vendored Rust archive, audits it, and exercises the `anydoc` +# build tag. That is minutes of rustc + cargo-audit, so this workflow stays +# off PRs that only touch migrations, frontend, CLI, or unrelated Go packages. + +on: + push: + branches: [main] + paths: + - "third_party/anydoc-go/**" + - "scripts/build-anydoc-lib.sh" + - "internal/infrastructure/docparser/**" + - ".github/workflows/anydoc.yml" + pull_request: + paths: + - "third_party/anydoc-go/**" + - "scripts/build-anydoc-lib.sh" + - "internal/infrastructure/docparser/**" + - ".github/workflows/anydoc.yml" + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +env: + GO_VERSION: "1.26" + GOPROXY: https://proxy.golang.org,direct + +jobs: + anydoc: + name: anydoc parser engine + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-go@v6 + with: + go-version: ${{ env.GO_VERSION }} + cache: true + + - uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo-audit + id: cargo-audit-cache + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/cargo-audit + key: cargo-audit-${{ runner.os }} + + - name: Install cargo-audit + if: steps.cargo-audit-cache.outputs.cache-hit != 'true' + run: cargo install cargo-audit --locked + + # The vendored bindings pull anydoc and its PDF stack from crates.io, and + # WeKnora parses untrusted uploads in-process. A Rust advisory there (as + # in RUSTSEC-2026-0187, an uncatchable abort on a hostile PDF) has to + # break the build, not wait for someone to notice. Vulnerabilities fail + # the job; unmaintained-crate warnings only report, since a transitive + # crate going unmaintained is not something this repo can act on. + - name: Audit the vendored dependency tree + working-directory: third_party/anydoc-go + run: cargo audit + + # The archive is a build artifact, not a committed blob, so CI is what + # keeps the vendored bindings in third_party/anydoc-go compiling. + - name: Build the anydoc static archive + run: ./scripts/build-anydoc-lib.sh + + - name: Vet, test, and build with the engine linked in + run: | + go vet -tags anydoc ./internal/infrastructure/docparser/... + go test -tags anydoc -count=1 ./internal/infrastructure/docparser/... + go build -tags anydoc ./cmd/server diff --git a/.github/workflows/app.yml b/.github/workflows/app.yml index 0c138bc0..c525c7ba 100644 --- a/.github/workflows/app.yml +++ b/.github/workflows/app.yml @@ -1,34 +1,41 @@ name: App +# Anydoc (Rust archive + `anydoc` build tag) lives in anydoc.yml so a +# migrations-only or unrelated Go PR does not compile the parser engine. + on: push: branches: [main] paths: - "**/*.go" - "!cli/**" + - "!client/**" + - "!docreader/**" + - "!third_party/anydoc-go/**" - "go.mod" - "go.sum" - "Makefile" - "config/**" - "migrations/**" - - "scripts/**" - "skills/preloaded/**" + - "testdata/**" - "docker/Dockerfile.app" - - "third_party/anydoc-go/**" - ".github/workflows/app.yml" pull_request: paths: - "**/*.go" - "!cli/**" + - "!client/**" + - "!docreader/**" + - "!third_party/anydoc-go/**" - "go.mod" - "go.sum" - "Makefile" - "config/**" - "migrations/**" - - "scripts/**" - "skills/preloaded/**" + - "testdata/**" - "docker/Dockerfile.app" - - "third_party/anydoc-go/**" - ".github/workflows/app.yml" workflow_dispatch: @@ -98,49 +105,3 @@ jobs: - name: Build server run: go build ./cmd/server - - anydoc: - name: anydoc parser engine - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v6 - - - uses: actions/setup-go@v6 - with: - go-version: ${{ env.GO_VERSION }} - cache: true - - - uses: dtolnay/rust-toolchain@stable - - - name: Cache cargo-audit - id: cargo-audit-cache - uses: actions/cache@v4 - with: - path: ~/.cargo/bin/cargo-audit - key: cargo-audit-${{ runner.os }} - - - name: Install cargo-audit - if: steps.cargo-audit-cache.outputs.cache-hit != 'true' - run: cargo install cargo-audit --locked - - # The vendored bindings pull anydoc and its PDF stack from crates.io, and - # WeKnora parses untrusted uploads in-process. A Rust advisory there (as - # in RUSTSEC-2026-0187, an uncatchable abort on a hostile PDF) has to - # break the build, not wait for someone to notice. Vulnerabilities fail - # the job; unmaintained-crate warnings only report, since a transitive - # crate going unmaintained is not something this repo can act on. - - name: Audit the vendored dependency tree - working-directory: third_party/anydoc-go - run: cargo audit - - # The archive is a build artifact, not a committed blob, so CI is what - # keeps the vendored bindings in third_party/anydoc-go compiling. - - name: Build the anydoc static archive - run: ./scripts/build-anydoc-lib.sh - - - name: Vet, test, and build with the engine linked in - run: | - go vet -tags anydoc ./internal/infrastructure/docparser/... - go test -tags anydoc -count=1 ./internal/infrastructure/docparser/... - go build -tags anydoc ./cmd/server diff --git a/.github/workflows/docreader.yml b/.github/workflows/docreader.yml index 93ece72b..c98c9125 100644 --- a/.github/workflows/docreader.yml +++ b/.github/workflows/docreader.yml @@ -8,7 +8,6 @@ on: - "go.mod" - "go.sum" - "testdata/**" - - "packages/**" - "docker/Dockerfile.docreader" - "docker/Dockerfile.odl-hybrid" - ".github/workflows/docreader.yml" @@ -18,7 +17,6 @@ on: - "go.mod" - "go.sum" - "testdata/**" - - "packages/**" - "docker/Dockerfile.docreader" - "docker/Dockerfile.odl-hybrid" - ".github/workflows/docreader.yml" diff --git a/.github/workflows/go-lint.yml b/.github/workflows/go-lint.yml index 68ae1527..401a7fbb 100644 --- a/.github/workflows/go-lint.yml +++ b/.github/workflows/go-lint.yml @@ -28,14 +28,65 @@ env: GOPROXY: https://proxy.golang.org,direct jobs: + # Path filters above start this workflow for any Go change; the matrix still + # used to lint all three modules. Detect which modules the PR actually + # touches so a root-only change (migrations test, handler, …) does not queue + # cli/ and client/ runners. Changing .golangci.yml or this workflow still + # lints every module, since they share the root config. + changes: + name: detect lint modules + runs-on: ubuntu-latest + outputs: + modules: ${{ steps.detect.outputs.modules }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Detect changed modules + id: detect + shell: bash + run: | + diff_range="${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" + modules=() + if git diff --name-only --diff-filter=ACMR "$diff_range" -- \ + .golangci.yml .github/workflows/go-lint.yml | grep -q .; then + modules=("." "cli" "client") + else + if git diff --name-only --diff-filter=ACMR "$diff_range" -- \ + '*.go' ':!cli/**' ':!client/**' go.mod go.sum | grep -q .; then + modules+=(".") + fi + if git diff --name-only --diff-filter=ACMR "$diff_range" -- 'cli/**' | grep -q .; then + modules+=("cli") + fi + if git diff --name-only --diff-filter=ACMR "$diff_range" -- 'client/**' | grep -q .; then + modules+=("client") + fi + fi + json="[" + first=1 + for m in "${modules[@]}"; do + if [ "$first" -eq 1 ]; then + first=0 + else + json+="," + fi + json+="\"${m}\"" + done + json+="]" + echo "modules=${json}" >> "$GITHUB_OUTPUT" + echo "Lint modules: ${json}" + golangci: name: golangci-lint (${{ matrix.module }}) + needs: changes + if: needs.changes.outputs.modules != '[]' runs-on: ubuntu-latest timeout-minutes: 20 strategy: fail-fast: false matrix: - module: [".", "cli", "client"] + module: ${{ fromJSON(needs.changes.outputs.modules) }} steps: - uses: actions/checkout@v6 with: