diff --git a/.github/workflows/slack-skipped-tests.yml b/.github/workflows/slack-skipped-tests.yml new file mode 100644 index 00000000000..bd232f0f5fb --- /dev/null +++ b/.github/workflows/slack-skipped-tests.yml @@ -0,0 +1,17 @@ +name: Slack Skipped Tests + +on: + schedule: + # Run every Tuesday at 2pm UTC / 8am CST / 9am EST + - cron: '0 14 * * 2' + workflow_dispatch: + +jobs: + slack-skipped-tests: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run Slack Skipped Tests Script + run: node scripts/slack-skipped-tests.js ${{ secrets.SLACK_E2E_TEST_WEBHOOK }} diff --git a/scripts/slack-skipped-tests.js b/scripts/slack-skipped-tests.js new file mode 100644 index 00000000000..9604b58a9f9 --- /dev/null +++ b/scripts/slack-skipped-tests.js @@ -0,0 +1,38 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (C) 2024 Posit Software, PBC. All rights reserved. + * Licensed under the Elastic License 2.0. See LICENSE.txt for license information. + *--------------------------------------------------------------------------------------------*/ + +const { execSync } = require('child_process'); + +const slackSkippedTests = (slackWebhookUrl) => { + try { + const skippedTests = execSync( + `grep -r --include \\*.test.ts -E "describe\\.skip|it\\.skip" test/smoke/src/areas/positron | sed 's/\\.test\\.ts.*$/.test.ts/'` + ).toString(); + + const slackMessage = { + attachments: [ + { + mrkdwn_in: ['text'], + color: skippedTests === '' ? '#CCCCCC' : '#FF0000', + pretext: ':skipping:*Skipped Tests*', + text: skippedTests === '' ? 'There are no skipped tests. :tada:' : skippedTests, + }, + ], + }; + + console.log(skippedTests); + console.log(JSON.stringify(slackMessage, null, 2)); + + execSync( + `curl -X POST -H 'Content-type: application/json' --data '${JSON.stringify( + slackMessage + )}' ${slackWebhookUrl}` + ); + } catch (error) { + console.error(`Error: ${error}`); + } +}; + +slackSkippedTests(process.argv[2]);