-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (93 loc) · 3.54 KB
/
report-file-size.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: File Size
on:
pull_request:
branches:
- reporting
jobs:
build_master:
name: Build Master
runs-on: ubuntu-latest
steps:
# Shared Setup
- uses: actions/checkout@v2
with:
ref: master
- uses: volta-cli/action@v1
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# TODO: Leverage cache to avoid building `master` more than once
- run: yarn install
- run: yarn build
- uses: actions/upload-artifact@v1
with:
name: master-dist
path: dist
build_pr:
name: Build PR
runs-on: ubuntu-latest
steps:
# Shared Setup
- uses: actions/checkout@v2
- uses: volta-cli/action@v1
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install
- run: yarn build
- uses: actions/upload-artifact@v1
with:
name: pr-dist
path: dist
report:
name: Report Sizes
runs-on: ubuntu-latest
needs: [build_master, build_pr]
steps:
- uses: actions/download-artifact@v1
with:
name: master-dist
path: master-dist
- uses: actions/download-artifact@v1
with:
name: pr-dist
path: pr-dist
- name: G-Zip Files
run: gzip -k master-dist/fluid-tailwind.min.css pr-dist/fluid-tailwind.min.css
- name: Get size of Master
id: master-size
run: |
echo "::set-output name=base::$(du -k master-dist/fluid-tailwind.css | cut -f1)"
echo "::set-output name=minified::$(du -k master-dist/fluid-tailwind.min.css | cut -f1)"
echo "::set-output name=gzip::$(du -k master-dist/fluid-tailwind.min.css.gz | cut -f1)"
- name: Get size of PR
id: pr-size
run: |
echo "::set-output name=base::$(du -k pr-dist/fluid-tailwind.css | cut -f1)"
echo "::set-output name=minified::$(du -k pr-dist/fluid-tailwind.min.css | cut -f1)"
echo "::set-output name=gzip::$(du -k pr-dist/fluid-tailwind.min.css.gz | cut -f1)"
- name: Post Comment
if: steps.master-size.outputs.base != steps.pr-size.outputs.base
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: |
| Build | **fluid-tailwind.css** | **fluid-tailwind.min.css** | **fluid-tailwind.min.css.gz** |
| :-- | :-- | :-- | :-- |
| `master` | ${{ steps.master-size.outputs.base }} KB | ${{ steps.master-size.outputs.minified }} KB | ${{ steps.master-size.outputs.gzip }} KB |
| PR Size | ${{ steps.pr-size.outputs.base }} KB | ${{ steps.pr-size.outputs.minified }} KB | ${{ steps.pr-size.outputs.gzip }} KB |