-
Notifications
You must be signed in to change notification settings - Fork 518
160 lines (133 loc) · 7.28 KB
/
dsm-test.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Validate pull request modifications
on:
pull_request:
paths:
- 'front-packages/akeneo-design-system/**'
jobs:
test:
name: Launch tests on the DSM
runs-on: ubuntu-latest
steps:
- name: Checkout the current branch
uses: actions/checkout@v2
- name: Install node 18 for the rest of the workflow
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: '**/front-packages/akeneo-design-system/node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/front-packages/akeneo-design-system/yarn.lock') }}
- name: Install peer dependencies
# TODO RAC-594 Do not used fixed peer dependencies
run: cd front-packages/akeneo-design-system && yarn add --dev react@^16.14.0 react-dom@^16.9.12 styled-components@^5.1.1
- name: Install node modules
run: cd front-packages/akeneo-design-system && yarn install
- name: Generate a dummy component to test it with the others
run: cd front-packages/akeneo-design-system && ./bin/dsm generate Dummy
- name: Cache TypeScript build
uses: actions/cache@v2
env:
cache-name: cache-typescript-build
with:
path: '**/front-packages/akeneo-design-system/tsconfig.build.tsbuildinfo'
key: ${{ runner.os }}-typescript-${{ hashFiles('**/front-packages/akeneo-design-system/src') }}
- name: Cache lib build
uses: actions/cache@v2
env:
cache-name: cache-lib-build
with:
path: '**/front-packages/akeneo-design-system/lib'
key: ${{ runner.os }}-lib-${{ hashFiles('**/front-packages/akeneo-design-system/src') }}
- name: Make sure the lib build is successful
run: cd front-packages/akeneo-design-system && yarn lib:build
- name: Launch lint checks
run: cd front-packages/akeneo-design-system && yarn lint:check
- uses: actions/cache@v2
name: Cache jest cache
env:
cache-name: cache-jest-cache
with:
path: /tmp/jest/**
key: ${{ runner.os }}-jest-cache
- name: Launch unit tests
run: cd front-packages/akeneo-design-system && yarn test:unit:run
- name: Build storybook
id: build_storybook
run: cd front-packages/akeneo-design-system && yarn storybook:build && echo ::set-output name=status::success
- name: Launch visual tests
run: cd front-packages/akeneo-design-system && yarn test:visual:run && echo ::set-output name=status::success
id: visual_test_execution
- name: Cache example node modules
uses: actions/cache@v2
env:
cache-name: cache-example-node-modules
with:
path: '**/front-packages/akeneo-design-system/example/node_modules'
key: ${{ runner.os }}-example-project-node-modules-${{ hashFiles('**/front-packages/akeneo-design-system/example/yarn.lock') }}
# To check if the build is working, the directory `example` contains an integration of the lib
# with a few tests. In the next step we will build this example and validate that it's working properly
- name: Install example project dependencies
run: cd front-packages/akeneo-design-system/example && rm -rf node_modules/akeneo-design-system && yarn install --check-files
- name: Launch example integration tests
run: cd front-packages/akeneo-design-system/example && yarn test
- name: Upload the src folder on failure for debugging purposes
uses: actions/upload-artifact@v2
if: failure()
with:
name: src-folder
path: front-packages/akeneo-design-system/src
# In this next section (only launched if the visual regression failed) we will update the visual snapshots
# to provide a pull request to the developer contributing to the DSM.
- name: Remove files generated by previous steps
if: failure() && steps.visual_test_execution.outputs.status != 'success' && steps.build_storybook.outputs.status == 'success'
run: cd front-packages/akeneo-design-system && git reset HEAD --hard
- name: Update visual tests snapshots
if: failure() && steps.visual_test_execution.outputs.status != 'success' && steps.build_storybook.outputs.status == 'success'
run: cd front-packages/akeneo-design-system && yarn test:visual:update
- name: Get the current branch name to expose it later on
uses: mdecoleman/[email protected]
if: failure() && steps.visual_test_execution.outputs.status != 'success' && steps.build_storybook.outputs.status == 'success'
id: extract_branch
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Remove Dummy component
if: failure() && steps.visual_test_execution.outputs.status != 'success' && steps.build_storybook.outputs.status == 'success'
run: rm -rf front-packages/akeneo-design-system/src/components/Dummy
- name: Push to a new branch and create pull request targeting the current one
if: failure() && steps.visual_test_execution.outputs.status != 'success' && steps.build_storybook.outputs.status == 'success'
id: create_visual_pull_request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update visual tests for branch ${{ steps.extract_branch.outputs.branch }}
branch: ${{ steps.extract_branch.outputs.branch }}-visual-update
base: ${{ steps.extract_branch.outputs.branch }}
title: Update visual tests for branch ${{ steps.extract_branch.outputs.branch }}
body: This PR updates the visual tests for the changes in the branch ${{ steps.extract_branch.outputs.branch }}
assignees: ${{ github.actor }}
- name: Comment current PR to notify that new visual snapshots are available
uses: thollander/actions-comment-pull-request@main
if: failure() && steps.visual_test_execution.outputs.status != 'success' && steps.build_storybook.outputs.status == 'success'
with:
message: |
Your visual regression tests are not passing <img width="25" src="https://emoji.slack-edge.com/T031L1UKF/sad-dog/ac79218e153de6de.jpg" />
Here is a pull request to fix them: https://github.com/${{ github.repository }}/pull/${{ steps.create_visual_pull_request.outputs.pull-request-number }} :tada:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to gh-pages on the external repository (in a subfolder)
uses: peaceiris/[email protected]
with:
personal_token: ${{ secrets.DSM_EXTERNAL_TOKEN }}
publish_dir: ./front-packages/akeneo-design-system/storybook-static
destination_dir: ${{ github.event.number }}
keep_files: true
external_repository: akeneo/akeneo-design-system
- name: Comment PR to say that the staging env is available
uses: thollander/actions-comment-pull-request@main
with:
message: |
A new version of the staging env has been deployed :tada:
Check it out here: https://akeneo.github.io/akeneo-design-system/${{ github.event.number }}/
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}