Skip to content

Commit ecf3e46

Browse files
authored
Add annotations when consumer test fails (#1857)
* Add annotation step to test_types workflow * Remove branch restriction from `pull_request` event * Make tsconfig.build.json fail consumer test * Add always() to if clause in test_types workflow * Use clearer failed() instead of always() * Remove brackets from workflow if * s/status/conclusion * s/failed/failure * Add longer annotation * Format workflow echo * Attempt to use cat for multi-line annotation * Rename to consumer test * Add issue context links * Nicer links in consumer test readme * Revert "Make tsconfig.build.json fail consumer test" This reverts commit f6a3678. * Add consumer-test to eslintrc ignore
1 parent f7b8a3a commit ecf3e46

File tree

6 files changed

+37
-6
lines changed

6 files changed

+37
-6
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"lib/**/*",
2424
"lib-*/**/*",
2525
"types/**/*",
26-
"test-types/**/*"
26+
"consumer-test/**/*"
2727
],
2828
"globals": {
2929
"__DEV__": "readonly"

.github/workflows/test_types.yml renamed to .github/workflows/consumer_test.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Test types
1+
name: Consumer test
22
on:
33
push: {branches: main}
4-
pull_request: {branches: main}
4+
pull_request:
55
workflow_dispatch:
66

77
jobs:
8-
test-types:
9-
name: Test types
8+
consumer-test:
9+
name: Consumer test
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout repository
@@ -38,8 +38,14 @@ jobs:
3838
run: npm link
3939

4040
- name: Link and test
41-
working-directory: test-types
41+
id: link-and-test
42+
working-directory: consumer-test
4243
run: |
4344
npm install
4445
npm link @primer/react
4546
npm run check
47+
48+
- name: Add annotation
49+
if: failure() && steps.link-and-test.conclusion == 'failure'
50+
run: |
51+
echo "::error file=tsconfig.build.json::Test package could not build. See https://github.com/primer/react/blob/main/consumer-test"
File renamed without changes.

consumer-test/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Primer React Consumer Test
2+
3+
This directory is used to run a simple test that asserts that a consumer of
4+
Primer React can build their own project with strict TypeScript options enabled,
5+
including `"skipLibCheck": false`.
6+
7+
During Primer React's build process, we run the TypeScript compiler and output
8+
`.d.ts` declaration files for consumers of Primer React that are using
9+
TypeScript. If the build script runs with a TypeScript configuration that has
10+
any files in its `types` or `typeRoots` that import any of our development
11+
dependencies, it's possible for our build output to be polluted by interface
12+
augmentations in those dependencies, or in transitive dependencies.
13+
14+
The best way to avoid this is to ensure that any files that import development
15+
dependencies are excluded in our `tsconfig.build.json` file we use to build
16+
Primer React.
17+
18+
If a mistake is made and a file is omitted, we will catch those when we attempt
19+
to build this consumer library, which has `"skipLibCheck": false` in its
20+
TypeScript configuration.
21+
22+
For historical context, see these issues:
23+
24+
- [v27.0.0 breaks TypeScript typings](https://github.com/primer/react/issues/1163)
25+
- [Storybook dependency changes types in build output](https://github.com/primer/react/issues/1849)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)