Skip to content

Nightly checks

Nightly checks #767

Workflow file for this run

name: Nightly checks
# runs every day at midnight
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
# To test fixes on push rather than wait for the scheduling
push:
branches:
- fix/nightly
jobs:
assert_test_runner:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Get current version of Storybook
run: |
echo "prev_sb_version=$(yarn list @storybook/react --depth=0 2> /dev/null | grep @storybook/react | awk -F'@' '{print $3}')" >> $GITHUB_ENV
echo "prev_sb_csf_version=$(yarn list @storybook/csf --depth=0 2> /dev/null | grep @storybook/csf | awk -F'@' '{print $3}')" >> $GITHUB_ENV
- name: Upgrade to storybook@next
run: |
npx storybook@next upgrade --yes
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Run test runner
uses: mathiasvr/[email protected]
id: tests
with:
run: |
yarn build
yarn test-storybook:ci
- name: Get prerelease version of Storybook
if: ${{ failure() }}
run: |
echo "sb_version=$(yarn list @storybook/react --depth=0 2> /dev/null | grep @storybook/react | awk -F'@' '{print $3}')" >> $GITHUB_ENV
echo "sb_csf_version=$(yarn list @storybook/csf --depth=0 2> /dev/null | grep @storybook/csf | awk -F'@' '{print $3}')" >> $GITHUB_ENV
- name: Report incoming errors
if: ${{ failure() }}
id: slack
uses: slackapi/[email protected]
with:
channel-id: '${{ secrets.SLACK_CHANNEL_ID }}'
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":storybook: :runner: [Test Runner] The Nightly check has failed :alert:",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*@storybook/react version:*\n${{ env.prev_sb_version }} >> ${{ env.sb_version }}"
},
{
"type": "mrkdwn",
"text": "*@storybook/csf version:*\n${{ env.prev_sb_csf_version }} >> ${{ env.sb_csf_version }}"
}
],
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "View failure",
"emoji": true
},
"value": "view_failure",
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"action_id": "button-action"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
assert_test_runner_failures:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Get current version of Storybook
run: |
echo "prev_sb_version=$(yarn list @storybook/react --depth=0 2> /dev/null | grep @storybook/react | awk -F'@' '{print $3}')" >> $GITHUB_ENV
echo "prev_sb_csf_version=$(yarn list @storybook/csf --depth=0 2> /dev/null | grep @storybook/csf | awk -F'@' '{print $3}')" >> $GITHUB_ENV
- name: Upgrade to storybook@next
run: |
npx storybook@next upgrade --prerelease --yes
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Run test runner and expect failure
uses: mathiasvr/[email protected]
with:
run: |
yarn build
! yarn test-storybook:ci-failures
- name: Process test results
if: ${{ always() }}
id: tests
uses: sergeysova/jq-action@v2
with:
cmd: 'jq .numPassedTests test-results.json -r'
- name: Set failure check to env
if: ${{ always() }}
run: |
echo "FAILED=${{ steps.tests.outputs.value > 0 }}" >> $GITHUB_ENV
- name: Get prerelease version of Storybook
if: ${{ always() && env.FAILED == 'true' }}
run: |
echo "sb_version=$(yarn list @storybook/react --depth=0 2> /dev/null | grep @storybook/react | awk -F'@' '{print $3}')" >> $GITHUB_ENV
echo "sb_csf_version=$(yarn list @storybook/csf --depth=0 2> /dev/null | grep @storybook/csf | awk -F'@' '{print $3}')" >> $GITHUB_ENV
- name: Report if any test passes
if: ${{ always() && env.FAILED == 'true' }}
id: slack
uses: slackapi/[email protected]
with:
channel-id: '${{ secrets.SLACK_CHANNEL_ID }}'
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":storybook: :runner: [Test Runner] The Nightly check for **failures** has passed :thinking_face:",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*@storybook/react version:*\n${{ env.prev_sb_version }} >> ${{ env.sb_version }}"
},
{
"type": "mrkdwn",
"text": "*@storybook/csf version:*\n${{ env.prev_sb_csf_version }} >> ${{ env.sb_csf_version }}"
}
],
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "View failure",
"emoji": true
},
"value": "view_failure",
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"action_id": "button-action"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}