2020 with :
2121 go-version : 1.25.0
2222 - name : Test quickly without Docker
23- run : go test -v ./...
23+ run : |
24+ echo "Testing main module..."
25+ go test -v ./...
26+ echo "Testing reservations module..."
27+ cd reservations && go test -v ./...
2428
2529 test-with-docker :
2630 # We don't need to run this longer test if the previous one already failed.
@@ -43,15 +47,27 @@ jobs:
4347 export GITHUB_ACTIONS=1
4448 export POSTGRES_CONTAINER=1
4549 export RABBITMQ_CONTAINER=1
50+
51+ echo "Running tests for main module..."
4652 go test -v \
4753 -coverpkg=./internal/... \
4854 -coverprofile=pr_profile.cov ./internal/...
4955 go tool cover -func pr_profile.cov > pr_func_coverage.txt
50- - name : Upload coverage file
56+
57+ echo "Running tests for reservations module..."
58+ cd reservations
59+ go test -v \
60+ -coverpkg=./internal/... \
61+ -coverprofile=reservations_profile.cov ./internal/...
62+ go tool cover -func reservations_profile.cov > reservations_func_coverage.txt
63+ cd ..
64+ - name : Upload coverage files
5165 uses : actions/upload-artifact@v4
5266 with :
5367 name : pr-func-coverage
54- path : pr_func_coverage.txt
68+ path : |
69+ pr_func_coverage.txt
70+ reservations/reservations_func_coverage.txt
5571 # Steps below are only executed if the workflow is triggered by a pull request
5672 - name : Delete old coverage comments (PR only)
5773 if : ${{ github.event_name == 'pull_request' }}
7389 });
7490 }
7591 }
76- - name : Download coverage file (PR only)
92+ - name : Download coverage files (PR only)
7793 if : ${{ github.event_name == 'pull_request' }}
7894 uses : actions/download-artifact@v5
7995 with :
@@ -87,20 +103,46 @@ jobs:
87103 const fs = require('fs');
88104 const path = require('path');
89105
90- // Extract the last line of the coverage report
91- const coverageReport = fs.readFileSync('pr_func_coverage.txt', 'utf8');
92- const lines = coverageReport.trim().split('\n');
93- const lastLine = lines[lines.length - 1];
94- const coverageMatch = lastLine.match(/total:\s+\(statements\)\s+(\d+\.\d+)%/);
95- const coveragePercentage = coverageMatch ? coverageMatch[1] : 'unknown';
106+ // Read main module coverage report
107+ const mainCoverageReport = fs.readFileSync('pr_func_coverage.txt', 'utf8');
108+ const mainLines = mainCoverageReport.trim().split('\n');
109+ const mainLastLine = mainLines[mainLines.length - 1];
110+ const mainCoverageMatch = mainLastLine.match(/total:\s+\(statements\)\s+(\d+\.\d+)%/);
111+ const mainCoveragePercentage = mainCoverageMatch ? mainCoverageMatch[1] : 'unknown';
112+
113+ // Read reservations module coverage report
114+ let reservationsCoverageReport = '';
115+ let reservationsCoveragePercentage = 'unknown';
116+ try {
117+ reservationsCoverageReport = fs.readFileSync('reservations/reservations_func_coverage.txt', 'utf8');
118+ const reservationsLines = reservationsCoverageReport.trim().split('\n');
119+ const reservationsLastLine = reservationsLines[reservationsLines.length - 1];
120+ const reservationsCoverageMatch = reservationsLastLine.match(/total:\s+\(statements\)\s+(\d+\.\d+)%/);
121+ reservationsCoveragePercentage = reservationsCoverageMatch ? reservationsCoverageMatch[1] : 'unknown';
122+ } catch (error) {
123+ reservationsCoverageReport = 'No coverage data available';
124+ }
96125
97126 let commentBody = '<!-- coverage-comment -->\n';
127+ commentBody += '## Test Coverage Report\n\n';
128+
129+ // Main module coverage
98130 commentBody += '<details>\n';
99- commentBody += '<summary>Coverage in go module internal/: ';
100- commentBody += coveragePercentage ;
131+ commentBody += '<summary>Coverage in main module ( internal/) : ';
132+ commentBody += mainCoveragePercentage ;
101133 commentBody += '%</summary>\n\n';
102134 commentBody += '```text\n';
103- commentBody += coverageReport;
135+ commentBody += mainCoverageReport;
136+ commentBody += '```\n';
137+ commentBody += '</details>\n\n';
138+
139+ // Reservations module coverage
140+ commentBody += '<details>\n';
141+ commentBody += '<summary>Coverage in reservations module (reservations/internal/): ';
142+ commentBody += reservationsCoveragePercentage;
143+ commentBody += '%</summary>\n\n';
144+ commentBody += '```text\n';
145+ commentBody += reservationsCoverageReport;
104146 commentBody += '```\n';
105147 commentBody += '</details>\n';
106148
@@ -110,4 +152,4 @@ jobs:
110152 owner: context.repo.owner,
111153 repo: context.repo.repo,
112154 body: commentBody,
113- });
155+ });
0 commit comments