|
1 | 1 | # This is a basic workflow to help you get started with Actions
|
2 | 2 |
|
3 |
| -name: Tests |
| 3 | +name: Pull Request Tests |
4 | 4 |
|
5 | 5 | # Controls when the action will run. Triggers the workflow on push or pull request
|
6 | 6 | # events but only for the develop branch
|
7 | 7 | on:
|
8 | 8 | pull_request:
|
9 | 9 | branches:
|
10 | 10 | - develop
|
11 |
| - - main |
12 | 11 |
|
13 | 12 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
14 | 13 | jobs:
|
15 |
| - Tests: |
| 14 | + PullRequestTests: |
16 | 15 | # The type of runner that the job will run on
|
17 | 16 | runs-on: ubuntu-latest
|
18 |
| - |
| 17 | + env: |
| 18 | + QORUS_TOKEN: ${{ secrets.QORUS_TOKEN }} |
19 | 19 | # Steps represent a sequence of tasks that will be executed as part of the job
|
20 | 20 | steps:
|
21 |
| - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 21 | + # Get current time for the commit |
22 | 22 | - name: Get current time
|
23 | 23 | uses: josStorer/get-current-time@v2.0.2
|
24 | 24 | id: current_time
|
25 | 25 | with:
|
26 | 26 | format: YYYYMMDD-HH
|
27 | 27 | utcOffset: '+01:00'
|
28 |
| - # Checkout the repo |
29 |
| - - uses: actions/checkout@v3 |
| 28 | + |
| 29 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 30 | + - name: Get repo |
| 31 | + uses: actions/checkout@v3 |
30 | 32 | with:
|
31 |
| - fetch-depth: 0 |
32 | 33 | ref: ${{ github.event.pull_request.head.sha }}
|
33 |
| - # Get commit message |
| 34 | + fetch-depth: 0 |
| 35 | + |
34 | 36 | - name: Print head git commit message
|
35 | 37 | id: get_head_commit_message
|
36 | 38 | run: echo "::set-output name=HEAD_COMMIT_MESSAGE::$(git show -s --format=%s)"
|
| 39 | + |
37 | 40 | - uses: actions/setup-node@v3
|
38 | 41 | with:
|
39 |
| - node-version: 16 |
40 |
| - - name: Preparing environment |
41 |
| - id: setup_environment |
42 |
| - run: npm install -g yarn |
| 42 | + node-version: 20.11.0 |
| 43 | + |
| 44 | + # Notify Discord to not restart server |
| 45 | + - name: Discord Warning |
| 46 | + env: |
| 47 | + DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK_DEV}} |
| 48 | + # Mention someone in the embeds |
| 49 | + DISCORD_EMBEDS: '[{ "color":16711680, "description": ":exclamation: Tests started, **please do not restart Qorus on Rippy** for the next 30 minutes." }]' |
| 50 | + DISCORD_AVATAR: 'https://github.com/qoretechnologies/qorus-vscode/blob/95ad81fa8654fe83bb41f68f4de42ae088298e59/public/q-symbol-small.png?raw=true' |
| 51 | + uses: Ilshidur/action-discord@0.3.2 |
| 52 | + with: |
| 53 | + args: '<@820316067921395752>' |
| 54 | + |
| 55 | + - name: Save release version to outputs |
| 56 | + id: save_release_version |
| 57 | + run: echo ::set-output name=version::$(node -pe "require('./package.json').version") |
| 58 | + |
43 | 59 | - name: Installing modules
|
44 | 60 | id: install_modules
|
45 | 61 | run: |
|
46 |
| - yarn cache clean |
47 |
| - rm -rf node_modules |
48 | 62 | yarn install
|
49 |
| - - name: Running tests |
50 |
| - id: tests |
51 |
| - run: yarn test:ci |
52 |
| - - name: Build test |
53 |
| - id: build_test |
| 63 | + yarn install-playwright |
| 64 | + yarn build-storybook --quiet |
| 65 | +
|
| 66 | + - name: Run build test |
| 67 | + run: | |
| 68 | + yarn build:test:prod |
| 69 | +
|
| 70 | + - name: Run unit tests |
54 | 71 | run: |
|
55 |
| - yarn build |
56 |
| - rm -rf dist |
| 72 | + yarn test:ci |
| 73 | +
|
| 74 | + - name: Serve Storybook and run tests |
| 75 | + run: | |
| 76 | + npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ |
| 77 | + "npx http-server storybook-static --port 6008 --silent" \ |
| 78 | + "npx wait-on tcp:6008 && yarn test-storybook" |
| 79 | +
|
57 | 80 | - name: Publish to Chromatic
|
58 | 81 | id: chromatic_publish
|
59 | 82 | uses: chromaui/action@v1
|
60 | 83 | with:
|
61 | 84 | token: ${{ secrets.GITHUB_TOKEN }}
|
62 | 85 | projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
63 | 86 | exitZeroOnChanges: true
|
64 |
| - - name: Save release version to outputs |
65 |
| - id: save_release_version |
66 |
| - run: echo ::set-output name=version::$(node -pe "require('./package.json').version") |
67 |
| - - name: Discord notification |
| 87 | + allowConsoleErrors: true |
| 88 | + debug: true |
| 89 | + |
| 90 | + # Notify Discord if Success |
| 91 | + - name: Discord notification success |
68 | 92 | env:
|
69 | 93 | DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK}}
|
70 |
| - 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}}) 📙 [Documentation](${{ steps.chromatic_publish.outputs.storybookUrl }}) 🎨 [Chromatic Tests](${{ steps.chromatic_publish.outputs.buildUrl }})"}],"color": 65280,"footer": { "text": "Published at ${{steps.current_time.outputs.readableTime}}" }}]' |
71 |
| - DISCORD_AVATAR: 'https://github.com/qoretechnologies/reqore/blob/ae8ce24b7f0984340bf4e6835025d203d1741b3a/public/q-symbol-small.png?raw=true' |
| 94 | + 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}}"}}]' |
| 95 | + DISCORD_AVATAR: 'https://github.com/qoretechnologies/qorus-vscode/blob/95ad81fa8654fe83bb41f68f4de42ae088298e59/public/q-symbol-small.png?raw=true' |
72 | 96 | uses: Ilshidur/action-discord@0.3.2
|
73 | 97 | with:
|
74 |
| - args: ':white_check_mark: Tests action run #${{ github.run_number }} for [PR](${{ github.event.pull_request.html_url }}) triggered by ${{ github.triggering_actor }} succeeded. Check the links below for potentional Storybook and Chromatic updates.' |
| 98 | + args: ':white_check_mark: Tests run #${{ github.run_number }} for [PR](${{ github.event.pull_request.html_url }}) triggered by ${{ github.triggering_actor }} *succeeded*, click GitHub Action link below to get the VSIX artifact.' |
75 | 99 | if: success()
|
76 |
| - - name: Discord notification |
| 100 | + |
| 101 | + # Notify discord if failure |
| 102 | + - name: Discord notification failure |
77 | 103 | env:
|
78 | 104 | DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK}}
|
79 |
| - 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": "Triggered at ${{steps.current_time.outputs.readableTime}}" }}]' |
80 |
| - DISCORD_AVATAR: 'https://github.com/qoretechnologies/reqore/blob/ae8ce24b7f0984340bf4e6835025d203d1741b3a/public/q-symbol-small.png?raw=true' |
| 105 | + 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}}"}}]' |
| 106 | + DISCORD_AVATAR: 'https://github.com/qoretechnologies/qorus-vscode/blob/95ad81fa8654fe83bb41f68f4de42ae088298e59/public/q-symbol-small.png?raw=true' |
81 | 107 | uses: Ilshidur/action-discord@0.3.2
|
82 | 108 | with:
|
83 |
| - args: ':exclamation: Tests action run #${{ github.run_number }} for [PR](${{ github.event.pull_request.html_url }}) triggered by ${{ github.triggering_actor }} failed! Click the GitHub action link below to find out why.' |
| 109 | + args: ':exclamation: Tests run #${{ github.run_number }} for [PR](${{ github.event.pull_request.html_url }}) triggered by ${{ github.triggering_actor }} *failed*!' |
84 | 110 | if: failure()
|
| 111 | + |
| 112 | + - name: Discord notification safe to restart |
| 113 | + env: |
| 114 | + DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK_DEV}} |
| 115 | + DISCORD_EMBEDS: '[{ "color":65280, "description": ":white_check_mark: Tests action finished. It is now safe to restart Qorus on Rippy." }]' |
| 116 | + DISCORD_AVATAR: 'https://github.com/qoretechnologies/qorus-vscode/blob/95ad81fa8654fe83bb41f68f4de42ae088298e59/public/q-symbol-small.png?raw=true' |
| 117 | + uses: Ilshidur/action-discord@0.3.2 |
| 118 | + with: |
| 119 | + args: '<@820316067921395752>' |
| 120 | + if: always() |
0 commit comments