From 6e123ed9f4bdb88fca8a1220309d49038ae1f2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C4=B0rgin?= Date: Mon, 16 Nov 2026 00:42:07 +0300 Subject: [PATCH] ci: post test results to BadgeSmith and show test badges --- .github/workflows/ci.yml | 66 +++++++++++++++++++++++++++++++ README.md | 11 ++++++ docs/engineering/documentation.md | 9 ++++- docs/engineering/quality-gates.md | 23 +++++++---- 4 files changed, 100 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4ca73e..4e053ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,10 +153,20 @@ jobs: if: needs.changes.outputs.code == 'true' runs-on: ${{ matrix.os }} timeout-minutes: 55 + permissions: + contents: read + checks: write strategy: fail-fast: false matrix: os: [windows-2025, ubuntu-24.04, macos-15] + include: + - os: windows-2025 + name: windows + - os: ubuntu-24.04 + name: linux + - os: macos-15 + name: macos steps: - name: Checkout uses: actions/checkout@v7 @@ -191,6 +201,62 @@ jobs: dotnet test --solution OpenCode.Agents.AI.slnx --configuration Release --no-build --report-trx --results-directory artifacts/test-results --minimum-expected-tests 1 --timeout 25m --hangdump --hangdump-timeout 15m --hangdump-type Mini exit $LASTEXITCODE + - name: Publish test results + id: test-results + uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 + if: success() || failure() + # Allow fork PRs to fail gracefully (permission error) without breaking the workflow. + continue-on-error: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} + with: + name: "Test Results (${{ matrix.name }})" + # The merged TRX repeats the per-framework results; count only the originals. + path: "artifacts/test-results/*.trx" + reporter: dotnet-trx + path-replace-backslashes: true + fail-on-error: true + + # Badge posting failure must not fail CI: the badgesmith.cs tool exits 0 on a failed post + # unless --fail-on-error is passed (which this action never does), and continue-on-error + # here is defense in depth against pre-flight validation failures. always() plus the + # ref/event guard mirrors badge-smith's own ci-cd.yml so a failing master run still posts + # the (failing) counts instead of leaving the badge stale. + # GitHub Actions treats any remote reference under .github/workflows/ as a REUSABLE + # WORKFLOW and refuses it inside steps ("reusable workflows should be referenced at the + # top-level jobs.*.uses key"), so the composite action cannot be consumed remotely from its + # current home. Until badge-smith relocates it (e.g. .github/actions/) and re-tags, we check + # the pinned tag out and consume the action through the local-path form badge-smith itself + # uses; the action is github.action_path-relative, so the relocated checkout is + # self-contained. + - name: Checkout BadgeSmith action + if: always() && github.ref == 'refs/heads/master' && github.event_name == 'push' + continue-on-error: true + uses: actions/checkout@v7 + with: + repository: localstack-dotnet/badge-smith + # Pinned to the commit the live api.localstackfor.net deployment runs, keeping the + # signing tool and the server in lockstep. (The 2026-08-31 401s were ultimately a + # corrupted repository secret, not the tag - but deploy-aligned pinning stays the + # safer default until badge-smith tags releases in lockstep with its deployments.) + ref: bc7ed07860ec4b0e702add6370c2636daccb2adf + path: .badge-smith + + - name: Update test badge via BadgeSmith API + if: always() && github.ref == 'refs/heads/master' && github.event_name == 'push' + continue-on-error: true + uses: ./.badge-smith/.github/workflows/update-test-badge + with: + platform: ${{ matrix.name }} + test_passed: '${{ steps.test-results.outputs.passed || 0 }}' + test_failed: '${{ steps.test-results.outputs.failed || 0 }}' + test_skipped: '${{ steps.test-results.outputs.skipped || 0 }}' + test_url_html: ${{ steps.test-results.outputs.url_html || '' }} + commit_sha: '${{ github.sha }}' + run_id: '${{ github.run_id }}' + repository: '${{ github.repository }}' + server_url: '${{ github.server_url }}' + api_base_url: 'https://api.localstackfor.net' + hmac_secret: '${{ secrets.TESTDATASECRET }}' + - name: List tests after failure if: ${{ failure() && !cancelled() && steps.build.outcome == 'success' && steps.test.outcome == 'failure' }} timeout-minutes: 5 diff --git a/README.md b/README.md index 2a7a329..c40a0cb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # OpenCode Agents AI +[![CI](https://github.com/opencode-dotnet/opencode-agents-ai/actions/workflows/ci.yml/badge.svg)](https://github.com/opencode-dotnet/opencode-agents-ai/actions/workflows/ci.yml) [![Linux Tests](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi.localstackfor.net%2Fbadges%2Ftests%2Flinux%2Fopencode-dotnet%2Fopencode-agents-ai%2Fmaster)](https://api.localstackfor.net/redirect/test-results/linux/opencode-dotnet/opencode-agents-ai/master) [![Windows Tests](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi.localstackfor.net%2Fbadges%2Ftests%2Fwindows%2Fopencode-dotnet%2Fopencode-agents-ai%2Fmaster)](https://api.localstackfor.net/redirect/test-results/windows/opencode-dotnet/opencode-agents-ai/master) [![macOS Tests](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi.localstackfor.net%2Fbadges%2Ftests%2Fmacos%2Fopencode-dotnet%2Fopencode-agents-ai%2Fmaster)](https://api.localstackfor.net/redirect/test-results/macos/opencode-dotnet/opencode-agents-ai/master) + > **Unofficial.** This project is not affiliated with or endorsed by the > [opencode](https://opencode.ai) team. @@ -17,6 +19,15 @@ thin library adapter over the published OpenCode .NET SDK, intended for the NuGe [`docs/ROADMAP.md`](docs/ROADMAP.md) has the current state and what comes next. Usage arrives with the first version. +### Build & Test Matrix + +| Category | Platform/Type | Status | Description | +|----------|---------------|--------|-------------| +| **🔧 Build** | Cross-Platform | [![CI](https://github.com/opencode-dotnet/opencode-agents-ai/actions/workflows/ci.yml/badge.svg)](https://github.com/opencode-dotnet/opencode-agents-ai/actions/workflows/ci.yml) | Matrix: Windows, Linux, macOS | +| **🧪 Tests** | Linux | [![Linux Tests](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi.localstackfor.net%2Fbadges%2Ftests%2Flinux%2Fopencode-dotnet%2Fopencode-agents-ai%2Fmaster)](https://api.localstackfor.net/redirect/test-results/linux/opencode-dotnet/opencode-agents-ai/master) | `net10.0`, `net11.0` | +| **🧪 Tests** | Windows | [![Windows Tests](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi.localstackfor.net%2Fbadges%2Ftests%2Fwindows%2Fopencode-dotnet%2Fopencode-agents-ai%2Fmaster)](https://api.localstackfor.net/redirect/test-results/windows/opencode-dotnet/opencode-agents-ai/master) | `net472`, `net10.0`, `net11.0` | +| **🧪 Tests** | macOS | [![macOS Tests](https://img.shields.io/endpoint?url=https%3A%2F%2Fapi.localstackfor.net%2Fbadges%2Ftests%2Fmacos%2Fopencode-dotnet%2Fopencode-agents-ai%2Fmaster)](https://api.localstackfor.net/redirect/test-results/macos/opencode-dotnet/opencode-agents-ai/master) | `net10.0`, `net11.0` | + ## Developing Building the repository needs the .NET SDK that `global.json` selects. diff --git a/docs/engineering/documentation.md b/docs/engineering/documentation.md index f96c789..e2c0af0 100644 --- a/docs/engineering/documentation.md +++ b/docs/engineering/documentation.md @@ -1,6 +1,6 @@ # Documentation -Date: 2026-11-06 +Date: 2026-11-16 Canonical rules for documentation ownership, authority, lifecycle, references, and lossless maintenance. @@ -79,6 +79,13 @@ ships or a newer handoff supersedes them. `README.md` and `CHANGELOG.md` speak to .NET developers who compose MAF agents and workflows. +- Every opencode-dotnet repository's README shows its status through BadgeSmith + (`api.localstackfor.net`): one test-result badge per CI operating system, and one nuget.org badge + and one GitHub Packages badge per published package once one is published, each with + `?prerelease=true` while its feed carries only prereleases. CI posts each operating system's test + counts from `master` pushes through BadgeSmith's pinned `update-test-badge` action, and a failed + post never fails CI; the workflow's comments own the mechanics. Each badge URL is checked live + before it is committed. - A change that alters what a consumer sees updates the README section that describes it, in the same pull request. - From the first package on, `CHANGELOG.md` gets an entry under `[Unreleased]` for every diff --git a/docs/engineering/quality-gates.md b/docs/engineering/quality-gates.md index 9379c6f..d588839 100644 --- a/docs/engineering/quality-gates.md +++ b/docs/engineering/quality-gates.md @@ -1,6 +1,6 @@ # Engineering Quality Gates -Date: 2026-11-06 +Date: 2026-11-16 Canonical quality policy for product code, repository tooling, tests, analyzers, dependencies, performance evidence, and completion claims. @@ -169,8 +169,9 @@ This is the decided CI contract; `../ROADMAP.md` records whether it is in place. documentation-only change needs the changes job green and the skipped jobs skipped. - **Merge queue.** Everything lands on the default branch through the merge queue, which requires the `CI result` check (`workflow.md`). -- **Least privilege and bounds.** The workflow has `contents: read`; a superseded pull request run - is cancelled, while each default-branch push has a per-commit concurrency group so a newer commit +- **Least privilege and bounds.** The workflow has `contents: read`; the build/test job alone also has + `checks: write`, which the test reporter needs to publish its check run; a superseded pull request + run is cancelled, while each default-branch push has a per-commit concurrency group so a newer commit does not cancel its pending or running workflow; every job has a bounded timeout. The .NET SDK is set up from `global.json` and each job logs the version that resolved. Steps run in `pwsh` and check every command's exit code. Job bounds are 5 minutes for classification, 30 for lint, 55 for each @@ -178,12 +179,18 @@ This is the decided CI contract; `../ROADMAP.md` records whether it is in place. - **Artifacts.** Each build/test leg uploads `artifacts/test-results/**` with `if: always()`, an OS-specific artifact name and seven-day retention. This directory holds the test platform's TRX files, TUnit HTML and JSON reports and, on a hang, hang-dump files; all are uploaded. No redaction - or size-processing step is needed: the workflow uses no secret, has only `contents: read`, sets - `TUNIT_DISABLE_ARTIFACT_UPLOAD` on every test step to prevent automatic upload without disabling - report generation, and runs on ephemeral hosted runners. Test listings stay in the job log. - Upload failures remain blocking and never turn a failed test green; there is no `continue-on-error`. -- **Actions.** Actions are referenced by major version tag (`actions/checkout@v7`, + or size-processing step is needed: the upload step uses no secret, every test step sets + `TUNIT_DISABLE_ARTIFACT_UPLOAD` to prevent automatic upload without disabling report generation, + and the jobs run on ephemeral hosted runners. Test listings stay in the job log. + Upload failures remain blocking and never turn a failed test green. The only `continue-on-error` + steps are the test reporter for fork pull requests, which lack the permission, and the BadgeSmith + steps. The BadgeSmith steps run on master pushes only; the update step reads + `secrets.TESTDATASECRET` and posts the test counts. A failed badge post never fails CI. +- **Actions.** Most actions are referenced by major version tag (`actions/checkout@v7`, `actions/setup-dotnet@v6`, `actions/upload-artifact@v7`); a major tag is not an immutable SHA pin. + Two actions are pinned by commit SHA, as in the OpenCode .NET SDK: `dorny/test-reporter` (v3.0.0), + and the BadgeSmith action, checked out from `localstack-dotnet/badge-smith` at the commit its live + API runs. - **Dependency review.** The `dependency-review` workflow (Dependency audit, above) runs on every pull request with `contents: read`, using `actions/dependency-review-action@v5` without PR comments. `CI result` does not cover Dependency Review; the maintainer checks it before queue entry.