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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ labels: [bug]
body:
- type: markdown
attributes:
value: Do not include credentials, proprietary source, or private provider payloads.
value: Search existing issues and PRs first. Use a minimal synthetic example. Remove credentials, proprietary source and private provider payloads from every field and attachment. For a suspected vulnerability, use the private reporting link on the issue chooser.
- type: input
id: version
attributes:
Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ description: Propose a provider-neutral improvement.
title: "[Feature]: "
labels: [enhancement]
body:
- type: markdown
attributes:
value: Search existing issues and PRs first. Describe a synthetic example and how a maintainer can tell that the proposed behavior works. Report suspected vulnerabilities through the private reporting link on the issue chooser.
- type: textarea
id: problem
attributes:
Expand Down
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## Summary

Link the issue and summarize the change. If AI materially assisted the submission, briefly identify its role and who verified the result.

## Validation

For a bug fix, confirm the result for the synthetic case in the linked issue. Identify checks still pending.

- [ ] Applicable validation from `docs/development.md` completed; list commands and results below (`scripts/quality.sh check` for implementation/release work, affected existing contracts and semantic review for documentation-only work)
- [ ] User-visible change has a Towncrier fragment, or this is classified `no-release` with the reason below
- [ ] Examples and fixtures are synthetic
Expand Down
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: 2
updates:
- package-ecosystem: uv
directory: /
target-branch: dev
schedule:
interval: monthly
day: monday
Expand All @@ -17,6 +18,7 @@ updates:
open-pull-requests-limit: 5
- package-ecosystem: github-actions
directory: /
target-branch: dev
schedule:
interval: monthly
day: monday
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/actions-maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ concurrency:
jobs:
cleanup:
name: cleanup-actions-storage
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Build artifacts
on:
workflow_dispatch:
pull_request:
branches: [main]
branches: [main, dev]
types: [opened, synchronize, reopened, edited, ready_for_review, converted_to_draft]

permissions:
contents: read
Expand All @@ -15,6 +16,7 @@ concurrency:
jobs:
classify:
name: classify-documentation
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
Expand Down Expand Up @@ -42,8 +44,11 @@ jobs:
echo "$result" >> "$GITHUB_OUTPUT"

build:
name: build-distributions
name: >-
${{ github.event_name != 'pull_request' && 'manual-build-distributions' ||
github.event.pull_request.draft && 'draft-deferred-build-distributions' || 'build-distributions' }}
needs: classify
if: ${{ !cancelled() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand All @@ -52,10 +57,14 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
if: needs.classify.outputs.docs_only != 'true'
with:
version: "0.13.8"
version: "0.13.10"
require-checksums: true
checksum: bf65ac1a0af10f92c522d91ac096c7c0a39657647b155577e7836c2cbbb4526c
enable-cache: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
save-cache: false
- if: needs.classify.outputs.docs_only != 'true'
run: uv sync --locked
- if: needs.classify.outputs.docs_only != 'true'
Expand Down Expand Up @@ -87,7 +96,9 @@ jobs:
/tmp/sdist-smoke/bin/python -m pip check
(cd /tmp && env -u PYTHONPATH /tmp/sdist-smoke/bin/python -I "${GITHUB_WORKSPACE}/scripts/installed_runtime_smoke.py")
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: needs.classify.outputs.docs_only != 'true'
if: >-
needs.classify.outputs.docs_only != 'true' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
with:
name: distributions
path: dist/
Expand Down
100 changes: 89 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CI

on:
pull_request:
branches: [main, dev]
types: [opened, synchronize, reopened, edited, ready_for_review, converted_to_draft]
workflow_dispatch:

permissions:
Expand Down Expand Up @@ -41,8 +43,11 @@ jobs:
echo "$result" >> "$GITHUB_OUTPUT"

test-python312:
name: test-ubuntu-latest-py3.12
name: >-
${{ github.event_name != 'pull_request' && 'manual-test-ubuntu-latest-py3.12' ||
github.event.pull_request.draft && 'draft-deferred-test-ubuntu-py3.12' || 'test-ubuntu-latest-py3.12' }}
needs: classify
if: ${{ !cancelled() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
runs-on: ubuntu-latest
timeout-minutes: 20
env:
Expand All @@ -53,11 +58,13 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
if: needs.classify.outputs.docs_only != 'true'
with:
version: "0.13.8"
enable-cache: true
version: "0.13.10"
require-checksums: true
checksum: bf65ac1a0af10f92c522d91ac096c7c0a39657647b155577e7836c2cbbb4526c
enable-cache: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
save-cache: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
if: needs.classify.outputs.docs_only != 'true'
Expand All @@ -71,7 +78,10 @@ jobs:

test-matrix:
needs: classify
name: test-${{ matrix.os }}-py${{ matrix.python }}
name: >-
${{ github.event_name != 'pull_request' && format('manual-test-{0}-py{1}', matrix.os, matrix.python) ||
github.event.pull_request.draft && 'draft-deferred-test-matrix' || format('test-{0}-py{1}', matrix.os, matrix.python) }}
if: ${{ !cancelled() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
continue-on-error: ${{ matrix.advisory }}
env:
UV_PYTHON: ${{ matrix.python }}
Expand All @@ -92,11 +102,69 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- name: Install qualified OCR for native coverage
id: native-ocr
if: ${{ needs.classify.outputs.docs_only != 'true' && matrix.coverage }}
env:
PR_BASE: ${{ github.event.pull_request.base.sha }}
shell: bash
run: |
read_native_pin() {
[[ "$1" =~ ^[0-9a-f]{40}$ ]] || return 1
git --no-replace-objects show "$1:compatibility/ocr-support.json" |
jq -er '
.recommended_version as $version |
select($version | type == "string" and test("^[0-9]+\\.[0-9]+\\.[0-9]+$")) |
[.releases[] | select(.version == $version)] |
select(length == 1) | .[0] | select(.status == "tested") |
[.assets[] | select(.name == "opencodereview-linux-amd64")] |
select(length == 1) | .[0] |
select(.sha256 | type == "string" and test("^[0-9a-f]{64}$")) |
select(.size | type == "number" and . == floor and . > 0 and . <= 67108864) |
[$version, .sha256, .size] | @tsv
'
}
if [[ "${GITHUB_EVENT_NAME}" == pull_request ]]; then
pin=$(read_native_pin "${PR_BASE}")
else
pin=$(read_native_pin "${GITHUB_SHA}")
fi
read -r version digest size <<< "${pin}"
umask 077
directory=$(mktemp -d "${RUNNER_TEMP}/ocr-coverage.XXXXXXXX")
name=opencodereview-linux-amd64
binary="${directory}/${name}"
url="https://github.com/alibaba/open-code-review/releases/download/v${version}/${name}"
final_url=$(curl --fail --silent --show-error --location \
--proto '=https' --proto-redir '=https' --connect-timeout 10 --max-time 120 \
--retry 2 --retry-max-time 120 --max-filesize "${size}" --output "${binary}" \
--write-out '%{url_effective}' "${url}")
case "${final_url}" in
https://github.com/*|https://objects.githubusercontent.com/*|https://release-assets.githubusercontent.com/*) ;;
*) echo "Unexpected OCR release asset origin." >&2; exit 1 ;;
esac
test "$(wc -c < "${binary}")" -eq "${size}"
actual_digest=$(sha256sum < "${binary}")
if [[ "${actual_digest%% *}" != "${digest}" ]]; then
echo "OCR release asset digest does not match the reviewed pin." >&2
exit 1
fi
chmod 0500 "${binary}"
printf 'binary=%s\n' "${binary}" >> "${GITHUB_OUTPUT}"
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
if: needs.classify.outputs.docs_only != 'true'
with:
version: "0.13.8"
enable-cache: true
version: "0.13.10"
require-checksums: true
checksum: >-
${{ fromJSON('{
"Linux": {"X64": "bf65ac1a0af10f92c522d91ac096c7c0a39657647b155577e7836c2cbbb4526c"},
"macOS": {
"ARM64": "e419bf07533bdbf48795fc793601c834dd79db57a8c49ce8e25cfe3a8639958d",
"X64": "153e03197588204c04fc4c81cc4bafbfa4280222a385e4ee36a87aeec0ae63b4"
}
}')[runner.os][runner.arch] }}
enable-cache: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
save-cache: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
if: needs.classify.outputs.docs_only != 'true'
Expand All @@ -109,6 +177,9 @@ jobs:
run: uv run --no-sync pytest -q --ignore=tests/test_installed_policy_e2e.py
- name: Test with boundary coverage gates
if: ${{ needs.classify.outputs.docs_only != 'true' && matrix.coverage }}
env:
OCR_FEDERATION_QUALIFY_BINARY: ${{ steps.native-ocr.outputs.binary }}
OCR_GITLINK_QUALIFY_BINARY: ${{ steps.native-ocr.outputs.binary }}
run: |
uv run --no-sync pytest --ignore=tests/test_installed_policy_e2e.py --cov=ocr_toolkit --cov-report=term-missing --cov-fail-under=88
uv run --no-sync coverage report --include=src/ocr_toolkit/ocr_result.py,src/ocr_toolkit/preflight.py --fail-under=85
Expand All @@ -130,19 +201,26 @@ jobs:
done

quality:
name: quality
name: >-
${{ github.event_name != 'pull_request' && 'manual-quality' ||
github.event.pull_request.draft && 'draft-quality' || 'quality' }}
needs: classify
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: needs.classify.outputs.docs_only != 'true'
with:
fetch-depth: 0
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
if: needs.classify.outputs.docs_only != 'true'
with:
version: "0.13.8"
version: "0.13.10"
require-checksums: true
checksum: bf65ac1a0af10f92c522d91ac096c7c0a39657647b155577e7836c2cbbb4526c
enable-cache: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
save-cache: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
if: needs.classify.outputs.docs_only != 'true'
with:
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: CodeQL

on:
pull_request:
branches: [main]
branches: [main, dev]
types: [opened, synchronize, reopened, edited, ready_for_review, converted_to_draft]
schedule:
- cron: "29 3 * * 2"
workflow_dispatch:
Expand All @@ -16,9 +17,15 @@ concurrency:

jobs:
analyze:
name: analyze-python
if: github.event.repository.private == false
name: >-
${{ github.event_name != 'pull_request' && 'non-pr-analyze-python' ||
github.event.pull_request.draft && 'draft-deferred-analyze-python' || 'analyze-python' }}
if: >-
github.event.repository.private == false &&
(github.event_name != 'pull_request' || !github.event.pull_request.draft) &&
(github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
timeout-minutes: 20
env:
# CodeQL v4 controls overlay database caching separately from TRAP caching.
# A full database is cheap for this repository and avoids per-run overlay caches.
Expand All @@ -30,8 +37,11 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
- uses: github/codeql-action/init@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
languages: python
trap-caching: false
- uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
- uses: github/codeql-action/analyze@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
upload: always
upload-database: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
7 changes: 5 additions & 2 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Dependency review

on:
pull_request:
branches: [main, dev]
types: [opened, synchronize, reopened, edited, ready_for_review, converted_to_draft]

permissions:
contents: read
Expand All @@ -12,13 +14,14 @@ concurrency:

jobs:
review:
name: dependency-review
name: ${{ github.event.pull_request.draft && 'draft-dependency-review' || 'dependency-review' }}
if: github.event.repository.private == false
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
- uses: actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec # v5.0.1
with:
fail-on-severity: moderate
Loading