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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/aw/actions-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"version": "v8.0.0",
"sha": "ed597411d8f924073f98dfc5c65a23a2325f34cd"
},
"actions/setup-dotnet@v4.3.1": {
"actions/setup-dotnet@v4": {
"repo": "actions/setup-dotnet",
"version": "v4.3.1",
"sha": "67a3573c9a986a3f9c594539f4ab511d57bb3ce9"
Expand All @@ -80,7 +80,7 @@
"version": "v6.1.0",
"sha": "4dc6199c7b1a012772edbd06daecab0f50c9053c"
},
"actions/setup-java@v4.8.0": {
"actions/setup-java@v4": {
"repo": "actions/setup-java",
"version": "v4.8.0",
"sha": "c1e323688fd81a25caa38c78aa6df2d33d3e20d9"
Expand Down Expand Up @@ -118,7 +118,7 @@
"anchore/sbom-action@v0": {
"repo": "anchore/sbom-action",
"version": "v0",
"sha": "62ad5284b8ced813296287a0b63906cb364b73ee"
"sha": "deef08a0db64bfad603422135db61477b16cef56"
},
"anchore/sbom-action@v0.20.10": {
"repo": "anchore/sbom-action",
Expand Down Expand Up @@ -153,7 +153,7 @@
"docker/login-action@v3": {
"repo": "docker/login-action",
"version": "v3",
"sha": "5e57cd118135c172c3672efd75eb46360885c0ef"
"sha": "c94ce9fb468520275223c153574b00df6fe4bcc9"
},
"docker/metadata-action@v5": {
"repo": "docker/metadata-action",
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Run unit tests with coverage
run: |
set -o pipefail
go test -v -parallel=8 -timeout=3m -run='^Test' -coverprofile=coverage.out -json ./... | tee test-result-unit.json
go test -v -parallel=8 -timeout=3m -run='^Test' -tags '!integration' -coverprofile=coverage.out -json ./... | tee test-result-unit.json
go tool cover -html=coverage.out -o coverage.html

# Coverage reports for recent builds only - 7 days is sufficient for debugging recent changes
Expand Down Expand Up @@ -198,19 +198,19 @@ jobs:

- name: Run integration tests - ${{ matrix.test-group.name }}
run: |
#set -o pipefail
set -o pipefail
# Sanitize the test group name for use in filename
SAFE_NAME=$(echo "${{ matrix.test-group.name }}" | sed 's/[^a-zA-Z0-9]/-/g' | sed 's/--*/-/g')

if [ -z "${{ matrix.test-group.pattern }}" ]; then
# Catch-all group: run with -skip to exclude tests matched by other groups
if [ -n "${{ matrix.test-group.skip_pattern || '' }}" ]; then
go test -v -parallel=8 -timeout=5m -tags 'integration' -skip '${{ matrix.test-group.skip_pattern }}' -json ${{ matrix.test-group.packages }} | tee "test-result-integration-${SAFE_NAME}.json"
go test -v -parallel=8 -timeout=10m -tags 'integration' -skip '${{ matrix.test-group.skip_pattern }}' -json ${{ matrix.test-group.packages }} | tee "test-result-integration-${SAFE_NAME}.json"
else
go test -v -parallel=8 -timeout=5m -tags 'integration' -json ${{ matrix.test-group.packages }} | tee "test-result-integration-${SAFE_NAME}.json"
go test -v -parallel=8 -timeout=10m -tags 'integration' -json ${{ matrix.test-group.packages }} | tee "test-result-integration-${SAFE_NAME}.json"
fi
else
go test -v -parallel=8 -timeout=5m -tags 'integration' -run '${{ matrix.test-group.pattern }}' -json ${{ matrix.test-group.packages }} | tee "test-result-integration-${SAFE_NAME}.json"
go test -v -parallel=8 -timeout=10m -tags 'integration' -run '${{ matrix.test-group.pattern }}' -json ${{ matrix.test-group.packages }} | tee "test-result-integration-${SAFE_NAME}.json"
fi

- name: Upload integration test results
Expand Down
20 changes: 20 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ make build # Rebuild gh-aw after modifying JSON schemas in pkg/parser/sche
```
Schema files are embedded in the binary using `//go:embed` directives, so changes require rebuilding the binary.

**ALWAYS ADD BUILD TAGS TO TEST FILES:**

Every test file (`*_test.go`) **must** have a build tag at the very top of the file:

```go
//go:build !integration // For unit tests (default)

//go:build integration // For integration tests (files with "integration" in name)
```

**Rules:**
- Files with "integration" in the filename get `//go:build integration`
- All other test files get `//go:build !integration`
- The build tag must be the **first line** of the file, followed by an empty line

**To add build tags to all test files:**
```bash
./scripts/add-build-tags.sh
```

**ALWAYS RUN LINTERS AFTER ADDING TEST FILES:**

When adding new test files (`*_test.go`), the **unused** linter may catch helper functions that are defined but never called. Always run linters after creating test files to catch these issues early.
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ build-windows:

# Test the code (runs both unlabelled unit tests and integration tests and long tests)
.PHONY: test
test:
go test -v -parallel=4 -timeout=10m -tags 'integration' -run='^Test' ./...
test: test-unit test-integration

# Test unit tests only (excludes labelled integration tests and long tests)
.PHONY: test-unit
test-unit:
go test -v -parallel=4 -timeout=10m -run='^Test' ./... -short

.PHONY: test-integration
test-integration:
go test -v -parallel=4 -timeout=10m -run='^Test' ./... -short

# Update golden test files
.PHONY: update-golden
update-golden:
Expand Down
2 changes: 2 additions & 0 deletions cmd/gh-aw/capitalization_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package main

import (
Expand Down
26 changes: 20 additions & 6 deletions cmd/gh-aw/main_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ func TestMainFunction(t *testing.T) {
// This is necessary because rootCmd captured the original os.Stderr in init()
rootCmd.SetOut(os.Stderr)

// Read from pipe in goroutine to prevent deadlock when buffer fills
var buf bytes.Buffer
done := make(chan struct{})
go func() {
_, _ = buf.ReadFrom(r)
close(done)
}()

// Execute help
rootCmd.SetArgs([]string{"--help"})
err := rootCmd.Execute()
Expand All @@ -173,9 +181,8 @@ func TestMainFunction(t *testing.T) {
os.Stderr = oldStderr
rootCmd.SetOut(os.Stderr) // Restore the command's output to the original stderr

// Read captured output
var buf bytes.Buffer
_, _ = buf.ReadFrom(r)
// Wait for reader goroutine to finish
<-done
output := buf.String()

if err != nil {
Expand All @@ -199,6 +206,14 @@ func TestMainFunction(t *testing.T) {
// Update the command's output to use the new os.Stderr pipe
rootCmd.SetOut(os.Stderr)

// Read from pipe in goroutine to prevent deadlock when buffer fills
var buf bytes.Buffer
done := make(chan struct{})
go func() {
_, _ = buf.ReadFrom(r)
close(done)
}()

// Execute help all
rootCmd.SetArgs([]string{"help", "all"})
err := rootCmd.Execute()
Expand All @@ -208,9 +223,8 @@ func TestMainFunction(t *testing.T) {
os.Stderr = oldStderr
rootCmd.SetOut(os.Stderr)

// Read captured output
var buf bytes.Buffer
_, _ = buf.ReadFrom(r)
// Wait for reader goroutine to finish
<-done
output := buf.String()

if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cmd/gh-aw/short_description_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/bootstrap_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/campaign_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/create_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/filter_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/injection_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/interactive_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/loader_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/metrics_snapshot_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/orchestrator_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/project_owner_normalization_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/project_repo_parsing_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/project_status_options_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/project_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/project_views_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/template_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/test_helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/validation_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/campaign/workflow_discovery_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package campaign

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/access_log_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/actionlint_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/actions_build_command_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/actions_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/add_command_table_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/add_command_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/add_description_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/add_gitattributes_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/add_no_args_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/add_repo_only_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/add_source_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/add_wildcard_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/add_workflow_not_found_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/agentic_workflow_agent_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/audit_agent_example_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/audit_agent_output_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/audit_input_size_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/audit_report_helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !integration

package cli

import (
Expand Down
Loading
Loading