Skip to content

Commit dc40a51

Browse files
authored
Created documentation for configuration (ArtiomTr#84)
1 parent 967c78d commit dc40a51

10 files changed

+166
-21
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"editor.codeActionsOnSave": {
33
"source.fixAll": true
4+
},
5+
"files.associations": {
6+
"*.md": "mdx"
47
}
58
}

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ inputs:
2424
default: emoji
2525
annotations:
2626
required: false
27-
description: 'What type of annotations show. Options: none, all'
27+
description: 'What type of annotations show. Options: none, coverage, failed-tests, all'
2828
default: all
2929
package-manager:
3030
required: false
139 KB
Loading
131 KB
Loading

docs/mdx.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ declare module '@mdx-js/react' {
3838
[key in ComponentType]?: React.ComponentType<{
3939
children: React.ReactNode;
4040
}>;
41+
} & {
42+
[key: string]: React.ComponentType;
4143
} & {
4244
a?: React.ComponentType<{ href: string }>;
4345
h1?: React.ComponentType<HeadingProps>;

docs/src/components/Header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const Header = ({ links }: HeaderProps) => {
5050
display="flex"
5151
maxW="container.lg"
5252
>
53-
<Link href="/">
53+
<Link href="/" passHref>
5454
<Logo
5555
className={classes['logo']}
5656
color="var(--chakra-colors-brand-600)"
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Flex, Heading, HeadingProps } from '@chakra-ui/react';
1+
import { Flex, Heading, HeadingProps, useStyleConfig } from '@chakra-ui/react';
22
import { HashIcon } from '@primer/octicons-react';
33
import Link from 'next/link';
44
import React from 'react';
@@ -7,19 +7,34 @@ import classes from './MarkdownHeading.module.scss';
77

88
export type MarkdownHeadingProps = HeadingProps;
99

10-
export const MarkdownHeading = ({ id, ...props }: MarkdownHeadingProps) => (
11-
<Link href={`#${id}`}>
12-
<Flex
13-
borderColor="gray.150"
14-
borderBottomWidth="thin"
15-
className={classes['heading']}
16-
alignItems="center"
17-
justifyContent="flex-start"
18-
marginY="3"
19-
>
20-
<span className={classes['heading__anchor']} id={id} />
21-
<HashIcon size={24} className={classes['heading__icon']} />
22-
<Heading {...props} />
23-
</Flex>
24-
</Link>
25-
);
10+
export const MarkdownHeading = ({
11+
id,
12+
children,
13+
...props
14+
}: MarkdownHeadingProps) => {
15+
const { fontSize } = useStyleConfig('Heading', props);
16+
17+
return (
18+
<Link href={`#${id}`}>
19+
<Flex
20+
borderColor="gray.150"
21+
borderBottomWidth="thin"
22+
className={classes['heading']}
23+
alignItems="center"
24+
justifyContent="flex-start"
25+
marginY="3"
26+
>
27+
<span className={classes['heading__anchor']} id={id} />
28+
<HashIcon size={24} className={classes['heading__icon']} />
29+
<Heading
30+
sx={{
31+
'--children-font-size': fontSize as string,
32+
}}
33+
{...props}
34+
>
35+
{children}
36+
</Heading>
37+
</Flex>
38+
</Link>
39+
);
40+
};

docs/src/components/markdown/components.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import React from 'react';
1111
import { Code } from './Code';
1212
import { MarkdownHeading } from './MarkdownHeading';
1313
import { MdLink } from './MdLink';
14+
import { ResponsiveImage } from '../ResponsiveImage';
1415

1516
export const components: Components = {
1617
h1: (props) => <MarkdownHeading as="h1" size="2xl" {...props} />,
@@ -25,5 +26,11 @@ export const components: Components = {
2526
a: MdLink,
2627
p: Text,
2728
code: Code,
28-
inlineCode: (props) => <ChakraInlineCode {...props} />,
29+
inlineCode: (props) => (
30+
<ChakraInlineCode
31+
fontSize="var(--children-font-size, var(--chakra-fontSizes-sm))"
32+
{...props}
33+
/>
34+
),
35+
ResponsiveImage,
2936
};

docs/src/pages/configuration.md

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: Configuration
3+
description: Documentation for the action's configuration. Described all inputs with examples.
4+
---
5+
6+
import CoverageAnnotationExample from 'assets/coverage-annotation-example.jpg';
7+
import FailedTestAnnotationExample from 'assets/failed-test-annotation-example.jpg';
8+
9+
# Configuration
10+
11+
Jest Coverage Report action's configuration is created in the same way as for [any other GitHub action](https://www.github.com/features/actions).
12+
13+
## github-token
14+
15+
GitHub token. Required parameter. By default, you can use standard GitHub-provided token: `${{ secrets.GITHUB_TOKEN }}`. Example:
16+
17+
```yaml
18+
- uses: artiomtr/jest-coverage-report-action@v2
19+
with:
20+
github-token: \${{ secrets.GITHUB_TOKEN }}
21+
```
22+
23+
## threshold
24+
25+
If you want to set minimal accepted coverage for the PR, you can pass and optional parameter threshold.
26+
27+
For example, if you want to reject every pull request, with total line coverage less than 80%:
28+
29+
```yaml
30+
- uses: artiomtr/jest-coverage-report-action@v2
31+
with:
32+
threshold: 80 # if coverage < 80%, action will fail
33+
```
34+
35+
## working-directory
36+
37+
If you want to run this action in custom directory, specify `working-directory`:
38+
39+
```yaml
40+
with:
41+
github-token: ${{ secrets.GITHUB_TOKEN }}
42+
working-directory: <dir>
43+
```
44+
45+
## test-script
46+
47+
By default, action will run this command, to extract coverage:
48+
49+
```bash
50+
npx jest --silent --ci --coverage --testLocationInResults --json --outputFile="report.json"
51+
```
52+
53+
If you're not satisfied with default behaviour, you can specify your own command, by passing custom option `test-script`.
54+
55+
<!-- TODO: replace link -->
56+
57+
**⚠ IMPORTANT: The test script must generate output in a specific format. For more information, see [docs](https://github.com/ArtiomTr/jest-coverage-report-action#customizing-test-script).**
58+
59+
For instance, if you want to run `test:coverage` npm script:
60+
61+
```yaml
62+
with:
63+
github-token: ${{ secrets.GITHUB_TOKEN }}
64+
test-script: npm run test:coverage
65+
```
66+
67+
## icons
68+
69+
If you don't satisfied with the standard icons, you can replace them with `icons` input. Example:
70+
71+
```yaml
72+
with:
73+
github-token: ${{ secrets.GITHUB_TOKEN }}
74+
icons: ascii
75+
```
76+
77+
Available options: `emoji` (standard), `ascii`, `unicode`.
78+
79+
## annotations
80+
81+
Annotations are enabled by default. To disable them, specify `annotations: none`. For instance:
82+
83+
```yaml
84+
with:
85+
github-token: ${{ secrets.GITHUB_TOKEN }}
86+
annotations: none
87+
```
88+
89+
If you want to enable only specific annotations, you can specify following choices:
90+
91+
### `annotations: coverage`
92+
93+
<ResponsiveImage width="100%" images={CoverageAnnotationExample.images} />
94+
95+
### `annotations: failed-tests`
96+
97+
<ResponsiveImage width="100%" images={FailedTestAnnotationExample.images} />
98+
99+
### package-manager
100+
101+
By default, action uses [npm](https://github.com/npm/cli#readme) package manager. But, if you want to use [yarn](https://github.com/yarnpkg/berry#readme), simply set `package-manager: yarn` option:
102+
103+
```yaml
104+
with:
105+
github-token: ${{ secrets.GITHUB_TOKEN }}
106+
package-manager: yarn
107+
```
108+
109+
### skip-step
110+
111+
If you've installed dependencies in previous step, or you already have `report.json` file, you can skip `install` or `all` steps. For instance:
112+
113+
```yaml
114+
with:
115+
github-token: ${{ secrets.GITHUB_TOKEN }}
116+
skip-step: install
117+
```

docs/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"jsx": "preserve",
1616
"baseUrl": ".",
1717
"paths": {
18-
"layouts/*": ["src/components/layouts/*"]
18+
"layouts/*": ["src/components/layouts/*"],
19+
"assets/*": ["assets/*"]
1920
}
2021
},
2122
"include": ["next-env.d.ts", "mdx.d.ts", "**/*.ts", "**/*.tsx"],

0 commit comments

Comments
 (0)