forked from Skyscanner/backpack
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (111 loc) · 4.4 KB
/
ci.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
name: Backpack CI
on:
push:
branches: [main]
pull_request:
defaults:
run:
shell: bash -l {0}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set the correct npm version
run: nvm install && nvm use
- name: Install dependencies from npm
run: |
nvm use
npm ci
- name: Build Backpack
run: |
nvm use
npm run build
- name: Confirm the build hasn't changed any files
run: ./scripts/check-pristine-state package-lock.json
- name: Run tests
run: |
nvm use
npm test
- 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 }}
- name: Build Storybook
run: |
nvm use
npm run storybook:dist
- name: Run visual tests
id: visualTests
run: |
nvm use
npm run jest:visual-tests
- name: Upload failed visual tests (if necessary)
uses: actions/upload-artifact@v2
if: failure() && steps.visualTests.outcome == 'failure'
with:
name: failed-visual-tests
path: .storybook/__image_snapshots__/__diff_output__
- name: Post a comment about the visual tests (if they pass)
uses: unsplash/comment-on-pr@master
if: github.ref != 'refs/heads/main' && github.repository == github.event.pull_request.head.repo.full_name && steps.visualTests.outcome == 'success'
with:
msg: "Visual regression tests passed 😎. Bear in mind that they only run in Chromium on static components – they aren't perfect."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Post a comment about the visual tests (if they fail)
uses: unsplash/comment-on-pr@master
if: failure() && steps.visualTests.outcome == 'failure'
with:
msg: "Visual regression tests failed 😢. You can download the failure diffs from the 'Artifacts' section of the failed CI run. To update the tests, run `npm run jest:visual-tests:update` locally."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Sass docs
if: github.ref == 'refs/heads/main'
run: |
nvm use
npm run sassdoc
- name: Deploy Sass docs to backpack.github.io, if on main branch
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
personal_token: ${{ secrets.DEPLOY_TOKEN }}
publish_dir: dist-sassdoc/
keep_files: false
external_repository: backpack/sassdoc
publish_branch: main
- name: Deploy Storybook to backpack.github.io, if on main branch
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
personal_token: ${{ secrets.DEPLOY_TOKEN }}
publish_dir: dist-storybook/
keep_files: false
external_repository: backpack/storybook
publish_branch: main
- name: Prepare to deploy Storybook (pull request build)
run: |
mkdir build
mv dist-storybook $PR_NUMBER
cp -R $PR_NUMBER build/
if: github.ref != 'refs/heads/main' && github.repository == github.event.pull_request.head.repo.full_name
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
- name: Deploy Storybook to backpack.github.io/storybook-prs, if a pull request
uses: peaceiris/actions-gh-pages@v3
if: github.ref != 'refs/heads/main' && github.repository == github.event.pull_request.head.repo.full_name
with:
personal_token: ${{ secrets.DEPLOY_TOKEN }}
publish_dir: build/
keep_files: true
external_repository: backpack/storybook-prs
publish_branch: main
- name: Link to the pull request build
uses: unsplash/comment-on-pr@master
if: github.ref != 'refs/heads/main' && github.repository == github.event.pull_request.head.repo.full_name
with:
msg: "Visit https://backpack.github.io/storybook-prs/${{ env.PR_NUMBER }} to see this build running in a browser."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}