Skip to content

Commit 2e8d8db

Browse files
ci(github-actions): publish tests resuls to GitHub
Fixes #33
1 parent 2b5d645 commit 2e8d8db

File tree

6 files changed

+126
-39
lines changed

6 files changed

+126
-39
lines changed

.github/workflows/tests.yml

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and tests
1+
name: Tests
22

33
on:
44

@@ -15,17 +15,22 @@ on:
1515
- 'vitest.config.ts'
1616
- 'eslint.config.mjs'
1717

18+
workflow_dispatch:
19+
1820
concurrency:
1921
group: ${{ github.workflow }}-${{ github.ref }}
2022
cancel-in-progress: true
2123

2224
permissions:
25+
contents: read
2326
actions: read
24-
issues: write # to be able to comment on released issues
25-
pull-requests: write # to be able to comment on released pull requests
27+
issues: write
28+
pull-requests: write
29+
checks: write
2630

2731
jobs:
2832
tests:
33+
name: "Testing"
2934

3035
strategy:
3136
matrix:
@@ -59,8 +64,79 @@ jobs:
5964
- name: Tests
6065
run: npm run test
6166

67+
- name: Upload Test Results
68+
if: always()
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: Test Results (OS ${{ matrix.os }} - Node.js ${{ matrix.node-version }})
72+
path: test/results/junit-report.xml
73+
6274
- name: Report Coverage
6375
# if: always()
6476
uses: davelosert/vitest-coverage-report-action@v2
6577
with:
6678
file-coverage-mode: all
79+
80+
publish-test-results:
81+
name: "Results publishing"
82+
needs: tests
83+
runs-on: ubuntu-latest
84+
permissions:
85+
checks: write
86+
# only needed unless run with comment_mode: off
87+
pull-requests: write
88+
# only needed for private repository
89+
contents: read
90+
# only needed for private repository
91+
issues: read
92+
if: always()
93+
94+
env:
95+
BADGE_COLOR: 696969
96+
97+
steps:
98+
99+
- name: Download artifacts
100+
uses: actions/download-artifact@v4
101+
with:
102+
path: test/results
103+
104+
- name: Publish tests results
105+
uses: EnricoMi/publish-unit-test-result-action@v2
106+
id: test-results
107+
with:
108+
files: "test/results/**/*.xml"
109+
110+
- name: Set badge color
111+
shell: bash
112+
run: |
113+
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
114+
success)
115+
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
116+
;;
117+
failure)
118+
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
119+
;;
120+
neutral)
121+
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
122+
;;
123+
esac
124+
125+
- name: Create badge
126+
uses: emibcn/[email protected]
127+
with:
128+
label: Tests
129+
status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}'
130+
color: ${{ env.BADGE_COLOR }}
131+
icon: data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiB2aWV3Qm94PSIwIDAgMjU2IDI1NiI+PGcgZmlsbD0ibm9uZSI+PHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIGZpbGw9IiMyNDI5MzgiIHJ4PSI2MCIvPjxwYXRoIGZpbGw9IiNmY2M3MmIiIGQ9Im0xNzguMDkgOTIuMzE5bC00Ny44MTMgNjkuMTMxYTQuMTE4IDQuMTE4IDAgMCAxLTYuNzc4LS4wMWE0LjA4IDQuMDggMCAwIDEtLjcwNi0yLjUwMmwxLjkxNC0zOC4xNjhsLTMwLjg5Mi02LjU1MWE0LjEgNC4xIDAgMCAxLTIuOTU2LTIuNDg0YTQuMDcgNC4wNyAwIDAgMSAuNDM1LTMuODNsNDcuODE0LTY5LjEzMWE0LjEyIDQuMTIgMCAwIDEgNC42OTktMS41NmE0LjEgNC4xIDAgMCAxIDIuMDc5IDEuNTcxYTQuMDcgNC4wNyAwIDAgMSAuNzA1IDIuNTAybC0xLjkxNCAzOC4xNjhsMzAuODkyIDYuNTVhNC4xIDQuMSAwIDAgMSAxLjc5Mi44NzRhNC4wNyA0LjA3IDAgMCAxIC43MjkgNS40NCIvPjxwYXRoIGZpbGw9IiM3MjliMWIiIGQ9Ik0xMjguMDE5IDIxOS40NTFhOS43IDkuNyAwIDAgMS0zLjcwNi0uNzM0YTkuNyA5LjcgMCAwIDEtMy4xNC0yLjEwMWwtNDUuMTc4LTQ1LjE3NWE5LjY4IDkuNjggMCAwIDEgNi44NS0xNi41MDhhOS42OCA5LjY4IDAgMCAxIDYuODQgMi44MTdsMzguMzM0IDM4LjMyOWw4My41MS04My41MDZhOS42ODMgOS42ODMgMCAwIDEgMTMuNjM0LjA1NWE5LjcgOS43IDAgMCAxIDIuODM3IDYuODA3YTkuNyA5LjcgMCAwIDEtMi43ODEgNi44MjhsLTkwLjM1NiA5MC4zNTNhOS42MyA5LjYzIDAgMCAxLTYuODQ0IDIuODM1Ii8+PHBhdGggZmlsbD0iIzcyOWIxYiIgZmlsbC1vcGFjaXR5PSIwLjUiIGQ9Ik0xMjcuOTggMjE5LjQ1MWE5LjcgOS43IDAgMCAwIDMuNzA2LS43MzRhOS43IDkuNyAwIDAgMCAzLjE0LTIuMTAxbDQ1LjE3OC00NS4xNzVhOS42OCA5LjY4IDAgMCAwLTEzLjY5MS0xMy42OTFsLTM4LjMzMyAzOC4zMjlsLTgzLjUxLTgzLjUwNmE5LjY4MyA5LjY4MyAwIDAgMC0xMy42MzQuMDU1YTkuNjgzIDkuNjgzIDAgMCAwLS4wNTYgMTMuNjM1bDkwLjM1NiA5MC4zNTNhOS42NSA5LjY1IDAgMCAwIDYuODQ0IDIuODM1Ii8+PC9nPjwvc3ZnPg==
132+
path: tests.svg
133+
134+
- name: Upload badge to Gist
135+
# if: >
136+
# github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
137+
# github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
138+
uses: andymckay/append-gist-action@6e8d64427fe47cbacf4ab6b890411f1d67c07f3e
139+
with:
140+
token: ${{ secrets.GIST_TOKEN }}
141+
gistURL: https://gist.githubusercontent.com/sergey-s-betke/d70e4de09a490afc9fb7a737363b231a
142+
file: tests.svg

.vscode/cSpell.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,21 @@
1212
"language": "ru,en",
1313
"dictionaries": [],
1414
"words": [
15+
"andymckay",
1516
"arethetypeswrong",
1617
"attw",
1718
"Betke",
1819
"blockquote",
1920
"commitlint",
2021
"conventionalcommits",
22+
"davelosert",
2123
"dependabot",
2224
"deps",
2325
"distclean",
2426
"editorconfig",
27+
"emibcn",
2528
"endregion",
29+
"esac",
2630
"findit",
2731
"gulpfile",
2832
"gulplog",
@@ -39,6 +43,7 @@
3943
"tssert",
4044
"tsup",
4145
"typecheck",
46+
"vitest",
4247
"winget"
4348
],
4449
"ignoreRegExpList": [

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@
139139
"typescript": "^5.6.3",
140140
"typescript-eslint": "^8.15.0",
141141
"vite-plugin-vitest-typescript-assert": "^1.1.4",
142-
"vitest": "^2.1.1",
143-
"vitest-github-actions-reporter": "^0.11.1"
142+
"vitest": "^2.1.1"
144143
}
145144
}

readme.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# gulp-intermediate2
22

3-
[![Build and Test Status](https://github.com/IT-Service-NPM/gulp-intermediate2/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/IT-Service-NPM/gulp-intermediate2/actions/workflows/tests.yml)
3+
[![Tests Status](https://github.com/IT-Service-NPM/gulp-intermediate2/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/IT-Service-NPM/gulp-intermediate2/actions/workflows/tests.yml)
4+
[![Tests Results](https://gist.githubusercontent.com/sergey-s-betke/d70e4de09a490afc9fb7a737363b231a/raw/tests.svg)](https://github.com/IT-Service-NPM/gulp-intermediate2/actions/workflows/tests.yml)
45

5-
[![GitHub release](https://img.shields.io/github/v/release/IT-Service-NPM/gulp-intermediate2.svg?sort=semver\&logo=github)](https://github.com/IT-Service-NPM/gulp-intermediate2/releases)
6+
[![GitHub release](https://img.shields.io/github/v/release/IT-Service-NPM/gulp-intermediate2.svg?sort=semver&logo=github)](https://github.com/IT-Service-NPM/gulp-intermediate2/releases)
67
[![NPM release](https://img.shields.io/npm/v/gulp-intermediate2.svg?logo=npm)](https://www.npmjs.com/package/gulp-intermediate2)
78

89
[![Semantic Versioning](https://img.shields.io/badge/Semantic%20Versioning-v2.0.0-green.svg?logo=semver)](https://semver.org/lang/ru/spec/v2.0.0.html)
@@ -30,23 +31,25 @@ Use `gulp-intermediate2` only if other (better) options aren’t available.
3031

3132
## Contents
3233

33-
* [Install](#install)
34-
* [Examples](#examples)
35-
* [Using old `intermediate` interface](#using-old-intermediate-interface)
36-
* [Copy UTF-8 files without options](#copy-utf-8-files-withoutoptions)
37-
* [Copy binary files](#copy-binary-files)
38-
* [Streaming mode support](#streaming-mode-support)
39-
* [Process without callback](#process-without-callback)
40-
* [API](#api)
41-
* [intermediate2(\[process\], \[options\])](#intermediate2process-options)
42-
* [options](#options)
43-
* [destOptions](#destoptions)
44-
* [srcOptions](#srcoptions)
45-
* [output](#output)
46-
* [container](#container)
47-
* [process(srcDirPath, destDirPath, cb)](#processsrcdirpath-destdirpath-cb)
48-
* [Notes](#notes)
49-
* [License](#license)
34+
- [gulp-intermediate2](#gulp-intermediate2)
35+
- [Contents](#contents)
36+
- [Install](#install)
37+
- [Examples](#examples)
38+
- [Using old `intermediate` interface](#using-old-intermediate-interface)
39+
- [Copy UTF-8 files without options](#copy-utf-8-files-withoutoptions)
40+
- [Copy binary files](#copy-binary-files)
41+
- [Streaming mode support](#streaming-mode-support)
42+
- [Process without callback](#process-without-callback)
43+
- [API](#api)
44+
- [intermediate2(\[process\], \[options\])](#intermediate2process-options)
45+
- [options](#options)
46+
- [destOptions](#destoptions)
47+
- [srcOptions](#srcoptions)
48+
- [output](#output)
49+
- [container](#container)
50+
- [process(srcDirPath, destDirPath, cb)](#processsrcdirpath-destdirpath-cb)
51+
- [Notes](#notes)
52+
- [License](#license)
5053

5154
## Install
5255

test/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
output*
22
coverage
3+
results

vitest.config.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
import { defineConfig } from 'vitest/config';
44
import { vitestTypescriptAssertPlugin } from 'vite-plugin-vitest-typescript-assert';
5-
import GithubActionsReporter from 'vitest-github-actions-reporter';
65

76
export default defineConfig({
8-
plugins: [
9-
vitestTypescriptAssertPlugin()
10-
],
11-
test: {
12-
coverage: {
13-
provider: 'istanbul',
14-
reporter: ['text', 'json-summary', 'json', 'lcov'],
15-
reportOnFailure: true,
16-
include: ['src/**']
17-
},
18-
reporters: process.env.GITHUB_ACTIONS
19-
? ['default', new GithubActionsReporter()]
20-
: 'default'
21-
},
7+
plugins: [
8+
vitestTypescriptAssertPlugin()
9+
],
10+
test: {
11+
coverage: {
12+
provider: 'istanbul',
13+
reporter: ['text', 'json-summary', 'json', 'lcov'],
14+
reportOnFailure: true,
15+
include: ['src/**']
16+
},
17+
reporters: process.env.GITHUB_ACTIONS
18+
? ['default', 'junit', 'json']
19+
: ['default'],
20+
outputFile: {
21+
junit: 'test/results/junit-report.xml',
22+
json: 'test/results/json-report.json',
23+
},
24+
},
2225
});

0 commit comments

Comments
 (0)