Skip to content

Commit 6b17330

Browse files
authored
Merge branch 'main' into hoc-rich-vertical-list
2 parents 4401179 + 510f79d commit 6b17330

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+960
-121
lines changed

.github/actions/percy-snapshot/action.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ runs:
3838

3939
- name: Install dependencies
4040
shell: bash
41-
run: yarn && pip3 install -r requirements.txt
41+
run: yarn install && pip3 install -r requirements.txt
4242

4343
- name: Build
4444
shell: bash
@@ -80,13 +80,16 @@ runs:
8080
id: percy_snapshot
8181
env:
8282
PERCY_TOKEN: ${{ inputs.percy_token_write }}
83-
# This identifies the diff by name in the percy diffs list
83+
# This is used to name the build on the Percy dashboard. For PRs, it is `pull/{pr_number}`, and for baseline, it is `main`.
8484
PERCY_BRANCH: ${{ inputs.branch_name }}
85+
# HEAD commit SHA signature that triggered this test
8586
PERCY_COMMIT: ${{ inputs.commitsh }}
86-
PERCY_CLIENT_ERROR_LOGS: false
8787
# If PR number is set & a Percy-GHA integration is set up, this allows Percy to set status on the PR
8888
PERCY_PULL_REQUEST: ${{ inputs.pr_number }}
89+
# GH runner sometimes runs into issues loading assets (large images especially) in the default 30s timeout.
90+
# This increases the timeout to 2 minutes to allow for more time to load assets.
8991
PERCY_PAGE_LOAD_TIMEOUT: 120000
92+
# Debugging vars to show more console output and diagnose issues with Percy
9093
LOG_LEVEL: debug
9194
PERCY_DEBUG: "*"
9295
run: |

.github/workflows/percy-baseline.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This workflow updates the Percy baseline on every push to main.
2+
# This allows pull requests to be compared against baseline test results.
3+
14
name: Update Percy Baseline
25

36
on:

.github/workflows/percy-prepare.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This workflow is triggered by the `pr-percy-prepare` workflows.
2-
# It checks out the SCSS/example markup changes and uploads them to Github as an artifact.
2+
# It checks out the SCSS/example markup changes and uploads them to GitHub as an artifact.
33
name: "Prepare Percy build"
44

55
on:
@@ -16,9 +16,10 @@ on:
1616

1717
jobs:
1818
copy_artifact:
19-
name: Copy changed files to GHA artifact
19+
name: Copy visual testing files to GitHub Actions artifact
2020
runs-on: ubuntu-latest
2121
steps:
22+
# Checkout only the files that are needed for visual testing and safe for the snapshots workflow to run
2223
- name: Checkout repo
2324
uses: actions/checkout@v4
2425
with:
@@ -31,7 +32,7 @@ jobs:
3132
3233
- name: Populate artifact directory
3334
run: |
34-
# Create needed directories so `cp` doesn't fail
35+
# Create needed directories so `cp` doesn't fail. This is for backwards compatibility with PRs that are based on commits that don't have these directories.
3536
# If a PR is made that doesn't have these directories in the source, the CPs at the end of the step will fail
3637
mkdir -p artifact
3738
mkdir -p tokens
@@ -45,9 +46,9 @@ jobs:
4546
# underscore-prefixed directories are ignored by GH artifacts, so we need to copy to a non-prefixed directory
4647
cp -R templates/_macros/. templates/macros/
4748
49+
# Copy all of the needed files to the artifact directory
4850
cp -R templates/docs/examples/ templates/macros/ scss/ tokens/ sd.config.json artifact/
4951
50-
5152
# Archive the PR number associated with this workflow since it won't be available in the base workflow context
5253
# https://github.com/orgs/community/discussions/25220
5354
- name: Archive PR data
@@ -59,6 +60,7 @@ jobs:
5960
echo "Contents of artifact"
6061
tree .
6162
63+
# Upload artifact so the `pr-percy-snapshots` workflow can pick it up
6264
- name: Upload artifact
6365
uses: actions/upload-artifact@v4
6466
with:

.github/workflows/pr-percy-snapshots.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,24 @@ jobs:
2121
percy_org_id: ${{ steps.percy_snapshot.outputs.org_id }}
2222
percy_build_id: ${{ steps.percy_snapshot.outputs.build_id }}
2323
steps:
24+
# Checkout `main` branch of Vanilla
2425
- name: Checkout SCM
2526
uses: actions/checkout@v4
2627

2728
- name: Remove SCM directories that will be replaced by artifact files
28-
run: |
29-
set -e
30-
rm -rf templates/docs/examples/ templates/_macros/ tokens/ sd.config.json scss/
29+
run: rm -rf templates/docs/examples/ templates/_macros/ tokens/ sd.config.json scss/
3130

32-
- name: Download artifact from workflow run
31+
- name: Download artifact from prepare workflow
3332
uses: actions/download-artifact@v4
3433
with:
3534
name: "percy-testing-web-artifact"
3635
github-token: ${{ secrets.GITHUB_TOKEN }}
3736
repository: ${{ github.event.workflow_run.repository.full_name }}
3837
run-id: ${{ github.event.workflow_run.id }}
3938

39+
# Downloading the artifact in the previous step also extracts its contents into `./`.
40+
# However, there are some files in the artifact that are not in the same place as Vanilla expects them to be.
41+
# This step moves those files to the correct place.
4042
- name: Move artifact files into place to replace SCM
4143
run: |
4244
# ensure the examples & macros dirs exist for backwards compatibility in case they aren't in the PR artifact
@@ -48,15 +50,19 @@ jobs:
4850
mv examples/ templates/docs/.
4951
mv macros/ templates/_macros
5052
53+
# The `pr_num.txt` and `pr_head_sha.txt` files are used to pass the PR number and head SHA from the PR to this workflow.
54+
# This is required as the `workflow_run` context of this workflow has no access to the context of the PR that triggered the `pr-percy-prepare` workflow.
5155
- name: Get PR data
5256
if: github.event.workflow_run.event=='pull_request'
5357
id: get_pr_data
5458
run: |
5559
echo "sha=$(cat pr_head_sha.txt)" >> $GITHUB_OUTPUT
5660
echo "pr_number=$(cat pr_num.txt)" >> $GITHUB_OUTPUT
61+
# Debugging step to show the full contents of the filesystem just before the Percy snapshot step
5762
tree
5863
59-
- name: Take snapshots & upload to Percy
64+
# Composite action uses the filesystem we have prepared for it with this workflow
65+
- name: Build, run, and test Vanilla
6066
id: percy_snapshot
6167
uses: "./.github/actions/percy-snapshot"
6268
with:

guides/percy-workflow.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
## Percy visual testing
2+
3+
We use [Percy](https://percy.io) for visual testing. Percy tests are run against pull requests to
4+
ensure that PRs do not introduce visual regressions. Your PR will be tested by Percy if it meets the following conditions:
5+
6+
- PR is against the `main` branch
7+
- One of the following is true:
8+
- PR passes Percy selectivity filters
9+
- PR makes changes to any of the following directories or files:
10+
- `scss/`
11+
- `templates/docs/examples/`
12+
- `templates/_macros/`
13+
- `tokens/`
14+
- `sd.config.json`
15+
- PR is not a draft
16+
- PR is labeled with "Review: Percy needed"
17+
- Note that a Percy (labeled) workflow will be triggered on each labelling and synchronisation event on PRs to `main`. They will be skipped shortly after starting if the PR does not have the "Review: Percy needed" label.
18+
19+
To ensure optimal Percy usage, we suggest the following PR flow:
20+
21+
1. Open the PR (against `main`) as a draft. Ensure that all non-Percy PR status checks pass.
22+
2. Apply the "Review: Percy needed" label to the PR to trigger a Percy test.
23+
3. Review the initial Percy build. After a few minutes, it will be available on our [Percy dashboard](https://percy.io/bb49709b/vanilla-framework). You can also click the Percy status check on the PR to navigate directly to the test results.
24+
25+
<img src="https://assets.ubuntu.com/v1/a4b79af3-percy_status_check.png" alt="Percy status check" width="400">
26+
27+
4. If there are additional changes needed to the PR through the review process, you can remove the "Review: Percy needed"
28+
label and mark the PR as a draft to prevent additional Percy tests from running. Any commits you add to the PR will not trigger a Percy test, as long as the PR is a draft and does not have the "Review: Percy needed" label.
29+
5. Once the PR is ready for final review, remove the draft status and reapply the "Review: Percy needed" label to trigger
30+
a final Percy test.
31+
6. If the Percy test passes, apply "Review: Percy +1" to indicate that the PR has passed Percy testing.
32+
33+
### Workflows
34+
35+
#### Baseline Workflow
36+
37+
The [baseline workflow](../.github/workflows/percy-baseline.yml) runs a Percy test on every push to `main`, and sets the results
38+
as the new Percy baseline that all future PRs will be compared against.
39+
40+
#### Prepare Workflow
41+
42+
The [prepare workflow](../.github/workflows/percy-prepare.yml) checks out a merge commit of a PR and `main`, then
43+
uploads all files in the PR that have any affects on the visual appearance of the design system as a GitHub artefact.
44+
45+
#### PR Snapshot Workflow
46+
47+
The [snapshot workflow](../.github/workflows/pr-percy-snapshots.yml) downloads the artefacts from the [prepare workflow](#prepare-workflow)
48+
and calls the [Percy snapshot action](../.github/actions/percy-snapshot/action.yml) to build, run, & visually test Vanilla.
49+
50+
The PR snapshot workflow is always called after the completion of the [prepare workflow](#prepare-workflow).
51+
52+
### Example snapshots
53+
54+
Percy is run by executing `yarn percy` or `npm run percy` in the root of the project. The [Percy CLI](https://github.com/percy/cli)
55+
runs [snapshots.js](../snapshots.js) which returns a list of all the snapshots that Percy will take.
56+
57+
Percy uses our [examples](https://vanillaframework.io/docs/examples) to take snapshots of all components, patterns, and utilities in Vanilla.
58+
59+
[snapshots.js](../snapshots.js) will take a snapshot of an example template file if the following conditions are met:
60+
61+
- Is an HTML file in `templates/docs/examples/`
62+
- File is not a partial (does not start with `_`)
63+
- File is not included in a combined example (is not in the same directory as a combined example or in a directory that descends from a directory with a combined example)
64+
65+
#### Snapshot widths
66+
67+
Each snapshot object returned by [snapshots.js](../snapshots.js) has a `widths` array property that specifies the widths (in pixels) at which the snapshot should be captured.
68+
The following table shows the widths at which snapshots are captured and which examples they apply to:
69+
70+
| Device | Width (px) | Captured on |
71+
| ------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
72+
| Desktop | 1,280 | All examples |
73+
| Tablet | 800 | All examples with `responsive` in their names, and [combined examples](#combined-examples) that include a `responsive` file in their directory |
74+
| Mobile | 375 | Default theme only (currently `light`) |
75+
76+
Each width is captured as a separate screenshot, and counts as an additional screenshot in Percy's pricing model.
77+
78+
#### Snapshot browsers
79+
80+
Percy can be configured to take snapshots in multiple browsers. Each additional browser counts as an additional set of screenshots in Percy's pricing model.
81+
Vanilla is currently only tested on Chrome. To add additional browsers, view the [Percy project settings page](https://percy.io/bb49709b/vanilla-framework/settings).
82+
83+
#### Combined examples
84+
85+
Combined examples are a way to show all the variants of a component or pattern on the same page. This helps us keep our
86+
Percy usage down by only taking one snapshot of a component or pattern, rather than one for each variant.
87+
Combined examples follow a naming convention: they must be named `combined.html`.
88+
If `combined.html` is found in a directory, [snapshots.js](../snapshots.js) will assume that every example in that directory (and its subdirectories) is rendered in the `combined.html` file.
89+
90+
**Combined examples do not currently include the JavaScript or CSS that is included in individual examples by `{% block script %}` and `{% block style %}` tags.**
91+
92+
##### Creating a combined example
93+
94+
1. Create a Jinja template file named `combined.html` in any subdirectory of `templates/docs/examples/`
95+
2. In your `content` block, create a `with` block that sets the flag `is_combined` to `true`. This will ensure that the [base example template](../templates/_layouts/examples.html) renders the example without the `{% block script %}` and `{% block style %}` tags and adds links to the individual examples.
96+
3. Include the examples you want to combine in the `combined.html` file using `{% include 'path/to/example.html' %}` inside the `with` block. It is good practice to separate the examples in `<section>` tags.
97+
98+
For example, see the [combined example for the button pattern](../templates/docs/examples/patterns/buttons/combined.html).
99+
100+
##### Spacing below examples
101+
102+
If an example's content is expected to overflow its body (such as a dropdown or tooltip), you can use the `spacing_below` parameter to add space below the example.
103+
`spacing_below` `rems` will be added beneath the example as `margin-bottom`.
104+
105+
For example:
106+
107+
```html
108+
<!-- Add `12rem` of space below the example -->
109+
{% with spacing_below = 12 %}
110+
<section>{% include 'docs/examples/patterns/contextual-menu/default.html' %}</section>
111+
{% endwith %}
112+
```
113+
114+
### Testing
115+
116+
[snapshots.test.js](../tests/snapshots.test.js) is a [Jest](https://jestjs.io/) testing file used to test the output of the [snapshots.js](../snapshots.js) file.
117+
It tests that the snapshots are correctly generated. It is run as part of our wider testing script (`yarn test`), but you can also execute it directly by running `npx jest tests/snapshots.test.js`.
118+
119+
[snapshots.js](../snapshots.js) considers `combined.html` to require responsive snapshots if a sibling or descendant file contains `responsive` in its name.
120+
[snapshots.test.js](../tests/snapshots.test.js) does not read the filesystem to decide whether a combined snapshot is responsive.
121+
If you add a combined example that must be captured responsively, you must add the path of that example to `RESPONSIVE_COMBINED_EXAMPLES` in [snapshots.test.js](../tests/snapshots.test.js).
122+
123+
### PR File Inclusion
124+
125+
Only some of a pull request's files are represented in each pull request snapshot test. Depending on which files need to be changed,
126+
you may need to make a separate pull request to make changes to `main` before a pull request will use your changes in Percy testing.
127+
128+
#### Files included in Percy tests
129+
130+
- Visual files:
131+
- `scss/`
132+
- `templates/docs/examples/`
133+
- `templates/_macros/`
134+
- `tokens/`
135+
- `sd.config.json`
136+
- Workflows that are run on the `pull_request` trigger, including (but not limited to):
137+
- [Prepare workflow](../.github/workflows/percy-prepare.yml)
138+
- [Prepare (labelled) workflow](../.github/workflows/pr-percy-prepare-label.yml)
139+
- [Prepare (pushed) workflow](../.github/workflows/pr-percy-prepare-push.yml)
140+
141+
Changes to other files should be added to a separate PR and merged before testing a PR that requires their changes.
142+
Otherwise, the changes will not be included in Percy tests.
143+
This notably includes:
144+
145+
- Dependencies
146+
- `Dockerfile`
147+
- `package.json`
148+
- `requirements.txt`
149+
- Workflows that are run on the `workflow_run` trigger:
150+
- [PR snapshots workflow](../.github/workflows/pr-percy-snapshots.yml)
151+
- [Snapshot action](../.github/actions/percy-snapshot/action.yml)
152+
- `snapshots.js` and `snapshots.test.js`
153+
154+
### Additional resources
155+
156+
- [Percy CLI documentation](https://www.browserstack.com/docs/percy/take-percy-snapshots/snapshots-via-cli#advanced-options)
157+
- [Percy environment variables](https://www.browserstack.com/docs/percy/get-started/set-env-var#Percy_SDK)
158+
- [Percy workflow blog post](https://ubuntu.com/blog/visual-testing-github-actions-migration-test-optimisation)

guides/pull-requests.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,7 @@ apply the relevant `-1` Labels.
8080

8181
#### Percy visual testing
8282

83-
We use [Percy](https://percy.io) for visual testing. Percy tests are run against pull requests to
84-
ensure that PRs to not introduce visual regressions. Your PR will be tested by Percy if it meets the following conditions:
85-
86-
- PR is against the `main` branch
87-
- One of the following is true:
88-
- PR passes Percy selectivity filters
89-
- PR changes files in the `scss/`, `templates/docs/examples/`, or `templates/_macros/` directories
90-
- PR is not a draft
91-
- PR is labeled with "Review: Percy needed"
92-
93-
To ensure optimal Percy usage, we suggest the following PR flow:
94-
95-
1. Open the PR (against `main`) in such a way that it causes an initial Percy test to run.
96-
- If your PR makes changes to files in the above directories, it will be automatically
97-
tested as long as it is not marked as a draft.
98-
- Applying the "Review: Percy needed" label to the PR ensures that it is always tested.
99-
2. Review the initial [Percy build](https://percy.io/bb49709b/vanilla-framework).
100-
3. If there are additional changes needed to the PR through the review process, you can remove the "Review: Percy needed"
101-
label and mark the PR as a draft to prevent additional Percy tests from running.
102-
4. Once the PR is ready for final review, remove the draft status and reapply the "Review: Percy needed" label to trigger
103-
a final Percy test.
104-
5. If the Percy test passes, apply "Review: Percy +1" to indicate that the PR has passed Percy testing.
105-
6. If all other reviews have been completed, the PR is ready to be merged.
83+
Please review the [Percy visual testing](percy-workflow.md) documentation for a detailed overview of how to work with the Percy visual testing system.
10684

10785
#### Merging a PR
10886

releases.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88
url: /docs/base/forms#fieldset
99
status: New
1010
notes: We've introduced <code>is-required</code> to legend fieldset elements.
11+
- component: Rule
12+
url: /docs/patterns/rule#default
13+
status: Deprecated
14+
notes: We've deprecated the <code>.p-rule</code> component. Use the <a href="/docs/base/separators#no-bottom-margin">HR with no bottom margin</a> instead.
15+
- component: Separator
16+
url: /docs/base/separators
17+
status: New
18+
notes: We've added <code>.is-highlighted</code> and <code>.is-highlighted.is-accent</code> classes to the base horizontal rule.
19+
- component: Image container
20+
url: /docs/patterns/images#image-container-with-aspect-ratio
21+
status: New
22+
notes: We've added new breakpoint-specific aspect ratio classes to the image container component.
23+
- component: Tiered list
24+
url: /docs/patterns/tiered-list
25+
status: Updated
26+
notes: We've added new CTA block usage examples for the tiered list pattern.
1127
- component: Rich list / vertical
1228
url: /docs/patterns/rich-list#vertical
1329
status: New

scss/_base_hr.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
background-color: $colors--theme--border-low-contrast;
3636
}
3737

38+
&.is-highlighted {
39+
@include vf-highlight-bar($colors--theme--text-default);
40+
41+
&.is-accent {
42+
@include vf-highlight-bar($color-accent);
43+
}
44+
}
45+
3846
&.u-no-margin--bottom {
3947
// compensate for hr thickness, to make sure it doesn't drift from baseline grid
4048
@extend %u-no-margin--bottom--hr;

scss/_layouts_fluid-breakout.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
grid-column: 2 / -1;
150150
grid-template-columns: repeat(2, minmax(0, 1fr));
151151

152-
@media (max-width: $threshold-4-6-col - 1) {
152+
@media (width < $threshold-4-6-col) {
153153
grid-template-columns: repeat(1, minmax(0, 1fr));
154154
width: $l-fluid-breakout-main-child-width;
155155
}
@@ -163,7 +163,7 @@
163163
&:nth-child(2) {
164164
justify-content: flex-end;
165165

166-
@media (max-width: $threshold-4-6-col - 1) {
166+
@media (width < $threshold-4-6-col) {
167167
justify-content: flex-start;
168168
}
169169
}

scss/_patterns_article-pagination.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
padding-left: $sp-xx-large;
5656
text-align: left;
5757

58-
@media (max-width: $breakpoint-x-small - 1) {
58+
@media (width < $breakpoint-x-small) {
5959
margin-right: 0;
6060
width: auto;
6161

@@ -84,7 +84,7 @@
8484
padding-right: $sp-xx-large;
8585
text-align: right;
8686

87-
@media (max-width: $breakpoint-x-small - 1) {
87+
@media (width < $breakpoint-x-small) {
8888
width: 100%;
8989
}
9090

0 commit comments

Comments
 (0)