Skip to content

Commit 21c4812

Browse files
feat: add CI workflow for tests with Allure v3 reporting (#72)
* feat: add CI workflow for tests with Allure reporting - Created a GitHub Actions workflow to run tests on pull requests to the main branch. - Integrated Allure reporting for test results. - Added configuration for Allure report generation in allurerc.mjs. - Set up Vitest configuration to manage test projects and reporting. - Introduced shared Vitest configuration for consistent test setup across projects. * feat: add quality gate configuration to Allure report * feat: update report name in Allure configuration to "Repository Tests" * feat: add build step before running tests in CI workflow * feat: update Allure reporting configuration and add css-js-gen tests * feat: improve testing cases and implement Allure report * feat: restructure CI workflows for Allure reporting and remove deprecated configuration
1 parent 42cefd7 commit 21c4812

13 files changed

Lines changed: 3065 additions & 477 deletions

File tree

‎.changeset/blue-trams-serve.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"css-js-gen": patch
3+
---
4+
5+
Improve testing cases and implement allure report

‎.github/workflows/ci-pull-request.yml‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,4 @@ jobs:
5959
secrets: inherit
6060
uses: withstudiocms/automations/.github/workflows/preview-pr.yml@f286863f2f7a414794b9a10ee6f1cadbb07f722f # main
6161
with:
62-
build-cmd: "pnpm ci:build"
63-
64-
css-js-gen-tests:
65-
name: Run css-js-gen Tests
66-
if: github.event_name == 'pull_request'
67-
permissions:
68-
contents: read
69-
pull-requests: write
70-
uses: withstudiocms/automations/.github/workflows/run-pnpm.yml@f286863f2f7a414794b9a10ee6f1cadbb07f722f # main
71-
secrets: inherit
72-
with:
73-
commands: >
74-
["ci:test:css-js-gen"]
62+
build-cmd: "pnpm ci:build"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Tests with Allure Report
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
checks: write
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Setup Apollo Git Bot
17+
id: bot-token
18+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
19+
with:
20+
app-id: ${{ secrets.STUDIOCMS_GIT_BOT_APP_ID }}
21+
private-key: ${{ secrets.STUDIOCMS_GIT_BOT_PRIVATE_KEY }}
22+
23+
- name: Checkout Repo
24+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
persist-credentials: false
27+
token: ${{ steps.bot-token.outputs.token }}
28+
29+
- name: Install Tools & Dependencies
30+
uses: withstudiocms/automations/.github/actions/install@f286863f2f7a414794b9a10ee6f1cadbb07f722f # main
31+
32+
- name: Build packages
33+
run: pnpm ci:build
34+
35+
- name: Run tests and generate report
36+
run: pnpm ci:test
37+
38+
- name: Deploy
39+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
40+
with:
41+
github_token: ${{ steps.bot-token.outputs.token }}
42+
publish_branch: test-report
43+
publish_dir: ./allure-report
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Tests with Allure Report
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
pull-requests: write
9+
checks: write
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Setup Apollo Git Bot
16+
id: bot-token
17+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
18+
with:
19+
app-id: ${{ secrets.STUDIOCMS_GIT_BOT_APP_ID }}
20+
private-key: ${{ secrets.STUDIOCMS_GIT_BOT_PRIVATE_KEY }}
21+
22+
- name: Checkout Repo
23+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
with:
25+
persist-credentials: false
26+
token: ${{ steps.bot-token.outputs.token }}
27+
28+
- name: Install Tools & Dependencies
29+
uses: withstudiocms/automations/.github/actions/install@f286863f2f7a414794b9a10ee6f1cadbb07f722f # main
30+
31+
- name: Build packages
32+
run: pnpm ci:build
33+
34+
- name: Run tests and generate report
35+
run: pnpm ci:test
36+
37+
- name: Run Allure Action
38+
uses: allure-framework/allure-action@c24234151c027cfee99e00eb6ec2dac1eb350414 # v0.6.6
39+
with:
40+
report-directory: "./allure-report"
41+
github-token: ${{ steps.bot-token.outputs.token }}

‎.gitignore‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ node_modules
22
.npmrc
33
.tsbuildinfo
44
build
5-
dist
5+
dist
6+
7+
# allure testing
8+
allure-results
9+
allure-report
10+
history.jsonl
11+
junit-report.xml

‎.vscode/settings.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"cSpell.words": [
2828
"Adammatthiesen",
29+
"allurereport",
2930
"astrojs",
3031
"automations",
3132
"codepaths",
@@ -41,6 +42,7 @@
4142
"mondeja",
4243
"noline",
4344
"omglookatthis",
45+
"peaceiris",
4446
"recompiles",
4547
"rehype",
4648
"rgba",

‎allurerc.mjs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { defineConfig } from "allure";
2+
3+
export default defineConfig({
4+
name: "Allure Report",
5+
output: "./allure-report",
6+
historyPath: "./history.jsonl",
7+
appendHistory: true,
8+
qualityGate: {
9+
rules: [
10+
{
11+
maxFailures: 0,
12+
fastFail: true,
13+
},
14+
],
15+
},
16+
plugins: {
17+
"css-js-gen": {
18+
import: "@allurereport/plugin-awesome",
19+
options: {
20+
reportName: "css-js-gen Tests",
21+
singleFile: false,
22+
reportLanguage: "en",
23+
open: false,
24+
publish: true,
25+
groupBy: ["parentSuite", "suite", "subSuite"],
26+
filter: ({ labels }) =>
27+
labels.find(({ name, value }) => name === "parentSuite" && value === "css-js-gen Tests"),
28+
},
29+
},
30+
log: {
31+
options: {
32+
groupBy: "none",
33+
},
34+
},
35+
},
36+
});

‎package.json‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,29 @@
2525

2626
"build": "pnpm --filter './packages/*' build",
2727
"dev": "pnpm --filter './packages/*' --filter playground -r --parallel dev",
28-
"test": "pnpm --filter './packages/*' test",
28+
"test": "vitest",
2929

3030
"ci:install": "pnpm install --frozen-lockfile",
3131
"ci:version": "changeset version",
3232
"ci:publish": "changeset publish",
3333
"ci:build": "pnpm build",
3434
"ci:lint": "pnpm lint",
35-
"ci:test:css-js-gen": "pnpm --filter css-js-gen test"
35+
"ci:test": "allure run -- pnpm test",
36+
37+
"allure:view": "allure open allure-report"
3638
},
3739
"devDependencies": {
40+
"@allurereport/plugin-awesome": "^3.1.0",
3841
"@biomejs/biome": "^2.3.14",
3942
"@changesets/cli": "^2.29.8",
4043
"@changesets/config": "^3.1.2",
4144
"@changesets/changelog-github": "^0.5.2",
4245
"@types/node": "catalog:",
4346
"@vitest/ui": "^4.0.18",
47+
"@vitest/runner": "^4.0.18",
48+
"allure": "^3.1.0",
49+
"allure-js-commons": "^3.4.5",
50+
"allure-vitest": "^3.4.5",
4451
"tsdown": "^0.20.3",
4552
"typescript": "^5.9.3",
4653
"pkg-pr-new": "^0.0.63",

0 commit comments

Comments
 (0)