-
Notifications
You must be signed in to change notification settings - Fork 196
196 lines (178 loc) · 7.81 KB
/
development.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
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
188
189
190
191
192
193
194
195
196
name:
Verify
# -------------------------------------------------------------
# This workflow will build and verify pull requests. It will:
# - Build the base branch and the PR branch
# - Compare the compiled output of the two branches
# - Run visual regression tests on the PR branch
# - Publish the PR branch to Netlify for review
# -------------------------------------------------------------
on:
merge_group:
pull_request:
branches:
- main
- spectrum-two
# Allow us to run tests for PRs updating github actions
- chore-*ci*
- chore-*github-actions*
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
- auto_merge_enabled
permissions:
contents: read
pull-requests: write
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
# -------------------------------------------------------------
# Validate build for various environments
# -------------------------------------------------------------
verify_builds:
name: Verify
# Check that the PR is not in draft mode (or if it is, that it has the run_ci label to force a build)
if: ${{ github.event.pull_request.draft != 'true' || contains(github.event.pull_request.labels.*.name, 'run_ci') }}
strategy:
fail-fast: false
matrix:
system:
- macos-latest
- ubuntu-latest
# - windows-latest # todo: debug token style-dictionary failures on windows
node-version:
- 20
uses: ./.github/workflows/build.yml
with:
system: ${{ matrix.system }}
node-version: ${{ matrix.node-version }}
secrets: inherit
# -------------------------------------------------------------
# Compare the compiled assets
# -------------------------------------------------------------
compare:
name: Compare
# Check that the PR is not in draft mode (or if it is, that it has the run_ci label to force a build)
if: ${{ github.event.pull_request.draft != 'true' || contains(github.event.pull_request.labels.*.name, 'run_ci') }}
uses: ./.github/workflows/compare-results.yml
with:
base-sha: ${{ github.event.pull_request.base.ref }}
head-sha: ${{ github.event.pull_request.head.ref }}
secrets: inherit
# -------------------------------------------------------------
# Returns all changed pull request files.
# --------------------------------------------------------------
changed_files:
runs-on: ubuntu-latest
name: Capture changed-files
outputs:
styles_added_files: ${{ steps.changed-files.outputs.styles_added_files }}
styles_modified_files: ${{ steps.changed-files.outputs.styles_modified_files }}
eslint_added_files: ${{ steps.changed-files.outputs.eslint_added_files }}
eslint_modified_files: ${{ steps.changed-files.outputs.eslint_modified_files }}
plugins_modified_files: ${{ steps.changed-files.outputs.plugins_modified_files }}
plugins_added_files: ${{ steps.changed-files.outputs.plugins_added_files }}
permissions:
pull-requests: read
steps:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files_yaml: |
styles:
- components/*/index.css
- components/*/themes/spectrum.css
- components/*/themes/express.css
eslint:
- components/*/stories/*.js
plugins:
- plugins/**/*
# -------------------------------------------------------------
# Lint pre-compiled assets for consistency
# -------------------------------------------------------------
lint:
name: Lint
if: ${{ contains(github.event.pull_request.labels.*.name, 'skip_lint') == false }}
needs: [changed_files]
uses: ./.github/workflows/lint.yml
with:
styles_added_files: ${{ needs.changed_files.outputs.styles_added_files }}
styles_modified_files: ${{ needs.changed_files.outputs.styles_modified_files }}
eslint_added_files: ${{ needs.changed_files.outputs.eslint_added_files }}
eslint_modified_files: ${{ needs.changed_files.outputs.eslint_modified_files }}
secrets: inherit
# -------------------------------------------------------------
# Run the test suites for the plugins if there are changes
# to any of the plugin files
# -------------------------------------------------------------
plugin_tests:
name: Plugin tests
runs-on: ubuntu-latest
needs: [changed_files]
if: ${{ needs.changed_files.outputs.plugins_added_files != '' || needs.changed_files.outputs.plugins_modified_files != '' }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Use Node LTS version
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Enable Corepack
run: corepack enable
## --- YARN CACHE --- ##
- name: Check for cached dependencies
continue-on-error: true
id: cache-dependencies
uses: actions/cache@v4
with:
path: |
.cache/yarn
node_modules
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }}
## --- INSTALL --- ##
# If statement isn't needed here b/c yarn will leverage the cache if it exists
- name: Install dependencies
shell: bash
run: yarn install --immutable
## --- Run plugins test suites --- ##
- name: Run plugin tests
run: yarn test:plugins
# -------------------------------------------------------------
# RUN VISUAL REGRESSION TESTS --- #
# Run VRT on:
# - ALL pull_request where:
# - PR has label 'run_vrt'
# - NOT in draft UNLESS labels includes 'run_ci'
# - PR is mergeable
# Note: mergeable implies ONLY that no merge conflicts with the base
# branch; nothing about other checks, like CI, passing.
# Note: 'skip_vrt' label is used to pass the tasks but not actually
# publish to Chromatic
# -------------------------------------------------------------
vrt:
name: Testing
if: contains(github.event.pull_request.labels.*.name, 'run_vrt') || ((github.event.pull_request.draft != true || contains(github.event.pull_request.labels.*.name, 'run_ci')) && github.event.pull_request.mergeable == true)
uses: ./.github/workflows/vrt.yml
with:
skip: ${{ github.base_ref == 'spectrum-two' || contains(github.event.pull_request.labels.*.name, 'skip_vrt') }}
secrets: inherit
# -------------------------------------------------------------
# PUBLISH TO NETLIFY --- #
# Publish to netlify by leveraging the previous build and then building the site as well
# -------------------------------------------------------------
publish_site:
name: Publish
uses: ./.github/workflows/publish-site.yml
with:
deploy-message: ${{ github.event.pull_request.title }}
alias: pr-${{ github.event.number }}
secrets: inherit