diff --git a/.github/skills/agentic-workflows/SKILL.md b/.github/skills/agentic-workflows/SKILL.md index 3fc711d4035..6f24708a24e 100644 --- a/.github/skills/agentic-workflows/SKILL.md +++ b/.github/skills/agentic-workflows/SKILL.md @@ -37,6 +37,7 @@ Load these files from `github/gh-aw` (they are not available locally). - `.github/aw/github-agentic-workflows.md` - `.github/aw/github-mcp-server.md` - `.github/aw/instructions.md` +- `.github/aw/linter-workflows.md` - `.github/aw/llms.md` - `.github/aw/loop.md` - `.github/aw/lsp.md` diff --git a/.github/workflows/cgo.yml b/.github/workflows/cgo.yml index b5b730a6713..971ecd6c51d 100644 --- a/.github/workflows/cgo.yml +++ b/.github/workflows/cgo.yml @@ -40,12 +40,29 @@ on: workflow_dispatch: jobs: test: + name: Unit tests (${{ matrix.name }}) runs-on: ubuntu-latest timeout-minutes: 15 permissions: contents: read + strategy: + fail-fast: false + matrix: + include: + - name: A-C + pattern: ^Test[A-C] + shard: a-c + - name: D-L + pattern: ^Test[D-L] + shard: d-l + - name: M-R + pattern: ^Test[M-R] + shard: m-r + - name: S-Z and other + pattern: ^Test([S-Z]|[^A-R]) + shard: s-z concurrency: - group: ci-${{ github.ref }}-test + group: ci-${{ github.ref }}-test-${{ matrix.shard }} cancel-in-progress: true steps: - name: Checkout code @@ -152,26 +169,16 @@ jobs: run: | set -o pipefail # Run tests with JSON output for artifacts, but also show failures - go test -v -parallel=8 -timeout=3m -run='^Test' -tags '!integration' -coverprofile=coverage.out -json ./... | tee test-result-unit.json + go test -v -parallel=8 -timeout=3m -run='${{ matrix.pattern }}' -tags '!integration' -coverprofile=coverage-${{ matrix.shard }}.out -json ./... | tee test-result-unit-${{ matrix.shard }}.json # Check if tests failed by looking at JSON output - if grep -q '"Action":"fail"' test-result-unit.json; then + if grep -q '"Action":"fail"' test-result-unit-${{ matrix.shard }}.json; then echo "❌ Tests failed - see output above" exit 1 fi # Generate coverage HTML report - go tool cover -html=coverage.out -o coverage.html - - - name: Validate pkg/cli and pkg/console tests executed - run: | - set -euo pipefail - for package in pkg/cli pkg/console; do - if ! grep -q "\"Action\":\"run\",\"Package\":\"github.com/github/gh-aw/${package}\"" test-result-unit.json; then - echo "Missing unit test execution records for ${package}" >&2 - exit 1 - fi - done + go tool cover -html=coverage-${{ matrix.shard }}.out -o coverage-${{ matrix.shard }}.html - name: Report test failures if: failure() && steps.run-unit-tests.outcome == 'failure' @@ -182,7 +189,7 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY # Run the failure report script - if ./scripts/report-test-failures.sh test-result-unit.json | tee /tmp/failure-report.txt; then + if ./scripts/report-test-failures.sh test-result-unit-${{ matrix.shard }}.json | tee /tmp/failure-report.txt; then echo "No failures detected in JSON output (unexpected - tests failed but no failure records found)" >> $GITHUB_STEP_SUMMARY else # Script found failures - add to summary @@ -195,16 +202,16 @@ jobs: - name: Upload coverage report uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: - name: coverage-report - path: coverage.html + name: coverage-report-${{ matrix.shard }} + path: coverage-${{ matrix.shard }}.html retention-days: 7 - name: Upload unit test results if: always() # Upload even if tests fail so canary-go can track coverage uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: - name: test-result-cgo-unit - path: test-result-unit.json + name: test-result-cgo-unit-${{ matrix.shard }} + path: test-result-unit-${{ matrix.shard }}.json retention-days: 7 canary-go: @@ -230,7 +237,7 @@ jobs: uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4 with: path: test-results - pattern: test-result-cgo-unit + pattern: test-result-cgo-unit-* merge-multiple: false - name: List downloaded artifacts @@ -241,6 +248,16 @@ jobs: echo "" echo "Total JSON files: $(find test-results -type f -name \"*.json\" | wc -l)" + - name: Validate pkg/cli and pkg/console tests executed + run: | + set -euo pipefail + for package in pkg/cli pkg/console; do + if ! grep -R -q "\"Action\":\"run\",\"Package\":\"github.com/github/gh-aw/${package}\"" test-results; then + echo "Missing unit test execution records for ${package}" >&2 + exit 1 + fi + done + - name: Extract executed tests from artifacts run: | set -euo pipefail diff --git a/Makefile b/Makefile index 6aa19a1988a..29c610ecb73 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ CI_COVERAGE_ENABLED ?= 1 CI_COVERAGE_SOURCE_BRANCH ?= main CI_RUN_ID ?= CI_UNIT_WORKFLOW_FILE ?= cgo.yml -CI_UNIT_TEST_ARTIFACT_PATTERN ?= test-result-cgo-unit +CI_UNIT_TEST_ARTIFACT_PATTERN ?= test-result-cgo-unit-* CI_UNIT_RUN_ID ?= GO_IMPACTED_TEST_MAX_SECONDS ?= 60 GO_IMPACTED_TEST_PATTERN_MAX_CHARS ?= 8000 @@ -360,12 +360,11 @@ test-impacted-go: rm -rf "$$UNIT_RESULT_DIR"; \ mkdir -p "$$UNIT_RESULT_DIR"; \ if gh run download "$$UNIT_RUN_ID" --pattern "$(CI_UNIT_TEST_ARTIFACT_PATTERN)" --dir "$$UNIT_RESULT_DIR" >/dev/null 2>&1; then \ - UNIT_RESULT_FILE=$$(find "$$UNIT_RESULT_DIR" -type f -name '*.json' | head -n 1); \ - if [ -n "$$UNIT_RESULT_FILE" ]; then \ + if find "$$UNIT_RESULT_DIR" -type f -name '*.json' -print -quit | grep -q .; then \ IMPACTED_PACKAGE_FILE="$(CI_COVERAGE_DIR)/impacted-go-packages.txt"; \ printf '%s\n' "$$CHANGED_GO_PACKAGES" | sed 's|^\./|github.com/github/gh-aw/|' > "$$IMPACTED_PACKAGE_FILE"; \ IMPACTED_TEST_CANDIDATES="$(CI_COVERAGE_DIR)/impacted-go-test-candidates.tsv"; \ - jq -r 'select(.Action == "pass" and .Package != null and .Test != null and (.Test | contains("/") | not) and .Elapsed != null) | [.Package, .Test, (.Elapsed | tostring)] | @tsv' "$$UNIT_RESULT_FILE" \ + find "$$UNIT_RESULT_DIR" -type f -name '*.json' -exec jq -r 'select(.Action == "pass" and .Package != null and .Test != null and (.Test | contains("/") | not) and .Elapsed != null) | [.Package, .Test, (.Elapsed | tostring)] | @tsv' {} + \ | awk 'NR==FNR { pkgs[$$1] = 1; next } $$1 in pkgs { print }' "$$IMPACTED_PACKAGE_FILE" - \ | sort -u > "$$IMPACTED_TEST_CANDIDATES"; \ if [ -s "$$IMPACTED_TEST_CANDIDATES" ]; then \ diff --git a/pkg/cli/data/agentic_workflows_fallback_aw_files.json b/pkg/cli/data/agentic_workflows_fallback_aw_files.json index 2165df7dc76..ba497b7d5cc 100644 --- a/pkg/cli/data/agentic_workflows_fallback_aw_files.json +++ b/pkg/cli/data/agentic_workflows_fallback_aw_files.json @@ -21,6 +21,7 @@ "github-agentic-workflows.md", "github-mcp-server.md", "instructions.md", + "linter-workflows.md", "llms.md", "loop.md", "lsp.md",