Skip to content

Commit

Permalink
add slack notification for nightly test results (#584)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
erratic-pattern authored Oct 31, 2023
1 parent c57cb52 commit 0d87cbe
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
41 changes: 37 additions & 4 deletions .github/workflows/test-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
27 changes: 24 additions & 3 deletions .github/workflows/test-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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: |
Expand Down Expand Up @@ -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}

0 comments on commit 0d87cbe

Please sign in to comment.