From b52e96ed04edd33f6ee8c890dd1b1f5492e4d5c6 Mon Sep 17 00:00:00 2001 From: Philippe Serhal Date: Mon, 21 Oct 2024 10:06:22 -0400 Subject: [PATCH] ci: remove unused Slack CI workflow code (#2680) --- .github/workflows/run-tests.yml | 9 -- .github/workflows/test-e2e.yml | 13 --- tools/deno/junit2slack.ts | 142 -------------------------------- 3 files changed, 164 deletions(-) delete mode 100644 tools/deno/junit2slack.ts diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 6fca08bcd8..8a54eb5f74 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -254,15 +254,6 @@ jobs: npx playwright merge-reports --reporter html ./all-blob-reports npx playwright merge-reports --reporter json ./all-blob-reports > merged_reports.json - # FIXME(serhalp) Once we recover access to the SquidlifyBot Slack App, reenable this. - # - name: Notify Slack - # if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.head_ref == 'main' - # run: npx playwright-slack-report -j merged_reports.json -c tests/playwright-slack-conf.json - # env: - # SLACK_BOT_USER_OAUTH_TOKEN: ${{ secrets.SLACK_BOT_USER_OAUTH_TOKEN }} - # RESULTS_VERSION: ${{ matrix.version }} - # RESULTS_URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} - - name: Upload HTML report uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 085528d103..90d9bf05f4 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -245,9 +245,6 @@ jobs: id: publish-test-results if: success() || failure() run: | - echo "slackEvent<> $GITHUB_OUTPUT - deno run -A tools/deno/junit2slack.ts --dir artifacts --version ${{matrix.version_spec.selector}} --runUrl ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} >> $GITHUB_OUTPUT - echo "NETLIFY_EOF" >> $GITHUB_OUTPUT deno run -A tools/deno/junit2json.ts artifacts ${{ matrix.version_spec.tag }} > report/test-results.json deno run -A tools/deno/generate-md.ts >> $GITHUB_STEP_SUMMARY @@ -259,13 +256,3 @@ jobs: # actual filename. name: ${{matrix.version_spec.selector}}-test-results.json path: report/test-results.json - - # FIXME(serhalp) Once we recover access to the SquidlifyBot Slack App, reenable this. - # - name: Notify Slack - # if: ${{ (success() || failure()) && github.event_name == 'schedule' }} - # uses: slackapi/slack-github-action@v1.26.0 - # env: - # SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - # SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - # with: - # payload: ${{ steps.publish-test-results.outputs.slackEvent }} diff --git a/tools/deno/junit2slack.ts b/tools/deno/junit2slack.ts deleted file mode 100644 index b9ef9129ea..0000000000 --- a/tools/deno/junit2slack.ts +++ /dev/null @@ -1,142 +0,0 @@ -import { expandGlob } from 'https://deno.land/std/fs/mod.ts' -import { parse } from 'https://deno.land/x/xml/mod.ts' -import { parseArgs } from 'https://deno.land/std@0.218.2/cli/parse_args.ts' -interface TestCase { - '@classname': string - '@name': string - '@time': number - '@file': string - failure?: string -} - -interface TestSuite { - '@name': string - '@errors': number - '@failures': number - '@skipped': number - '@timestamp': string - '@time': number - '@tests': number - testcase: TestCase[] -} - -interface TestSuites { - '@name': string - '@tests': number - '@failures': number - '@errors': number - '@time': number - testsuite: TestSuite[] -} - -async function parseXMLFile(filePath: string): Promise<{ testsuites: TestSuites }> { - const xmlContent = await Deno.readTextFile(filePath) - return parse(xmlContent) as unknown as { testsuites: TestSuites } -} - -const testCount = { - failed: 0, - passed: 0, - skipped: 0, -} - -const squares: Array = [] - -const icons = { - failed: '🟥', - passed: '🟩', - skipped: '⬜', -} - -function parseJUnit(xmlData: { testsuites: TestSuites }) { - if (!xmlData.testsuites) { - return - } - - const testSuites = Array.isArray(xmlData.testsuites.testsuite) - ? xmlData.testsuites.testsuite - : [xmlData.testsuites.testsuite] - - for (const suite of testSuites) { - const testCases = Array.isArray(suite.testcase) ? suite.testcase : [suite.testcase] - - testCases.forEach((testCase) => { - const status = 'skipped' in testCase ? 'skipped' : testCase.failure ? 'failed' : 'passed' - testCount[status]++ - squares.push(icons[status]) - }) - } -} - -async function processJUnitFiles(directoryPath: string) { - for await (const file of expandGlob(`${directoryPath}/**/*.xml`)) { - const xmlData = await parseXMLFile(file.path) - parseJUnit(xmlData) - } -} - -const { dir, version, runUrl } = parseArgs(Deno.args) - -// Check if the directory path is provided -if (!dir) { - console.error('Please provide a directory path.') - Deno.exit(1) -} - -// Process the JUnit files in the provided directory -await processJUnitFiles(dir) - -const total = testCount['passed'] + testCount['failed'] -let data = '' -data += `*Passed:* ${testCount['passed']} \n` -data += `*Failed:* ${testCount['failed']} \n` -data += `*Skipped:* ${testCount['skipped']}\n\n` - -data += `*${((testCount['passed'] / total) * 100).toFixed(2)}%* passing\n` - -data += `*${testCount['passed']}* passed out of *${total}* Next.js deploy tests. *${testCount['failed']}* still to go.\n\n` - -const result: { blocks: Array> } = { - blocks: [ - { - type: 'header', - text: { - type: 'plain_text', - text: `E2E test results for Next.js ${version}`, - emoji: true, - }, - }, - { - type: 'section', - text: { - type: 'mrkdwn', - text: data, - }, - accessory: { - type: 'image', - image_url: - 'https://emoji.slack-edge.com/T02UKDKNA/old-man-yells-at-vercel/3927e24cc7b0fa8d.png', - alt_text: 'old man yells at Next.js', - }, - }, - ], -} - -if (runUrl) { - result.blocks.push({ - type: 'actions', - elements: [ - { - type: 'button', - text: { - type: 'plain_text', - text: ':github: Show details', - emoji: true, - }, - url: runUrl, - }, - ], - }) -} - -console.log(JSON.stringify(result))