-
Notifications
You must be signed in to change notification settings - Fork 195
155 lines (143 loc) · 6.4 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
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 }}
permissions:
pull-requests: read
steps:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files_yaml: |
styles:
- components/*/index.css
- components/*/themes/spectrum.css
- components/*/themes/express.css
eslint:
- components/*/stories/*.js
# -------------------------------------------------------------
# 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 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
# The build step ensures we are leveraging the cache for the build
needs: [vrt]
# Note: the goal here is to allow vrt to be skipped but still require the build to succeed
if: ${{ always() }}
uses: ./.github/workflows/publish-site.yml
with:
deploy-message: ${{ github.event.pull_request.title }}
alias: pr-${{ github.event.number }}
# Only pass the storybook url if the vrt was successful
storybook-url: ${{ needs.vrt.outputs.storybook-url || '' }}
secrets: inherit