Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload test run results to codecov #4014

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run lint
if: success() || failure()
if: '!cancelled()'
- run: npm run lint-css
if: success() || failure()
if: '!cancelled()'
- run: npm run generate-typings
if: success() || failure()
if: '!cancelled()'
- run: npm run typecheck
if: success() || failure()
if: '!cancelled()'
- run: npm run generate-docs
- run: docker run --rm -v ${PWD}:/docs squidfunk/mkdocs-material build

Expand All @@ -53,6 +53,11 @@ jobs:
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
- name: Upload test results to Codecov
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}


integration-tests:
name: Integration tests
Expand All @@ -69,12 +74,11 @@ jobs:
- run: npm ci
- run: npm run build-dist
- uses: actions/upload-artifact@v4
if: success()
if: '!cancelled()'
with:
name: build-dist-${{ matrix.os }}
path: dist/maplibre-gl.js
- run: npm run test-integration-ci
if: success() || failure()

render-tests:
name: Render tests
Expand All @@ -101,17 +105,23 @@ jobs:
run: nohup Xvfb &
echo "DISPLAY=:0" >> $GITHUB_ENV
- run: npm run build-dist
- run: npm run test-render
- name: Run Render tests
run: npm run test-render
env:
CURRENT_SPLIT_INDEX: ${{ matrix.split }}
if: success() || failure()
- name: Upload coverage reports to Codecov
if: '!cancelled()'
uses: codecov/codecov-action@v4
with:
files: ${{ github.workspace }}/coverage/render/codecov.json
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
- name: Upload test results to Codecov
if: '!cancelled()'
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload render test failure
if: failure()
uses: actions/upload-artifact@v4
Expand All @@ -133,4 +143,3 @@ jobs:
- run: npm ci
- run: npm run build-dist
- run: npm run test-build-ci
if: success() || failure()
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ npm-debug.log
*.iml
/.vs/
.*.swp
junit.xml
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const config: Config = {
coverageProvider: 'v8',
reporters: [
'github-actions',
'jest-junit',
['jest-monocart-coverage', {
name: 'MapLibre Unit Coverage Report',

Expand Down
71 changes: 71 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@maplibre/maplibre-gl-style-spec": "^20.1.1",
"@types/geojson": "^7946.0.14",
"@types/geojson-vt": "3.2.5",
"@types/junit-report-builder": "^3.0.2",
"@types/mapbox__point-geometry": "^0.1.4",
"@types/mapbox__vector-tile": "^1.3.4",
"@types/pbf": "^3.0.5",
Expand Down Expand Up @@ -99,10 +100,12 @@
"is-builtin-module": "^3.2.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-junit": "^16.0.0",
"jest-monocart-coverage": "^1.1.0",
"jest-webgl-canvas-mock": "^2.5.3",
"jsdom": "^24.0.0",
"json-stringify-pretty-compact": "^4.0.0",
"junit-report-builder": "^3.2.1",
"minimist": "^1.2.8",
"mock-geolocation": "^1.0.11",
"monocart-coverage-reports": "^2.7.9",
Expand Down
44 changes: 28 additions & 16 deletions test/integration/render/run_render_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import puppeteer, {Page, Browser} from 'puppeteer';
import {CoverageReport} from 'monocart-coverage-reports';
import {localizeURLs} from '../lib/localize-urls';
import type {Map, CanvasSource, PointLike, StyleSpecification} from '../../../dist/maplibre-gl';
import jnuitReportBuilder, {type TestSuite} from 'junit-report-builder';
import * as maplibreglModule from '../../../dist/maplibre-gl';

const __dirname = dirname(fileURLToPath(import.meta.url));
Expand Down Expand Up @@ -670,30 +671,41 @@ function printProgress(test: TestData, total: number, index: number) {
}
}

function printSpecificStatistics(status: 'passed' | 'failed' | 'errored', subsetStats: TestData[], total: number, suite: TestSuite) {
const statusCount = subsetStats.length;
if (statusCount === 0) {
return;
}
console.log(`${statusCount} ${status} (${(100 * statusCount / total).toFixed(1)}%)`);
for (const testData of subsetStats) {
const testCase = suite.testCase().className(testData.id).name(testData.id);
if (status === 'failed') {
testCase.failure();
} else if (status === 'errored') {
testCase.error();
}
}
if (status === 'passed') {
return;
}
for (let i = 0; i < subsetStats.length; i++) {
printProgress(subsetStats[i], statusCount, i + 1);
}
}

/**
* Prints the summary at the end of the run
*
* @param tests - all the tests with their results
* @returns `true` if all the tests passed
*/
function printStatistics(stats: TestStats): boolean {
const suite = jnuitReportBuilder.testSuite().name('render-tests');
printSpecificStatistics('passed', stats.passed, stats.total, suite);
printSpecificStatistics('failed', stats.failed, stats.total, suite);
printSpecificStatistics('errored', stats.errored, stats.total, suite);

function printStat(status: string, subsetStats: TestData[]) {
const statusCount = subsetStats.length;
if (statusCount > 0) {
console.log(`${statusCount} ${status} (${(100 * statusCount / stats.total).toFixed(1)}%)`);
if (status !== 'passed') {
for (let i = 0; i < subsetStats.length; i++) {
printProgress(subsetStats[i], statusCount, i + 1);
}
}
}
}

printStat('passed', stats.passed);
printStat('failed', stats.failed);
printStat('errored', stats.errored);

jnuitReportBuilder.writeTo('junit.xml');
return (stats.failed.length + stats.errored.length) === 0;
}

Expand Down