Run Validation in CI
This guide shows how to integrate TestLink validation into your CI/CD pipeline.
Basic CI Integration
Step 1: Add validation command
Add the validate command to your CI script:
bash
./vendor/bin/testlink validateThe command returns:
- Exit code
0- All links valid - Exit code
1- Validation errors found
Step 2: Configure strictness
For stricter validation:
bash
./vendor/bin/testlink validate --strictThis fails on warnings as well as errors.
GitHub Actions
Basic workflow
yaml
# .github/workflows/tests.yml
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Install dependencies
run: composer install --no-interaction
- name: Run tests
run: ./vendor/bin/pest
- name: Validate TestLink
run: ./vendor/bin/testlink validateWith JSON output
yaml
- name: Validate TestLink
run: ./vendor/bin/testlink validate --json > testlink-report.json
- name: Upload report
uses: actions/upload-artifact@v4
with:
name: testlink-report
path: testlink-report.jsonSeparate validation job
yaml
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- run: composer install
- run: ./vendor/bin/pest
testlink:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- run: composer install
- run: ./vendor/bin/testlink validate --strictGitLab CI
yaml
# .gitlab-ci.yml
stages:
- test
test:
stage: test
image: php:8.2
before_script:
- composer install --no-interaction
script:
- ./vendor/bin/pest
- ./vendor/bin/testlink validate
testlink:report:
stage: test
image: php:8.2
before_script:
- composer install --no-interaction
script:
- ./vendor/bin/testlink report --json > testlink-report.json
artifacts:
paths:
- testlink-report.json
expire_in: 1 weekCircleCI
yaml
# .circleci/config.yml
version: 2.1
jobs:
test:
docker:
- image: cimg/php:8.2
steps:
- checkout
- run: composer install
- run: ./vendor/bin/pest
- run: ./vendor/bin/testlink validate
workflows:
test:
jobs:
- testPre-commit Hook
Using git hooks directly
Create .git/hooks/pre-commit:
bash
#!/bin/bash
echo "Running TestLink validation..."
./vendor/bin/testlink validate
if [ $? -ne 0 ]; then
echo "TestLink validation failed. Please fix the issues before committing."
exit 1
fiMake it executable:
bash
chmod +x .git/hooks/pre-commitUsing Husky (for Node.js projects)
json
// package.json
{
"husky": {
"hooks": {
"pre-commit": "./vendor/bin/testlink validate"
}
}
}Using CaptainHook (PHP)
json
// captainhook.json
{
"pre-commit": {
"actions": [
{
"action": "./vendor/bin/testlink validate"
}
]
}
}Scheduled Validation
Run comprehensive reports on a schedule:
GitHub Actions (weekly)
yaml
name: Weekly TestLink Report
on:
schedule:
- cron: '0 0 * * 0' # Every Sunday at midnight
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- run: composer install
- run: ./vendor/bin/testlink report --json > report.json
- run: ./vendor/bin/testlink validate --json > validate.json
- uses: actions/upload-artifact@v4
with:
name: testlink-reports
path: |
report.json
validate.jsonCombining with Other Tools
With PHPStan
yaml
- name: Static Analysis
run: |
./vendor/bin/phpstan analyse
./vendor/bin/testlink validateWith Pest coverage
yaml
- name: Tests with Coverage
run: ./vendor/bin/pest --coverage --min=80
- name: TestLink Validation
run: ./vendor/bin/testlink validateHandling Failures
Allow warnings, fail on errors
bash
# Exits 0 for warnings, 1 for errors
./vendor/bin/testlink validateFail on any issue
bash
# Exits 1 for warnings AND errors
./vendor/bin/testlink validate --strictContinue on failure (for non-blocking checks)
yaml
- name: TestLink Validation
run: ./vendor/bin/testlink validate
continue-on-error: trueBest Practices
- Run on every PR - Catch broken links early
- Use strict mode in CI - Be more lenient locally
- Generate reports - Archive for trend analysis
- Block merges on failure - Require validation to pass
- Add to PR checks - Make status visible to reviewers