Skip to content

Commit aaef9ff

Browse files
committed
👷 ci(test-guard): integrate test-guard into CI/CD pipeline
- move test-guard from standalone workflow into _ci-cd.yml as a PR-only job that consumes coverage from the tests job - extract coverage.xml from test container via docker cp and upload as "coverage-report" artifact - add pull-requests:write and statuses:write permissions to aws_dev.yml and aws_prod.yml callers - set per-job permissions in _ci-cd.yml (test-guard needs write access, other jobs only need contents:read) - update docker submodule (php-pcov + --coverage-clover)
1 parent 9f8cde0 commit aaef9ff

5 files changed

Lines changed: 58 additions & 50 deletions

File tree

.github/workflows/_ci-cd.yml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ env:
3333
# Opt into Node.js 24 for all JavaScript-based actions (checkout@v4, etc.)
3434
# Remove once actions/checkout@v5 is released with native Node 24 support.
3535
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
36-
permissions:
37-
contents: read
36+
# Permissions are set per-job (not workflow-level) because test-guard
37+
# requires pull-requests:write while other jobs only need contents:read.
38+
# The calling workflow (aws_dev.yml / aws_prod.yml) sets the ceiling.
3839
jobs:
3940
# ───────────────────────────────────────────────────────────────────────────
4041
# JOB 1 – tests
@@ -46,6 +47,8 @@ jobs:
4647
name: Run tests
4748
runs-on: ubuntu-24.04
4849
environment: ci_test
50+
permissions:
51+
contents: read
4952
steps:
5053
# Checkout the repo including all git submodules.
5154
# Falls back to the built-in github.token for fork PRs where
@@ -74,6 +77,19 @@ jobs:
7477
docker compose -f docker/docker-compose-ci.yml build test-node > /dev/null 2>&1
7578
# Run tests — exit code propagated to the workflow step
7679
docker compose -f docker/docker-compose-ci.yml up test-node --exit-code-from test-node || exit 1
80+
81+
# ── Coverage artifact (consumed by test-guard job) ──────────────────
82+
- name: Extract coverage report from test container
83+
run: |
84+
CONTAINER_ID=$(docker compose -f docker/docker-compose-ci.yml ps -aq test-node | head -1)
85+
docker cp "$CONTAINER_ID":/var/www/matecat/coverage.xml ./coverage.xml
86+
87+
- name: Upload coverage artifact
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: coverage-report
91+
path: coverage.xml
92+
retention-days: 7
7793
# ───────────────────────────────────────────────────────────────────────────
7894
# JOB 2 – deploy (only when should_deploy is true)
7995
#
@@ -89,6 +105,8 @@ jobs:
89105
name: Deploy to ${{ inputs.deploy_environment }}
90106
runs-on: ubuntu-24.04
91107
environment: ${{ inputs.deploy_environment }}
108+
permissions:
109+
contents: read
92110
if: ${{ inputs.should_deploy }}
93111
needs:
94112
- tests
@@ -163,3 +181,36 @@ jobs:
163181
# ── :latest aliases together ──────────────────────────────────────
164182
docker push $WEB_REPO:latest
165183
docker push $DAEMONS_REPO:latest
184+
185+
# ───────────────────────────────────────────────────────────────────────────
186+
# JOB – test-guard (PR only)
187+
#
188+
# Downloads the "coverage-report" artifact produced by the tests job and
189+
# runs ostico/test-guard to evaluate test adequacy on changed files.
190+
# ───────────────────────────────────────────────────────────────────────────
191+
test-guard:
192+
name: Test adequacy gate
193+
runs-on: ubuntu-latest
194+
needs: tests
195+
if: github.event_name == 'pull_request'
196+
permissions:
197+
contents: read
198+
pull-requests: write
199+
statuses: write
200+
steps:
201+
- name: Checkout repository
202+
uses: actions/checkout@v4
203+
with:
204+
fetch-depth: 0
205+
206+
- name: Download coverage artifact
207+
uses: actions/download-artifact@v4
208+
with:
209+
name: coverage-report
210+
211+
- name: Test Guard
212+
uses: ostico/test-guard@v1.0.1
213+
with:
214+
coverage-file: coverage.xml
215+
coverage-threshold: '80'
216+
ai-enabled: 'true'

.github/workflows/aws_dev.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
branches: [ "develop" ]
1010
permissions:
1111
contents: read
12+
pull-requests: write
13+
statuses: write
1214
jobs:
1315
ci-cd:
1416
uses: ./.github/workflows/_ci-cd.yml

.github/workflows/aws_prod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ on:
1515
branches: [ "master" ]
1616
permissions:
1717
contents: read
18+
pull-requests: write
19+
statuses: write
1820
jobs:
1921
ci-cd:
2022
uses: ./.github/workflows/_ci-cd.yml

.github/workflows/test-guard.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

docker

0 commit comments

Comments
 (0)