Skip to content

Commit d77c9a6

Browse files
docs: Add CI/CD integration requirements for test suites
- Updated scripts/tests/unit.sh to install prerequisites before running tests - Added install-dev step for asyncapigenerator tests to fix CI failures - Added copilot instruction #14 requiring unit.sh updates for new projects - Expanded CI/CD Integration section with comprehensive documentation: - Current GitHub Actions workflow details - Step-by-step guide for adding new test suites - Examples for Python and TypeScript projects - Local testing instructions - Documented 5-minute timeout and coverage format requirements - Added changelog entry explaining rationale and changes
1 parent 90cce1a commit d77c9a6

File tree

3 files changed

+132
-22
lines changed

3 files changed

+132
-22
lines changed

scripts/tests/unit.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ cd "$(git rev-parse --show-toplevel)"
1919

2020
# run tests
2121

22-
22+
# Python projects - asyncapigenerator
23+
echo "Setting up and running asyncapigenerator tests..."
24+
make -C ./src/asyncapigenerator install-dev
2325
make -C ./src/asyncapigenerator test
26+
27+
# TypeScript/JavaScript projects (npm workspace)
2428
npm ci
2529
npm run test:unit --workspaces
2630

src/.github/copilot-instructions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828

2929
13. **Python environment setup** - For Python projects, always use `configure_python_environment` tool to set up the Python environment before running tests or installing dependencies. When VS Code prompts to select which requirements file to install, **always select `requirements-dev.txt`** (not `requirements.txt`) as it includes all testing dependencies plus production dependencies.
3030

31+
14. **Update unit.sh for CI/CD integration** - When adding tests for a new project, you **MUST** update `scripts/tests/unit.sh` to include:
32+
- Installation of prerequisites (e.g., `make -C ./src/project-name install-dev` for Python projects)
33+
- Execution of the test suite (e.g., `make -C ./src/project-name test`)
34+
- The CI/CD pipeline runs `make test-unit` which calls `scripts/tests/unit.sh`
35+
- This file is used by `.github/workflows/stage-2-test.yaml` in the "Run unit test suite" step
36+
- Always test that the prerequisites install correctly before running tests
37+
- Add a comment in unit.sh explaining what each section does
38+
3139
## Quick Reference
3240

3341
- **TESTING_PLAN.md**: Main testing plan document with progress tracker and changelog

src/TESTING_PLAN.md

Lines changed: 119 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ This document outlines the comprehensive plan for implementing unit tests across
7070

7171
**Track all implementation activities here. Add new entries at the top (reverse chronological order).**
7272

73+
### 2025-01-04 16:45 GMT - Added CI/CD Integration Documentation
74+
75+
- **Author**: GitHub Copilot
76+
- **Activity**: Documented CI/CD test integration requirements and updated unit.sh
77+
- **Changes**:
78+
- Added Copilot Instruction #14: Requirement to update `scripts/tests/unit.sh` when adding new test suites
79+
- Updated `scripts/tests/unit.sh`: Added `install-dev` prerequisite step before running asyncapigenerator tests
80+
- Expanded CI/CD Integration section in TESTING_PLAN.md with:
81+
- Current implementation details (GitHub Actions workflow)
82+
- Step-by-step guide for adding new projects to unit.sh
83+
- Examples for Python and TypeScript projects
84+
- Full example of unit.sh structure
85+
- CI/CD workflow details and requirements
86+
- Local testing instructions
87+
- Clarified that Python projects must have `install-dev` target and `requirements-dev.txt`
88+
- Documented 5-minute timeout requirement for unit tests
89+
- Added note about coverage report format compatibility
90+
- **Files Modified**:
91+
- `src/.github/copilot-instructions.md` - Added instruction #14
92+
- `scripts/tests/unit.sh` - Added install-dev step and comments
93+
- `src/TESTING_PLAN.md` - Replaced "GitHub Actions Workflow (Future)" with comprehensive current implementation documentation
94+
- **Rationale**: CI was failing because prerequisites weren't installed before running tests. This ensures future implementers understand the complete integration requirements.
95+
- **Status**: CI/CD integration requirements now fully documented
96+
7397
### 2025-01-04 16:15 GMT - Refactored Copilot Instructions
7498

7599
- **Author**: GitHub Copilot
@@ -684,36 +708,110 @@ export default config;
684708

685709
## CI/CD Integration
686710

687-
### GitHub Actions Workflow (Future)
711+
### Current Implementation
712+
713+
The project uses **GitHub Actions** for CI/CD testing. All tests are executed via:
714+
715+
```bash
716+
make test-unit
717+
```
718+
719+
Which calls the test orchestration script:
720+
721+
```bash
722+
scripts/tests/unit.sh
723+
```
724+
725+
This script is used by `.github/workflows/stage-2-test.yaml` in the **"Run unit test suite"** step.
726+
727+
### Adding Tests for New Projects
728+
729+
**CRITICAL**: When you add tests for a new project, you **MUST** update `scripts/tests/unit.sh` to include:
730+
731+
1. **Prerequisites installation** (for Python projects)
732+
2. **Test execution**
733+
734+
#### Example for Python Projects
735+
736+
```bash
737+
# Python projects - your-project-name
738+
echo "Setting up and running your-project-name tests..."
739+
make -C ./src/your-project-name install-dev # Install test dependencies
740+
make -C ./src/your-project-name test # Run tests
741+
```
742+
743+
#### Example for TypeScript Projects
744+
745+
TypeScript projects in the npm workspace are automatically tested via:
746+
747+
```bash
748+
npm ci
749+
npm run test:unit --workspaces
750+
```
688751

689-
```yaml
690-
name: Tests
752+
No additional changes needed if your project has `test:unit` script in `package.json`.
691753

692-
on: [push, pull_request]
754+
#### Full Example: scripts/tests/unit.sh
693755

694-
jobs:
695-
test:
696-
runs-on: ubuntu-latest
697-
steps:
698-
- uses: actions/checkout@v3
756+
```bash
757+
#!/bin/bash
699758

700-
- name: Set up Python
701-
uses: actions/setup-python@v4
702-
with:
703-
python-version: '3.11'
759+
set -euo pipefail
704760

705-
- name: Set up Node.js
706-
uses: actions/setup-node@v3
707-
with:
708-
node-version: '18'
761+
cd "$(git rev-parse --show-toplevel)"
709762

710-
- name: Run all tests
711-
run: make test
763+
# Python projects
764+
echo "Setting up and running asyncapigenerator tests..."
765+
make -C ./src/asyncapigenerator install-dev
766+
make -C ./src/asyncapigenerator test
712767

713-
- name: Upload coverage
714-
uses: codecov/codecov-action@v3
768+
echo "Setting up and running cloudeventjekylldocs tests..."
769+
make -C ./src/cloudeventjekylldocs install-dev
770+
make -C ./src/cloudeventjekylldocs test
771+
772+
# TypeScript/JavaScript projects (npm workspace)
773+
npm ci
774+
npm run test:unit --workspaces
775+
776+
# Merge coverage reports
777+
mkdir -p .reports
778+
TMPDIR="./.reports" ./node_modules/.bin/lcov-result-merger \
779+
"**/.reports/unit/coverage/lcov.info" \
780+
".reports/lcov.info" \
781+
--ignore "node_modules" \
782+
--prepend-source-files \
783+
--prepend-path-fix "../../.."
715784
```
716785

786+
### CI/CD Workflow Details
787+
788+
The GitHub Actions workflow (`.github/workflows/stage-2-test.yaml`):
789+
790+
1. **Checks out code**
791+
2. **Runs `npm ci`** - Installs npm dependencies
792+
3. **Generates dependencies** - Runs `npm run generate-dependencies --workspaces --if-present`
793+
4. **Runs `make test-unit`** - Executes `scripts/tests/unit.sh`
794+
5. **Uploads artifacts** - Saves test results and coverage reports
795+
796+
**Important Notes**:
797+
798+
- Python projects must have `install-dev` target in their Makefile
799+
- Python projects must have `requirements-dev.txt` with test dependencies
800+
- Tests must run quickly (timeout is 5 minutes for unit tests)
801+
- Coverage reports should be in `.reports/` directory
802+
- Python coverage should use pytest-cov format compatible with lcov-result-merger
803+
804+
### Testing CI/CD Changes Locally
805+
806+
Before committing changes to `scripts/tests/unit.sh`, test locally:
807+
808+
```bash
809+
# From repository root
810+
bash scripts/tests/unit.sh
811+
```
812+
813+
This will run all tests exactly as CI/CD does.
814+
717815
## Success Criteria
718816

719817
### Per Project

0 commit comments

Comments
 (0)