This repository has been archived by the owner on Jan 24, 2022. It is now read-only.
48 lines (46 loc) · 1.62 KB
/
size-impact.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: size-impact
on:
pull_request:
paths:
- "index.js"
- "src/**"
jobs:
size-impact:
strategy:
matrix:
os: [ubuntu-latest]
node: [13.8.0]
runs-on: ${{ matrix.os }}
name: node ${{ matrix.node }} on ${{ matrix.os }}
env:
CI: true
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: npm config
run: npm config set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Please note || echo "{}" > ../snapshot.base.json
# It means we fallback on an empty snapshot when left command fails.
# It exists in case the base branch does not contains size-impact files.
# Happens at least when a pull request introduces
# @jsenv/github-pull-request-filesize-impact to a repository for the first time.
- name: generate base snapshot
run: |
git checkout -f $GITHUB_BASE_REF
npm install
npm run dist
node ./.github/size-impact/generate-size-snapshot.js ../snapshot.base.json || echo "{}" > ../snapshot.base.json
- name: generate head snapshot
run: |
git checkout -f $GITHUB_HEAD_REF
npm install
npm run dist
node ./.github/size-impact/generate-size-snapshot.js ../snapshot.head.json
- name: report size impact
run: node ./.github/size-impact/report-size-impact.js ../snapshot.base.json ../snapshot.head.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}