Skip to content

Commit

Permalink
fix version extraction script
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jan 24, 2024
1 parent 2b22464 commit b0788d6
Showing 1 changed file with 175 additions and 166 deletions.
341 changes: 175 additions & 166 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,169 +29,178 @@ jobs:

- 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/command-output@v2.0.0
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/slack-github-action@v1.24.0
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/command-output@v2.0.0
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/slack-github-action@v1.24.0
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 }}
set -x
result=$(yarn why @storybook/csf 2> /dev/null)
echo "Result of yarn why: $result"
filtered_result3=$(echo "$result" | grep "@storybook/csf@" | head -n 1)
echo "Filtered result3: $filtered_result3"
filtered_result=$(echo "$result" | grep -m1 "@storybook/csf@")
echo "Filtered result: $filtered_result"
result2=$(yarn why @storybook/csf)
echo "Result2 of yarn why: $result"
filtered_result2=$(echo "$result" | grep -m1 "@storybook/csf@")
echo "Filtered result2: $filtered_result2"
shell: bash
# - name: Upgrade to storybook@next
# run: |
# npx storybook@next upgrade --yes
# env:
# YARN_ENABLE_IMMUTABLE_INSTALLS: false

# - name: Run test runner
# uses: mathiasvr/command-output@v2.0.0
# id: tests
# with:
# run: |
# yarn build
# yarn test-storybook:ci

# - name: Get prerelease version of Storybook
# if: ${{ failure() }}
# run: |
# echo "sb_version=$(yarn why @storybook/react 2> /dev/null | grep -m1 "@storybook/react@" | awk -F'@' '{print $3}' | awk -F':' '{print $2}' | awk '{print $1}')" >> $GITHUB_ENV
# echo "sb_csf_version=$(yarn why @storybook/csf 2> /dev/null | grep -m1 "@storybook/csf@" | awk -F'@' '{print $3}' | awk -F':' '{print $2}' | awk '{print $1}')" >> $GITHUB_ENV

# - name: Report incoming errors
# if: ${{ failure() }}
# id: slack
# uses: slackapi/slack-github-action@v1.24.0
# 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 why @storybook/react 2> /dev/null | grep -m1 "@storybook/react@" | awk -F'@' '{print $3}' | awk -F':' '{print $2}' | awk '{print $1}')" >> $GITHUB_ENV
# echo "prev_sb_csf_version=$(yarn why @storybook/csf 2> /dev/null | grep -m1 "@storybook/csf@" | awk -F'@' '{print $3}' | awk -F':' '{print $2}' | awk '{print $1}')" >> $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/command-output@v2.0.0
# 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 why @storybook/react 2> /dev/null | grep -m1 "@storybook/react@" | awk -F'@' '{print $3}' | awk -F':' '{print $2}' | awk '{print $1}')" >> $GITHUB_ENV
# echo "sb_csf_version=$(yarn why @storybook/csf 2> /dev/null | grep -m1 "@storybook/csf@" | awk -F'@' '{print $3}' | awk -F':' '{print $2}' | awk '{print $1}')" >> $GITHUB_ENV

# - name: Report if any test passes
# if: ${{ always() && env.FAILED == 'true' }}
# id: slack
# uses: slackapi/slack-github-action@v1.24.0
# 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 }}

0 comments on commit b0788d6

Please sign in to comment.