-
Notifications
You must be signed in to change notification settings - Fork 104
187 lines (180 loc) · 7.54 KB
/
Copy pathmain.yml
File metadata and controls
187 lines (180 loc) · 7.54 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
detect-visual-changes:
name: Detect visual changes
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
should_run: ${{ steps.filter.outputs.styles == 'true' || steps.filter.outputs.runtime == 'true' || steps.filter.outputs.tests == 'true' || steps.filter.outputs.infrastructure == 'true' }}
steps:
- name: ⬇️ Checkout
uses: actions/checkout@v4
- name: 🔎 Detect visual changes
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
styles:
- 'packages/stacks-classic/lib/**/*.less'
runtime:
- 'packages/stacks-classic/lib/index.ts'
- 'packages/stacks-classic/lib/esm-no-css.ts'
- 'packages/stacks-classic/lib/controllers.ts'
- 'packages/stacks-classic/lib/stacks.ts'
- 'packages/stacks-classic/lib/components/**/!(*.test|*.test.setup|*.fixtures).ts'
tests:
- 'packages/stacks-classic/lib/**/*.visual.test.ts'
- 'packages/stacks-classic/lib/**/*.test.setup.ts'
- 'packages/stacks-classic/lib/**/*.fixtures.ts'
- 'packages/stacks-classic/lib/test/test-utils.ts'
- 'packages/stacks-classic/lib/test/visual-test-utils.ts'
infrastructure:
- '.gitattributes'
- '.github/workflows/main.yml'
- '.github/workflows/test.yml'
- 'package.json'
- 'packages/stacks-classic/package.json'
- 'packages/stacks-classic/run-test-visual.ps1'
- 'packages/stacks-classic/screenshots/**'
- 'packages/stacks-classic/web-test-runner.config.mjs'
- 'packages/stacks-classic/web-test-runner.config.ci.mjs'
build-and-test:
name: ${{ matrix.command_description }}
uses: ./.github/workflows/test.yml
strategy:
fail-fast: false
matrix:
include:
- command_description: Build
command: npm run build
needs_lfs: false
needs_playwright: false
- command_description: Lint
command: npm run lint
needs_lfs: false
needs_playwright: false
- command_description: Less Tests
command: npm run test:less -w packages/stacks-classic
needs_lfs: false
needs_playwright: false
- command_description: Unit Tests
command: npm run test:unit -w packages/stacks-classic -- --config web-test-runner.config.ci.mjs
needs_lfs: false
needs_playwright: true
- command_description: A11y Tests
command: npm run test:a11y -w packages/stacks-classic -- --config web-test-runner.config.ci.mjs
needs_lfs: false
needs_playwright: true
- command_description: Package Tests (stacks-classic)
command: npm run test:package -w packages/stacks-classic
needs_lfs: false
needs_playwright: true
- command_description: Unit Tests (stacks-svelte)
command: npm run test -w packages/stacks-svelte
needs_lfs: false
needs_playwright: true
- command_description: Unit Tests (stacks-utils)
command: npm run test -w packages/stacks-utils
needs_lfs: false
needs_playwright: false
- command_description: Package Tests (stacks-utils)
command: npm run test:package -w packages/stacks-utils
needs_lfs: false
needs_playwright: false
- command_description: Unit Tests (stacks-docs)
command: npm run test -w packages/stacks-docs
needs_lfs: false
needs_playwright: false
- command_description: Unit Tests (stacks-email)
command: npm run test -w packages/stacks-email
needs_lfs: false
needs_playwright: false
- command_description: Release Configuration Tests
command: npm run test:release
needs_lfs: false
needs_playwright: false
with:
command: ${{ matrix.command }}
command_description: ${{ matrix.command_description }}
needs_playwright: ${{ matrix.needs_playwright }}
needs_lfs: ${{ matrix.needs_lfs }}
secrets: inherit
visual-regression-tests:
name: Visual Regression Tests
needs: detect-visual-changes
if: ${{ always() }}
uses: ./.github/workflows/test.yml
with:
command: npm run test:visual:ci -w packages/stacks-classic -- --config ./visual-runner/stacks-classic-runner-config/web-test-runner.config.ci.mjs
command_description: Visual Regression Tests
needs_lfs: true
needs_playwright: false # we are using playwright docker image to run visual tests
should_run: ${{ needs.detect-visual-changes.result != 'success' || needs.detect-visual-changes.outputs.should_run == 'true' }}
secrets: inherit
release:
name: "Release (main)"
if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.build-and-test.result == 'success' && (needs.visual-regression-tests.result == 'success' || needs.visual-regression-tests.result == 'skipped') }}
needs: [build-and-test, visual-regression-tests]
runs-on: ubuntu-latest
timeout-minutes: 20
env:
BETTER_AUTH_SECRET: ${{ secrets.AUTH_SECRET || 'ci-build-placeholder-secret' }}
outputs:
published: ${{ steps.changesets.outputs.published }}
steps:
- uses: actions/checkout@v5
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "npm"
- name: Install dependencies
run: |
npm ci
npm run build
- name: Prepare ignored-only changesets
run: node .github/scripts/prepare-ignored-changesets.mjs "$RUNNER_TEMP"
- name: 🚀 Create/Update Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
version: npm run version
publish: npm run release
title: "chore(new-release)"
commit: "chore(new-release)"
branch: main
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.STACKS_TOOLING_GH_RW_PAT }}
NPM_TOKEN: ${{ secrets.NPM_API_KEY }}
- name: Docs on Release Pull Request
# run only if there is a release pull request open
if: steps.changesets.outputs.pullRequestNumber
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: "pr-release-docs"
pr-number: ${{ steps.changesets.outputs.pullRequestNumber }}
message: |
To trigger the build for this PR, **close and re-open it**.
This is necessary because the PR is updated by github-actions[bot].
This is a technical user which does not trigger actions workflows on push events.
See this GH issue for more details: https://github.com/changesets/action/issues/187
- name: Deploy docs site
if: steps.changesets.outputs.published == 'true'
run: bash .github/scripts/deploy-netlify.sh
env:
NETLIFY_API_TOKEN: ${{ secrets.NETLIFY_API_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_BRANCH: main
NETLIFY_DEPLOY_TITLE: Release docs deploy
# cancel the jobs if another workflow is kicked off for the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}