GeezerVison is showing github.com — test: restore all-skipped coverage guard with custom reporter · docker/actions-toolkit@b1b6c30
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/test.yml +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 47 | 47 | - | 48 | 48 | name: Check coverage | 49 | 49 | run: | | 50 | | - if [ -f ./coverage/clover.xml ]; then | | 50 | + if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then | 51 | 51 | echo "RUN_CODECOV=true" >> $GITHUB_ENV | 52 | 52 | else | 53 | 53 | echo "RUN_CODECOV=false" >> $GITHUB_ENV | @@ -217,7 +217,7 @@ jobs: | 217 | 217 | - | 218 | 218 | name: Check coverage | 219 | 219 | run: | | 220 | | - if [ -f ./coverage/clover.xml ]; then | | 220 | + if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then | 221 | 221 | echo "RUN_CODECOV=true" >> $GITHUB_ENV | 222 | 222 | else | 223 | 223 | echo "RUN_CODECOV=false" >> $GITHUB_ENV | |
Collapse file Copy file name to clipboard +19Lines changed: 19 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/** | | 2 | + * Copyright 2026 actions-toolkit authors | | 3 | + * | | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | | 5 | + * you may not use this file except in compliance with the License. | | 6 | + * You may obtain a copy of the License at | | 7 | + * | | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | | 9 | + * | | 10 | + * Unless required by applicable law or agreed to in writing, software | | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 13 | + * See the License for the specific language governing permissions and | | 14 | + * limitations under the License. | | 15 | + */ | | 16 | + | | 17 | +import type {Reporter} from 'vitest/node'; | | 18 | + | | 19 | +export declare const vitestAllSkippedReporter: () => Reporter; |
Collapse file Copy file name to clipboard +59Lines changed: 59 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/** | | 2 | + * Copyright 2026 actions-toolkit authors | | 3 | + * | | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | | 5 | + * you may not use this file except in compliance with the License. | | 6 | + * You may obtain a copy of the License at | | 7 | + * | | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | | 9 | + * | | 10 | + * Unless required by applicable law or agreed to in writing, software | | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 13 | + * See the License for the specific language governing permissions and | | 14 | + * limitations under the License. | | 15 | + */ | | 16 | + | | 17 | +import fs from 'node:fs'; | | 18 | +import path from 'node:path'; | | 19 | + | | 20 | +export const vitestAllSkippedReporter = () => { | | 21 | + let vitest; | | 22 | + let hasExecutedTest; | | 23 | + let hasAnyCollectedTest; | | 24 | + | | 25 | + const getFlagPath = () => { | | 26 | + const reportsDirectory = vitest?.config?.coverage?.reportsDirectory ?? 'coverage'; | | 27 | + return path.join(reportsDirectory, 'allSkipped.txt'); | | 28 | + }; | | 29 | + | | 30 | + return { | | 31 | + onInit(ctx) { | | 32 | + vitest = ctx; | | 33 | + hasExecutedTest = false; | | 34 | + hasAnyCollectedTest = false; | | 35 | + }, | | 36 | + onTestCaseReady() { | | 37 | + hasAnyCollectedTest = true; | | 38 | + }, | | 39 | + onTestCaseResult(testCase) { | | 40 | + const state = testCase.result()?.state; | | 41 | + if (state === 'passed' || state === 'failed') { | | 42 | + hasExecutedTest = true; | | 43 | + } | | 44 | + }, | | 45 | + onTestRunEnd() { | | 46 | + if (!vitest?.config?.coverage?.enabled) { | | 47 | + return; | | 48 | + } | | 49 | + const allSkipped = hasAnyCollectedTest && !hasExecutedTest; | | 50 | + const flagPath = getFlagPath(); | | 51 | + if (allSkipped) { | | 52 | + fs.mkdirSync(path.dirname(flagPath), {recursive: true}); | | 53 | + fs.writeFileSync(flagPath, ''); | | 54 | + } else if (fs.existsSync(flagPath)) { | | 55 | + fs.rmSync(flagPath); | | 56 | + } | | 57 | + } | | 58 | + }; | | 59 | +}; |
Collapse file Copy file name to clipboardExpand all lines: vitest.config.itg.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | */ | 16 | 16 |
| 17 | 17 | import {defineConfig} from 'vitest/config'; | | 18 | +import {vitestAllSkippedReporter} from './__tests__/.setup/skipped-reporter.mjs'; | 18 | 19 |
| 19 | 20 | export default defineConfig({ | 20 | 21 | test: { | 21 | 22 | clearMocks: true, | 22 | 23 | environment: 'node', | 23 | 24 | include: ['**/*.test.itg.ts'], | 24 | 25 | testTimeout: 1800000, | | 26 | + reporters: ['default', vitestAllSkippedReporter()], | 25 | 27 | coverage: { | 26 | 28 | provider: 'v8', | 27 | 29 | reporter: ['clover'], | 28 | 30 | include: ['src/**/*.ts'], | 29 | | - exclude: ['src/**/index.ts'] | | 31 | + exclude: ['src/**/index.ts', '__tests__/**', 'lib/**'] | 30 | 32 | } | 31 | 33 | } | 32 | 34 | }); |
Collapse file Copy file name to clipboardExpand all lines: vitest.config.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | */ | 16 | 16 |
| 17 | 17 | import {defineConfig} from 'vitest/config'; | | 18 | +import {vitestAllSkippedReporter} from './__tests__/.setup/skipped-reporter.mjs'; | 18 | 19 |
| 19 | 20 | export default defineConfig({ | 20 | 21 | test: { | 21 | 22 | clearMocks: true, | 22 | 23 | environment: 'node', | 23 | 24 | setupFiles: ['./__tests__/.setup/setup.unit.ts'], | 24 | 25 | include: ['**/*.test.ts'], | | 26 | + reporters: ['default', vitestAllSkippedReporter()], | 25 | 27 | coverage: { | 26 | 28 | provider: 'v8', | 27 | 29 | reporter: ['clover'], | 28 | 30 | include: ['src/**/*.ts'], | 29 | | - exclude: ['src/**/index.ts'] | | 31 | + exclude: ['src/**/index.ts', '__tests__/**', 'lib/**'] | 30 | 32 | } | 31 | 33 | } | 32 | 34 | }); |
|