-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (105 loc) · 5.18 KB
/
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
name: Test
on:
push:
env:
# Group output as we make heavy use of parallel and nested tasks.
TASK_OUTPUT: "--output group --output-group-begin '::group::{{.TASK}}' --output-group-end '::endgroup::'"
jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
# TODO replace which with what can be read from .nvmrc if we get a
# separation between checkout and install
node-version: 'lts/*'
registry-url: 'https://npm.pkg.github.com'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup go-task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Initialize environment
run: "task init ${{ env.TASK_OUTPUT }}"
- name: Prepare CMS for development
run: "task cms:dev ${{ env.TASK_OUTPUT }}"
- name: Link Design system to React components
run: "task react:link ${{ env.TASK_OUTPUT }}"
- name: Link Design system and React components to CMS
run: "task cms:link ${{ env.TASK_OUTPUT }}"
- name: Link Design system to React components (again)
run: "task react:link ${{ env.TASK_OUTPUT }}"
- name: Link Design system and React components to CMS (again)
run: "task cms:link ${{ env.TASK_OUTPUT }}"
- name: Test React components after linking
uses: cypress-io/github-action@v6
with:
start: yarn start:storybook:test
wait-on: "http://localhost:57021"
browser: chrome
working-directory: react
# A single test should be sufficient to ensure that Storybook can
# start, the React components work etc. after linking.
# The demo modal test is simple and quick to execute.
spec: src/apps/demo-modal/demo-modal.test.ts
- name: Test CMS after linking
working-directory: cms
# A single request to see that the frontpage can be retrieved should be
# sufficient to ensure that Drupal can bootstrap and return a page.
# If we can get ports for running containers in the CMS directory after
# initializing then docker commands within the subdirectory will work
# with the Dapple-initiated containers as expected.
run: "curl --fail http://localhost:$(docker compose port varnish 8080 | cut -d: -f2)"
# Test that changes to design system results in changes in React component dependencies
- name: Store current build of Design system in React components
run: |
mkdir ${{ runner.temp }}/design-system
cp node_modules/@danskernesdigitalebibliotek/dpl-design-system/build/css/base.css ${{ runner.temp }}/design-system/base.before.css
working-directory: react
- name: Update design system file
run: |
echo -e "\nh1 { color: pink; }\n" >> src/stories/Library/typography/typography.scss
working-directory: design-system
- name: Build Design system
run: "task design-system:build ${{ env.TASK_OUTPUT }}"
- name: Store new build of Design system in React components
run: |
cp node_modules/@danskernesdigitalebibliotek/dpl-design-system/build/css/base.css ${{ runner.temp }}/design-system/base.after.css
working-directory: react
- name: Ensure there is a difference between design system builds in React components
# We expect a difference and diff will return an error code if there is
# a difference. Reverse this using !.
run: |
! diff ${{ runner.temp }}/design-system/base.before.css ${{ runner.temp }}/design-system/base.after.css
- name: Store info on current build of React components in CMS
run: |
mkdir ${{ runner.temp }}/react
docker compose cp php:app/web/libraries/dpl-react/version.json ${{ runner.temp }}/react/version.before.json
working-directory: cms
- name: Update React component
run: |
echo -e "\nconsole.log('Hello world!');\n" >> src/apps/hello-world/hello-world.tsx
working-directory: react
- name: Build React components for CMS
# Normally this would happen automatically through file watchers when
# files are changed. We are not running with file watchers in GitHub
# actions so updated links to the CMS automatically.
run: "task cms:link ${{ env.TASK_OUTPUT }}"
- name: Store new build of React components in CMS
run: |
docker compose cp php:app/web/libraries/dpl-react/version.json ${{ runner.temp }}/react/version.after.json
working-directory: cms
- name: Ensure there is a difference between React builds in CMS
# We expect a difference and diff will return an error code if there is
# a difference. Reverse this using !.
run: |
! diff ${{ runner.temp }}/react/version.before.json ${{ runner.temp }}/react/version.after.json
- name: Reset environment
run: "task reset ${{ env.TASK_OUTPUT }}"
- name: Setup tmate session to support debugging if enabled
if: runner.debug == '1'
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15