Skip to content

Commit c5f78c4

Browse files
committed
chore: ci rework
1 parent ed24ed4 commit c5f78c4

22 files changed

+1562
-185
lines changed

.github/CONTRIBUTING.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,21 @@ To generate a new component, run the generator:
6565
yarn new component
6666
```
6767

68-
Build the project, open a live-reloading browser window, and watch for changes:
68+
To kick-off the project's storybook locally, run:
69+
70+
```shell
71+
yarn start
72+
```
73+
74+
This is our development environment, where you can see all the components in action, and develop new components. All components must have a storybook entry.
75+
76+
Working on the documentation site? Run:
6977

7078
```shell
7179
yarn dev
7280
```
7381

74-
Commit changes with a [conventional commit message](https://www.conventionalcommits.org), making sure to correctly use `feat:`, `fix:`, and `BREAKING CHANGE` accordingly, and referencing the relevant issue number (if any):
82+
Commit all changes with a [conventional commit message](https://www.conventionalcommits.org), making sure to correctly use `feat:`, `fix:`, and `BREAKING CHANGE` accordingly, and referencing the relevant issue number (if any):
7583

7684
```shell
7785
git commit -m "fix(calendar): rendering issue in Safari, fixes #252"
@@ -84,6 +92,12 @@ git fetch upstream
8492
git merge upstream/main
8593
```
8694

95+
Run your updates through the formatter which will automatically fix any linting issues. Note that this is also handled on commit via lint-staged so running this manually is only necessary if you used a `--no-verify` flag on any of your commits.
96+
97+
```shell
98+
nx affected --target format
99+
```
100+
87101
Review your changes and any possible conflicts and push to your fork:
88102

89103
```shell
@@ -96,7 +110,7 @@ At this point you're waiting on us. We do our best to keep on top of all the pul
96110

97111
Some things that will increase the chance that your pull request is accepted:
98112

99-
- Write a thorough pull request description, include screenshots, and test your changes across all evergreen browsers.
100-
- Write out your test cases for any new features or bug fixes in as much detail as possible and include them in the pull request description.
101-
- Make sure the PR merges cleanly with the latest main.
102-
- Describe your feature/bugfix and why it's needed/important in the pull request description.
113+
- Write a thorough pull request description, include screenshots, and test your changes across all evergreen browsers.
114+
- Write out your test cases for any new features or bug fixes in as much detail as possible and include them in the pull request description.
115+
- Make sure the PR merges cleanly with the latest main.
116+
- Describe your feature/bugfix and why it's needed/important in the pull request description.

.github/ISSUE_TEMPLATE/--bug-report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ assignees: pfulton, castastrophe
2626

2727
## Environment
2828

29-
- **Version of the impacted component(s):** <!-- 2.13.0 -->
30-
- **Browser(s) and OS(s):** <!-- Chrome 75.0.3770.142 on Win 10 -->
29+
- **Version of the impacted component(s):** <!-- 2.13.0 -->
30+
- **Browser(s) and OS(s):** <!-- Chrome 75.0.3770.142 on Win 10 -->
3131

3232
## Additional context
3333

.github/ISSUE_TEMPLATE/--support-request.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ assignees: pfulton, castastrophe
1616

1717
## Environment
1818

19-
- **Spectrum CSS version:** <!-- 2.13.0 -->
20-
- **Browser(s) and OS(s):** <!-- Chrome 75.0.3770.142 on Win 10 -->
19+
- **Spectrum CSS version:** <!-- 2.13.0 -->
20+
- **Browser(s) and OS(s):** <!-- Chrome 75.0.3770.142 on Win 10 -->
2121

2222
## Additional context
2323

.github/README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# GitHub Actions, templates, and bots (oh my!)
2+
3+
The goal of this documentation is to provide an outline for the GitHub goodness that exists in this folder. This is a living document, so please feel free to contribute to it.
4+
5+
## Architecture
6+
7+
```bash
8+
⎪ actions
9+
├── file-diff
10+
├──── action.yml - this defines the inputs and outputs of the action
11+
├──── index.js - the code that runs the action
12+
├──── package.json - has dependencies so has package
13+
├──── README.md - more documentation yay!
14+
⎪ workflows
15+
├── development.yml - run on pull requests only
16+
├── production.yml - runs only on pushes to main
17+
├── vrt.yml - a reusable workflow that can be called by other workflows (i.e., development.yml or production.yml) or called on it's own via [workflow dispatch](https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/).
18+
├── build.yml - builds a branch and outputs the compiled assets as artifacts
19+
├── compare-results.yml - compares the compiled assets between the pull request branch and the main branch
20+
```
21+
22+
**But wait! There's more!**
23+
24+
```bash
25+
⎪ ISSUE_TEMPLATE
26+
├── --bug-report.md
27+
├── --documentation-issue.md
28+
├── --feature-request.md
29+
├── --support-request.md
30+
⎪ PULL_REQUEST_TEMPLATE.md
31+
⎪ CONTRIBUTING.md
32+
⎪ dependabot.yml
33+
```
34+
35+
## Actions
36+
37+
### File Diff
38+
39+
This action is used to determine if a compiled asset has changed between two branches. See the [README](./file-diff/README.md) for more information.
40+
41+
## Workflows
42+
43+
### Development
44+
45+
This workflow runs:
46+
47+
- on pull requests when:
48+
- opened against the `main` branch
49+
- opened, reopened, synchronized (i.e., when a commit is pushed to the pull request), labeled or unlabeled, or if auto merge is enabled
50+
- any files other than markdown have changed (i.e., will not run on a pull request that only changes markdown files)
51+
52+
#### What does this workflow do?
53+
54+
##### 👷‍♀️ Build
55+
56+
Builds the pull request branch against various development environments. Installs dependencies and builds the project looking for basic processing errors.
57+
58+
##### 👷‍♀️ Compare results
59+
60+
Compares the compiled assets between the pull request branch and the base branch. If there are differences, a comment is added to the pull request with a table detailing the files and the size differences.
61+
62+
_to-do_: This needs to diff the actual content of the files as well. Right now we're leveraging a canary approach which would catch any file size changes to the compiled assets. However, **if the content of the file changes but the size doesn't, we won't catch that**.
63+
64+
##### 🧹 Linting
65+
66+
Runs stylelint or eslint if any relevant assets have been updated in this PR.
67+
68+
##### 📝 Publish site
69+
70+
After the build and visual regression tests have passed, this will build the docs site and publish it to Netlify.
71+
72+
##### 📸 Visual regression testing
73+
74+
Run these tests if the `run_vrt` label is added to the pull request.
75+
76+
**OR** the pull request is not in a draft state and is mergeable (meaning no conflicts with the base branch)
77+
78+
**OR** the pull request review request is approved.
79+
80+
The only step in this job is to run the `vrt.yml` workflow.
81+
82+
### Production
83+
84+
This workflow runs:
85+
86+
- on pushes to the `main` branch
87+
88+
#### What does this workflow do?
89+
90+
##### 👷🏾 1. Build
91+
92+
Builds the `main` branch and outputs the compiled assets as artifacts.
93+
94+
##### 📝 2. Publish site
95+
96+
Publish the docs site to Netlify.
97+
98+
##### 📸 3. Visual regression testing
99+
100+
Run the visual regression testing for **ALL** pushes to the `main` branch. Triggers the `vrt.yml` workflow, see below for more information.
101+
102+
<!-- ##### 💾 Auto-updates
103+
104+
If a pull request includes the `auto-update` label and uses `main` as the base branch, this workflow will run. It will attempt to update the pull request with the latest changes from `main` but will fail gracefully if there are conflicts. Conflicts will need to be resolved manually. -->
105+
106+
### Visual regression testing
107+
108+
First, why is this a workflow and not it's own action? We want to be able to trigger the visual regression test manually via the GitHub UI or dynamically via another workflow. It also doesn't need to run in the same container as the rest of the workflow. An action is a definition of tasks and runs in the context it's called within while a workflow runs in it's own container.

.github/actions/file-diff/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# File diff
2+
3+
A GitHub Action for comparing compiled assets between branches.
4+
5+
## Inputs
6+
7+
### `path`
8+
9+
**Required** Path to file or directory for file sizes analysis.
10+
11+
### `diff-path`
12+
13+
**Optional** Path to another directory against which to perform file comparisons.
14+
15+
### `token`
16+
17+
**Optional** GitHub token for accessing the GitHub API. Defaults to `${{ github.token }}`.
18+
19+
### `file-glob-pattern`
20+
21+
**Optional** Glob pattern for selecting files to compare. Defaults to `dist/*`.
22+
23+
### `comment`
24+
25+
**Optional** If true, add a comment on the pull request with the results of the comparison. Defaults to `true`.
26+
27+
### `comment-header`
28+
29+
**Optional** Header content for the comment. Markdown is supported. Defaults to `## File metrics`.
30+
31+
## Outputs
32+
33+
### `has-changed`
34+
35+
True if the overall file size has changed, false otherwise.
36+
37+
### `total-size`
38+
39+
Total size of all files for this branch in bytes.
40+
41+
## Example usage
42+
43+
```yaml
44+
name: Compare compiled output file size
45+
uses: "spectrum-tools/gh-action-file-diff"
46+
with:
47+
path: ${{ github.workspace }}/pull-request
48+
diff-path: ${{ github.workspace }}/base-branch
49+
file-glob-pattern: |
50+
components/*/dist/*.{css,json}
51+
components/*/dist/themes/*.css
52+
```

.github/actions/file-diff/action.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "File comparisons"
2+
description: "Compares files between branches."
3+
author: "spectrum-tools"
4+
inputs:
5+
path:
6+
description: "Path to file or directory for file sizes analysis."
7+
required: false
8+
default: ${{ github.workspace }}
9+
diff-path:
10+
description: "Optional path to another directory to perform file size diff against the provided path."
11+
required: false
12+
token:
13+
description: "GITHUB_TOKEN for the repository."
14+
required: false
15+
default: ${{ github.token }}
16+
file-glob-pattern:
17+
description: "Glob pattern for filtering of the files."
18+
required: false
19+
default: "**/dist/**"
20+
comment:
21+
description: "Whether to comment on the PR."
22+
required: false
23+
default: "true"
24+
comment-header:
25+
description: "Comment header to be used in the PR comment."
26+
required: false
27+
default: "## File metrics"
28+
outputs:
29+
has-changed:
30+
description: "True if the overall file size has changed."
31+
total-size:
32+
description: "Total size of the files in bytes."
33+
runs:
34+
using: "node20"
35+
main: "index.js"

0 commit comments

Comments
 (0)