-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (127 loc) · 8.16 KB
/
tests.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
# This is a basic workflow to help you get started with Actions
name: Pull Request Tests
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the develop branch
on:
pull_request:
branches:
- develop
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
PullRequestTests:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
QORUS_TOKEN: ${{ secrets.QORUS_TOKEN }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Get current time for the commit
- name: Get current time
uses: josStorer/get-current-time@v2.0.2
id: current_time
with:
format: YYYYMMDD-HH
utcOffset: '+01:00'
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Get repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Print head git commit message
id: get_head_commit_message
run: echo "::set-output name=HEAD_COMMIT_MESSAGE::$(git show -s --format=%s)"
- uses: actions/setup-node@v3
with:
node-version: 20.11.0
# Notify Discord to not restart server
- name: Discord Warning
env:
DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK_DEV}}
# Mention someone in the embeds
DISCORD_EMBEDS: '[{ "color":16711680, "description": ":exclamation: Tests started, **please do not restart Qorus on Rippy** for the next 30 minutes." }]'
DISCORD_AVATAR: 'https://github.com/qoretechnologies/qorus-vscode/blob/95ad81fa8654fe83bb41f68f4de42ae088298e59/public/q-symbol-small.png?raw=true'
uses: Ilshidur/action-discord@0.3.2
with:
args: '<@820316067921395752>'
- name: Save release version to outputs
id: save_release_version
run: echo ::set-output name=version::$(node -pe "require('./package.json').version")
- name: Installing modules
id: install_modules
run: |
yarn install
yarn install-playwright
yarn playwright install
yarn build-storybook --quiet
- name: Run build test
run: |
yarn build
- name: Run unit tests
run: |
yarn test:ci
- name: Serve Storybook and run tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"npx http-server storybook-static --port 6008 --silent" \
"npx wait-on tcp:6008 && yarn test-storybook"
- name: Bump version with timestamp and canary tag
id: bump
run: |
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
NEW_VERSION=$(npm version prerelease --preid=canary.$TIMESTAMP --no-git-tag-version)
echo "New version: $NEW_VERSION"
echo "::set-output name=version::$NEW_VERSION"
- name: Publish canary version to NPM
id: npm_publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
tag: canary
access: public
- name: Create comment with canary version
uses: mshick/add-pr-comment@v2
with:
message: |
Canary version for this PR published: ${{ steps.bump.outputs.version }}
```sh
yarn add @qoretechnologies/reqraft@${{ steps.bump.outputs.version }}
```
- name: Publish to Chromatic
id: chromatic_publish
uses: chromaui/action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
exitZeroOnChanges: true
allowConsoleErrors: true
debug: true
# Notify Discord if Success
- name: Discord notification success
env:
DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK}}
DISCORD_EMBEDS: '[{ "author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "https://github.com/${{github.actor}}" },"url": "https://github.com/${{github.repository}}/commit/${{github.sha}}","fields": [{ "name": "Commit Message", "value": "${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}"},{ "name": "Repository", "value": "[${{github.event.repository.name}}](${{github.event.repository.clone_url}})", "inline": true },{ "name": "Branch", "value": "[${{github.ref_name}}](https://github.com/${{github.repository}}/pull/${{github.ref_name}})", "inline": true },{ "name": "Event", "value": "${{github.event_name}}", "inline": true },{ "name": "Author", "value": "[${{github.actor}}](https://github.com/${{github.actor}})", "inline": true },{ "name": "Job", "value": "${{github.job}}", "inline": true},{ "name": "Version", "value": "v${{ steps.save_release_version.outputs.version }}", "inline": true},{ "name": "", "value": "🤖 [Github Action](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id}}) 🌐 [View Site]( https://deploy-preview-${{ github.event.pull_request.number}}--magical-starburst-a8bdfc.netlify.app) 📙 [Storybook](${{ steps.chromatic_publish.outputs.storybookUrl }}) 🎨 [Chromatic Tests](${{ steps.chromatic_publish.outputs.buildUrl }})"}],"color":65280,"footer":{"text": "Published at ${{steps.current_time.outputs.readableTime}}"}}]'
DISCORD_AVATAR: 'https://github.com/qoretechnologies/qorus-vscode/blob/95ad81fa8654fe83bb41f68f4de42ae088298e59/public/q-symbol-small.png?raw=true'
uses: Ilshidur/action-discord@0.3.2
with:
args: ':white_check_mark: Tests run #${{ github.run_number }} for [PR](${{ github.event.pull_request.html_url }}) triggered by ${{ github.triggering_actor }} *succeeded*, install the canary version via `yarn add @qoretechnologies/reqraft@${{ steps.bump.outputs.version }}`.'
if: success()
# Notify discord if failure
- name: Discord notification failure
env:
DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK}}
DISCORD_EMBEDS: '[{ "author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "https://github.com/${{github.actor}}" },"url": "https://github.com/${{github.repository}}/commit/${{github.sha}}","fields": [{ "name": "Commit Message", "value": "${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}"},{ "name": "Repository", "value": "[${{github.event.repository.name}}](${{github.event.repository.clone_url}})", "inline": true },{ "name": "Branch", "value": "[${{github.ref_name}}](https://github.com/${{github.repository}}/pull/${{github.ref_name}})", "inline": true },{ "name": "Event", "value": "${{github.event_name}}", "inline": true },{ "name": "Author", "value": "[${{github.actor}}](https://github.com/${{github.actor}})", "inline": true },{ "name": "Job", "value": "${{github.job}}", "inline": true },{ "name": "Version", "value": "v${{ steps.save_release_version.outputs.version }}", "inline": true},{ "name": "", "value": "🤖 [Github Action](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id}})"}],"color":16711680,"footer":{"text": "Published at ${{steps.current_time.outputs.readableTime}}"}}]'
DISCORD_AVATAR: 'https://github.com/qoretechnologies/qorus-vscode/blob/95ad81fa8654fe83bb41f68f4de42ae088298e59/public/q-symbol-small.png?raw=true'
uses: Ilshidur/action-discord@0.3.2
with:
args: ':exclamation: Tests run #${{ github.run_number }} for [PR](${{ github.event.pull_request.html_url }}) triggered by ${{ github.triggering_actor }} *failed*!'
if: failure()
- name: Discord notification safe to restart
env:
DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK_DEV}}
DISCORD_EMBEDS: '[{ "color":65280, "description": ":white_check_mark: Tests action finished. It is now safe to restart Qorus on Rippy." }]'
DISCORD_AVATAR: 'https://github.com/qoretechnologies/qorus-vscode/blob/95ad81fa8654fe83bb41f68f4de42ae088298e59/public/q-symbol-small.png?raw=true'
uses: Ilshidur/action-discord@0.3.2
with:
args: '<@820316067921395752>'
if: always()