Skip to content

chore(composer): move composer.json to the repo root, rename to dappc… #72

chore(composer): move composer.json to the repo root, rename to dappc…

chore(composer): move composer.json to the repo root, rename to dappc… #72

Workflow file for this run

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