generated from withstudiocms/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (91 loc) · 3.32 KB
/
ci-testing.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: CI - Tests PRs & Main
on:
workflow_dispatch:
push:
paths:
- 'packages/**'
- 'vitest.config.mts'
branches: [main]
pull_request:
paths:
- 'packages/**'
- 'vitest.config.mts'
types:
- opened
- reopened
- synchronize
concurrency: testing-${{ github.ref }}
jobs:
run-tests:
name: Vitest Test
runs-on: ubuntu-latest
env:
NODE_OPTIONS: "--max_old_space_size=4096"
steps:
- name: Check out code using Git
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install Tools & Dependencies
uses: withstudiocms/automations/.github/actions/install@main
- name: Build Packages
run: pnpm ci:build
- name: Test Packages
run: pnpm ci:test
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: vitest-report
path: html
retention-days: 14
publish-tests:
name: Publish Test Results
if: ${{ !cancelled() }}
needs: [run-tests]
runs-on: ubuntu-latest
steps:
- name: Check out code using Git
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install Tools & Dependencies
uses: withstudiocms/automations/.github/actions/install@main
- name: Download HTML report from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
name: vitest-report
path: vitest-report
# If the push is to the main branch, deploy the test results to GitHub Pages under /vitest folder
- name: Deploy Test Results to GitHub Pages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.STUDIOCMS_SERVICE_TOKEN }}
folder: vitest-report
target-folder: vitest
force: false
clean: false
branch: test-results
# If the push is to a PR, deploy the test results to GitHub Pages under /pr-preview folder
- name: Deploy PR Test Results to GitHub Pages
uses: rossjrw/pr-preview-action@v1
id: preview-step
with:
token: ${{ secrets.STUDIOCMS_SERVICE_TOKEN }}
source-dir: vitest-report
umbrella-dir: pr-preview/vitest/
preview-branch: test-results
comment: false
- uses: marocchino/sticky-pull-request-comment@v2
if: steps.preview-step.outputs.deployment-action == 'deploy' && env.deployment_status == 'success'
with:
GITHUB_TOKEN: ${{ secrets.STUDIOCMS_SERVICE_TOKEN }}
header: pr-preview
message: |
# PR Test Results
Vitest Test Results: ${{ steps.preview-step.outputs.preview-url }}
- uses: marocchino/sticky-pull-request-comment@v2
if: steps.preview-step.outputs.deployment-action == 'remove' && env.deployment_status == 'success'
with:
GITHUB_TOKEN: ${{ secrets.STUDIOCMS_SERVICE_TOKEN }}
header: pr-preview
message: |
# PR Test Results
Results removed because the pull request was closed.
${{ steps.preview-step.outputs.action-start-time }}