-
Notifications
You must be signed in to change notification settings - Fork 188
140 lines (113 loc) · 3.64 KB
/
_build.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Build
on:
workflow_call:
defaults:
run:
shell: bash -l {0}
env:
CACHE_NAME: node-modules-cache
BUILD_CACHE_NAME: build-cache
BUILD_LOGS: log-artifacts-build
jobs:
Build:
runs-on: ubuntu-latest
permissions:
statuses: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Restore Cache
uses: actions/cache/[email protected]
id: npm-cache
with:
path: |
node_modules/
packages/node_modules/
key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json', 'packages/package-lock.json') }}
- name: Setup logs directory
run: mkdir logs
- name: Build Backpack
run: npm run build
- name: Confirm the build hasn't changed any files
run: ./scripts/check-pristine-state package-lock.json
- name: Run typecheck
run: npm run typecheck
- name: Run tests
run: bash -c "set -o pipefail;npm run test |& tee 'logs/test.log'"
- name: Tar and compress logs
run: |
tar -cf ${{env.BUILD_LOGS}}.tar.br --use-compress-program="brotli -q 7" ./logs
- name: Upload test logs
uses: actions/[email protected]
with:
name: ${{env.BUILD_LOGS}}
path: ${{env.BUILD_LOGS}}.tar.br
Danger:
runs-on: ubuntu-latest
needs: Build
permissions:
statuses: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Restore Cache
uses: actions/cache/[email protected]
id: npm-cache
with:
path: |
node_modules/
packages/node_modules/
key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json', 'packages/package-lock.json') }}
- name: Download artifacts
uses: actions/[email protected]
with:
name: ${{env.BUILD_LOGS}}
- name: Untar and decompress artifacts
shell: bash
run: |
brotli -d ${{env.BUILD_LOGS}}.tar.br
tar -xf ${{env.BUILD_LOGS}}.tar
- name: Danger
run: npm run danger
if: github.ref != 'refs/heads/main' && github.repository == github.event.pull_request.head.repo.full_name
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PercyTests:
runs-on: ubuntu-latest
needs: [Danger]
permissions:
statuses: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Restore Cache
uses: actions/cache/[email protected]
id: npm-cache
with:
path: |
node_modules/
packages/node_modules/
key: ${{ env.CACHE_NAME }}-${{ hashFiles('package-lock.json', 'packages/package-lock.json') }}
- name: Restore Cache
uses: actions/cache/[email protected]
id: storybook-dist-cache
with:
path: dist-storybook/
key: ${{ env.BUILD_CACHE_NAME }}-${{ hashFiles('packages/**', 'examples/**') }}
- name: Percy Test
run: npm run percy-test
if: ( github.ref == 'refs/heads/main' || github.repository == github.event.pull_request.head.repo.full_name) && github.actor != 'dependabot[bot]'
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}