From 0d87cbee4f49c0485834ffdcc4bb9d6dfddc368a Mon Sep 17 00:00:00 2001 From: Adam Curtis Date: Tue, 31 Oct 2023 14:07:21 -0400 Subject: [PATCH] add slack notification for nightly test results (#584) * add slack notification nightly test results * fix evaluation of github conditional * allow Nightly Test to be ran manually * allow Nightly Test to be ran manually --- .github/workflows/test-nightly.yml | 41 +++++++++++++++++++++++++++--- .github/workflows/test-staging.yml | 27 +++++++++++++++++--- 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-nightly.yml b/.github/workflows/test-nightly.yml index 5b26c003..bae936a3 100644 --- a/.github/workflows/test-nightly.yml +++ b/.github/workflows/test-nightly.yml @@ -5,14 +5,31 @@ run-name: Test Nightly (${{ github.event.client_payload.tagName }}) on: repository_dispatch: types: [nightly-release] + workflow_dispatch: + inputs: + tagName: + description: Release tag to use for this test run. + type: string env: CI: true jobs: + get-tag: + name: Get Release Tag + runs-on: ubuntu-latest + outputs: + tagName: ${{ inputs.tagName || github.event.client_payload.tagName || steps.defaultTagName.outputs.tagName }} + steps: + - name: Create Default Tag Name + id: defaultTagName + if: ${{ !inputs.tagName && !github.event.client_payload.tagName }} + run: | + echo "tagName=nightly-$(date +%d-%m-%Y)" >> $GITHUB_OUTPUT + test-nightly: name: Nightly Test - + needs: get-tag uses: ./.github/workflows/test-staging.yml strategy: fail-fast: false @@ -23,14 +40,30 @@ jobs: - os: windows-latest with: runsOn: ${{ matrix.os }} - releaseVersion: ${{ github.event.client_payload.tagName }} + releaseVersion: ${{ needs.get-tag.outputs.tagName }} testRunnerOptions: -E 'kind(test)' secrets: CLOUDTRUTH_API_KEY: ${{ secrets.CT_STAGING_CI_ADMIN_API_KEY }} + slack-notification: + name: Slack Notification + needs: test-nightly + # do not run on skipped or cancelled + if: ${{ always() && (success() || failure()) }} + runs-on: ubuntu-latest + steps: + - uses: rtCamp/action-slack-notify@v2 + env: + SLACK_TITLE: CLI Nightly Test + SLACK_CHANNEL: dev-notifications + SLACK_USERNAME: ${{ github.repository }} + SLACK_COLOR: ${{ needs.test-nightly.result }} + SLACK_ICON_EMOJI: ":crab:" + SLACK_MESSAGE: ${{ needs.test-nightly.result == 'success' && '✅ Passed' || needs.test-nightly.result == 'failure' && '❌ Failed' }} + cleanup-nightly: name: Nightly Cleanup - needs: test-nightly + needs: [get-tag, test-nightly] if: ${{ always() }} runs-on: ubuntu-latest steps: @@ -40,6 +73,6 @@ jobs: - run: sh cicd/scripts/install-rust.sh - - run: sudo ./install.sh --install-prerequisites --version '${{ github.event.client_payload.tagName }}' || sudo ./install.sh --install-prerequisites + - run: sudo ./install.sh --install-prerequisites --version '${{ needs.get-tag.outputs.tagName }}' || sudo ./install.sh --install-prerequisites - run: cargo run --release --package xtask -- cleanup --confirm cli-test diff --git a/.github/workflows/test-staging.yml b/.github/workflows/test-staging.yml index 577818d8..101cafe2 100644 --- a/.github/workflows/test-staging.yml +++ b/.github/workflows/test-staging.yml @@ -19,6 +19,11 @@ on: description: The CloudTruth server URL to use for testing type: string default: https://api.staging.cloudtruth.io + ### NOTE: nextest does not yet implement JSON output. see https://github.com/nextest-rs/nextest/issues/20 + # outputs: + # testOutputJson: + # description: the JSON output of cargo-nextest + # value: ${{ jobs.cargo-test.outputs.testReportJson }} secrets: CLOUDTRUTH_API_KEY: description: "Staging API Key" @@ -32,12 +37,12 @@ env: CLOUDTRUTH_SERVER_URL: ${{ inputs.serverUrl }} CLOUDTRUTH_API_KEY: ${{ secrets.CLOUDTRUTH_API_KEY }} TEST_ARCHIVE_FILE: integration-test-${{inputs.runsOn}}.tar.zst + # NEXTEST_OUTPUT_JSON_FILE: nextest-output.json jobs: cargo-test: name: CLI Test (staging) runs-on: ${{ inputs.runsOn }} - steps: - shell: bash if: | @@ -80,11 +85,27 @@ jobs: - name: E2E Test (from pre-release assets) if: inputs.releaseVersion shell: bash - run: cargo nextest run --profile ci --archive-file "$TEST_ARCHIVE_FILE" ${{ inputs.testRunnerOptions }} --workspace-remap "${GITHUB_WORKSPACE}" + run: | + cargo nextest run \ + --profile ci \ + --archive-file "$TEST_ARCHIVE_FILE" \ + ${{ inputs.testRunnerOptions }} \ + --workspace-remap "${GITHUB_WORKSPACE}" \ + # --message-format json\ + # > ${NEXTEST_OUTPUT_JSON_FILE} # build and run - name: E2E Test (from workflow artifacts) if: inputs.artifactId shell: bash - run: cargo nextest run --profile ci --archive-file ./integration-test-archive.tar.zst ${{ inputs.testRunnerOptions }} --workspace-remap "${GITHUB_WORKSPACE}" + run: | + cargo nextest run \ + --profile ci \ + --archive-file \ + ./integration-test-archive.tar.zst \ + ${{ inputs.testRunnerOptions }} \ + --workspace-remap "${GITHUB_WORKSPACE}"\ + #--message-format json \ + #> ${NEXTEST_OUTPUT_JSON_FILE} +