-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (166 loc) · 5.77 KB
/
Copy pathci.yml
File metadata and controls
176 lines (166 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: CI
# AX-compliant CI workflow for dAppCore/agent
# RFC-CORE-008-AGENT-EXPERIENCE.md (Agent Experience Design Principles)
#
# Usage examples:
# - To add a new test language: create test-{lang} job following test-go/test-php pattern
# - To add a new linter: create lint-{tool} job following golangci-lint pattern
# - To add SonarCloud project: update sonarcloud job args with new project key
#
# Core primitives applied:
# - Declarative job structure (YAML workflow definition)
# - Predictable job names (test-go, test-php, not test1, test2)
# - Path as documentation (workflow file location signals purpose)
on:
push:
branches: [dev, main]
pull_request:
branches: [dev, main]
permissions:
contents: read
env:
# AX: Explicit environment variables with descriptive names
GOFLAGS: -buildvcs=false
GOWORK: "off"
GOPROXY: "direct"
GOSUMDB: "off"
jobs:
# Test jobs - each language runs independently for parallel coverage uploads
# AX Principle: Declarative job structure with predictable names
test-go:
name: Go Tests + Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Test with coverage
working-directory: go
# AX: Race detector for thread-safety, atomic mode for accuracy
run: go test -race -coverprofile=coverage.out -covermode=atomic -count=1 ./...
- name: Upload Go coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: go/coverage.out
flags: go-unittests
fail_ci_if_error: false
name: go-coverage
test-php:
name: PHP Tests + Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Install dependencies
working-directory: php
run: |
if [ -f composer.json ]; then
composer install --no-progress --prefer-dist
fi
- name: Run Pest tests with coverage
working-directory: php
# AX: This repo uses Pest testing framework, not PHPUnit
# Pest coverage requires pest-plugin/coverage or XDEBUG
run: |
if [ -f composer.json ]; then
if command -v ./vendor/bin/pest &> /dev/null; then
./vendor/bin/pest --coverage --coverage-clover=coverage.xml
else
echo "Pest not found, skipping PHP tests"
fi
else
echo "No composer.json found, skipping PHP tests"
fi
- name: Upload PHP coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: php/coverage.xml
flags: php-unittests
fail_ci_if_error: false
name: php-coverage
lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.26'
- uses: golangci/golangci-lint-action@v9
with:
version: latest
working-directory: go
# AX: Skip test files (covered by test-go job), timeout for large codebase
args: --timeout=5m --tests=false
# Quality analysis - runs after tests pass
# AX Principle: Composition - SonarCloud consumes test results from previous jobs
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
needs: [test-go, test-php]
# AX Principle: Explicit dependencies - waits for both language tests
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version: '1.26'
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Install PHP dependencies
working-directory: php
run: |
if [ -f composer.json ]; then
composer install --no-progress --prefer-dist
fi
- name: Test Go for coverage
working-directory: go
run: go test -coverprofile=coverage.out -covermode=atomic -count=1 ./...
- name: Test PHP for coverage
working-directory: php
# AX: Run Pest tests with coverage for SonarCloud
run: |
if command -v ./vendor/bin/pest &> /dev/null; then
./vendor/bin/pest --coverage --coverage-clover=coverage.xml
fi
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v6
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.organization=dappcore
-Dsonar.projectKey=dappcore_agent
-Dsonar.sources=go,php
# AX: Explicit exclusions following ignore patterns from .codecov.yml
-Dsonar.exclusions=**/vendor/**,**/third_party/**,**/.tmp/**,**/*_test.go,**/php/tests/**,**/php/vendor/**
-Dsonar.tests=go,php
-Dsonar.test.inclusions=**/*_test.go,**/*Test.php
-Dsonar.go.coverage.reportPaths=go/coverage.out
-Dsonar.php.coverage.reportPaths=php/coverage.xml
# Final coverage aggregation job
# AX Principle: Composition - combines results from all test jobs
finalize-coverage:
name: Finalize Coverage
runs-on: ubuntu-latest
needs: [test-go, test-php]
# AX: Explicit dependencies ensure all tests complete before finalization
steps:
- name: Finalize Codecov upload
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: go/coverage.out,php/coverage.xml
fail_ci_if_error: false
name: combined-coverage