Skip to content

Commit

Permalink
Merge branch 'master' into add-clean-script
Browse files Browse the repository at this point in the history
  • Loading branch information
developit authored Jun 21, 2021
2 parents f96e95e + fa703d2 commit d6fad5b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 22 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
```
### Customizing the Build
Expand Down Expand Up @@ -66,7 +64,6 @@ jobs:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
+ build-script: "ci"
```

Expand Down Expand Up @@ -114,7 +111,6 @@ jobs:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
+ pattern: "./build-output/**/*.{js,css,html,json}"
+ exclude: "{./build-output/manifest.json,**/*.map,**/node_modules/**}"
```
Expand Down Expand Up @@ -157,3 +153,12 @@ By default, a file that's been changed by a single byte will be reported as chan
```

In the above example, a file with a delta of less than 100 bytes will be reported as unchanged.

### Compression

By default, files are compared after gzip compression, but it's possible to use other compression algorithms (`gzip/brotli/none`) or disable the compression.

```yaml
compression: 'none'
```

3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ branding:
inputs:
repo-token:
description: 'The GITHUB_TOKEN secret'
required: true
required: false
default: ${{ github.token }}
clean-script:
description: 'An npm-script that cleans/resets state between branch builds'
build-script:
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async function createCheck(octokit, context) {

(async () => {
try {
const token = getInput('repo-token', { required: true });
const token = getInput('repo-token');
const octokit = getOctokit(token);
await run(octokit, context, token);
} catch (e) {
Expand Down
11 changes: 10 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,16 @@ function markdownTable(rows) {
}

const [firstRow] = rows;
const columnLength = firstRow.length;
let columnLength = firstRow.length;

// Hide `Change` column if they are all `0 B`
if (columnLength === 3 &rows.every(columns => columns[2] === '0 B')) {
columnLength -= 1;
for (const columns of rows) {
columns.pop();
}
}

if (columnLength === 0) {
return '';
}
Expand Down
30 changes: 15 additions & 15 deletions tests/__snapshots__/utils.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ exports[`diffTable 1`] = `
<details><summary>ℹ️ <strong>View Unchanged</strong></summary>
| Filename | Size | Change |
| :--- | :---: | :---: |
| \`three.js\` | 300 B | 0 B |
| Filename | Size |
| :--- | :---: |
| \`three.js\` | 300 B |
</details>
Expand All @@ -31,9 +31,9 @@ exports[`diffTable 2`] = `
<details><summary>ℹ️ <strong>View Unchanged</strong></summary>
| Filename | Size | Change |
| :--- | :---: | :---: |
| \`three.js\` | 300 B | 0 B |
| Filename | Size |
| :--- | :---: |
| \`three.js\` | 300 B |
</details>
Expand Down Expand Up @@ -96,12 +96,12 @@ exports[`diffTable 6`] = `
<details><summary>ℹ️ <strong>View Unchanged</strong></summary>
| Filename | Size | Change |
| :--- | :---: | :---: |
| \`one.js\` | 5 kB | 0 B |
| \`two.js\` | 5 kB | 0 B |
| \`three.js\` | 300 B | 0 B |
| \`four.js\` | 4.5 kB | 0 B |
| Filename | Size |
| :--- | :---: |
| \`one.js\` | 5 kB |
| \`two.js\` | 5 kB |
| \`three.js\` | 300 B |
| \`four.js\` | 4.5 kB |
</details>
Expand All @@ -117,9 +117,9 @@ exports[`diffTable 7`] = `
<details><summary>ℹ️ <strong>View Unchanged</strong></summary>
| Filename | Size | Change |
| :--- | :---: | :---: |
| \`three.js\` | 300 B | 0 B |
| Filename | Size |
| :--- | :---: |
| \`three.js\` | 300 B |
</details>
Expand Down

0 comments on commit d6fad5b

Please sign in to comment.