Skip to content

Commit

Permalink
test new slack schema
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerJang27 committed Nov 19, 2024
1 parent cc2d9d9 commit 2b52d16
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 49 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ on:
# Times in UTC (PST+8), this translates to running Mon-Fri at 2am/3am (depending on DST)
- cron: 0 10 * * 1-5
# Only enable on pull requests for testing
# pull_request:
# paths: [.github/workflows/nightly.yaml]
# DONOTLAND: REVERT THIS

Check failure on line 7 in .github/workflows/nightly.yaml

View check run for this annotation

Trunk-Staging.io / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'

Check failure on line 7 in .github/workflows/nightly.yaml

View workflow job for this annotation

GitHub Actions / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'
pull_request:
paths: [.github/workflows/nightly.yaml]
workflow_dispatch: {}

permissions:
Expand All @@ -30,6 +31,8 @@ jobs:
name: Plugin Tests Main
# runs-on: [self-hosted, "${{ matrix.os }}"] TODO(Tyler): Set after Windows self-hosted are established.
runs-on: ${{ matrix.os }}
# DONOTLAND: REVERT THIS

Check failure on line 34 in .github/workflows/nightly.yaml

View check run for this annotation

Trunk-Staging.io / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'

Check failure on line 34 in .github/workflows/nightly.yaml

View workflow job for this annotation

GitHub Actions / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'
if: false
timeout-minutes: 120
strategy:
fail-fast: false
Expand Down Expand Up @@ -174,7 +177,9 @@ jobs:
uses: ./.github/actions/linter_tests
with:
linter-version: ${{ matrix.linter-version }}
append-args: linters -- --json --outputFile=${{ matrix.results-file }}-res.json
# DONOTLAND: REVERT THIS

Check failure on line 180 in .github/workflows/nightly.yaml

View check run for this annotation

Trunk-Staging.io / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'

Check failure on line 180 in .github/workflows/nightly.yaml

View workflow job for this annotation

GitHub Actions / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'
append-args: linters/t -- --json --outputFile=${{ matrix.results-file }}-res.json
# append-args: linters -- --json --outputFile=${{ matrix.results-file }}-res.json
ref-type: release
sourcery-token: ${{ secrets.TRUNK_SOURCERY_TOKEN }}
trunk-staging-token: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}
Expand Down Expand Up @@ -214,6 +219,8 @@ jobs:
tool_tests_main:
name: Tool Tests Main
# runs-on: [self-hosted, "${{ matrix.os }}"] TODO(Tyler): Set after Windows self-hosted are established.
# DONOTLAND: REVERT THIS

Check failure on line 222 in .github/workflows/nightly.yaml

View check run for this annotation

Trunk-Staging.io / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'

Check failure on line 222 in .github/workflows/nightly.yaml

View workflow job for this annotation

GitHub Actions / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'
if: false
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
Expand Down Expand Up @@ -253,7 +260,9 @@ jobs:
name: Upload Tool Test Results
needs: tool_tests_main
# Still run on test failure
if: always()
# DONOTLAND: REVERT THIS

Check failure on line 263 in .github/workflows/nightly.yaml

View check run for this annotation

Trunk-Staging.io / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'

Check failure on line 263 in .github/workflows/nightly.yaml

View workflow job for this annotation

GitHub Actions / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'
# if: always()
if: false
uses: ./.github/workflows/upload_results.reusable.yaml
secrets:
TRUNKBOT_SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
Expand All @@ -270,10 +279,14 @@ jobs:
# Run repo healthcheck tests
repo_tests:
name: Repo Tests
# DONOTLAND: REVERT THIS

Check failure on line 282 in .github/workflows/nightly.yaml

View check run for this annotation

Trunk-Staging.io / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'

Check failure on line 282 in .github/workflows/nightly.yaml

View workflow job for this annotation

GitHub Actions / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'
if: false
uses: ./.github/workflows/repo_tests.reusable.yaml

action_tests_main:
name: Action Tests Main
# DONOTLAND: REVERT THIS

Check failure on line 288 in .github/workflows/nightly.yaml

View check run for this annotation

Trunk-Staging.io / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'

Check failure on line 288 in .github/workflows/nightly.yaml

View workflow job for this annotation

GitHub Actions / Trunk Check

trunk-toolbox(do-not-land)

[new] Found 'DONOTLAND'
if: false
runs-on: [ubuntu-latest]
timeout-minutes: 30
steps:
Expand Down
69 changes: 26 additions & 43 deletions .github/workflows/upload_results.reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,14 @@ jobs:
steps.download-ubuntu.outcome == 'failure' || steps.download-macos.outcome == 'failure' ||
steps.download-windows.outcome == 'failure'
with:
channel-id: ${{ env.SLACK_CHANNEL_ID }}
payload: |
{
"text": "Artifact Download Failure",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Failure: <https://github.com/trunk-io/plugins/actions/runs/${{ github.run_id }}| Unable to download some ${{ inputs.results-prefix }}test result artifacts (ubuntu: ${{ steps.download-ubuntu.outcome }}, macos: ${{ steps.download-macos.outcome }}, windows: ${{ steps.download-windows.outcome }}) >"
}
}
]
}
channel: ${{ env.SLACK_CHANNEL_ID }}
text: "Artifact Download Failure"
blocks:
- type: section
text:
type: mrkdwn
text: "Failure: <https://github.com/trunk-io/plugins/actions/runs/${{ github.run_id }}| Unable to download some ${{ inputs.results-prefix }}test result artifacts (ubuntu: ${{ steps.download-ubuntu.outcome }}, macos: ${{ steps.download-macos.outcome }}, windows: ${{ steps.download-windows.outcome }}) >"
env:
SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}

Expand All @@ -139,8 +133,8 @@ jobs:
id: parse
run: |
npm run parse
echo "failures=$([[ -f failures.json ]] && echo "true" || echo "false")" >> "$GITHUB_OUTPUT"
echo "failures-payload=$(cat failures.json)" >> "$GITHUB_OUTPUT"
echo "failures=$([[ -f failures.yaml ]] && echo "true" || echo "false")" >> "$GITHUB_OUTPUT"
echo "failures-payload=$(cat failures.yaml)" >> "$GITHUB_OUTPUT"
echo "reruns=$(cat reruns.txt)" >> "$GITHUB_OUTPUT"
env:
PLUGIN_VERSION: ${{ inputs.plugin-version }}
Expand Down Expand Up @@ -184,50 +178,39 @@ jobs:
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
if: always() && steps.parse.outputs.failures == 'true'
with:
channel-id: ${{ env.SLACK_CHANNEL_ID }}
payload: ${{ steps.parse.outputs.failures-payload }}
payload: |
channel: ${{ env.SLACK_CHANNEL_ID }}
${{ steps.parse.outputs.failures-payload }}
env:
SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}

- name: Slack Notification For Staging Upload Failure
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
if: inputs.upload-validated-versions == true && steps.upload-staging.outcome == 'failure'
with:
channel-id: ${{ env.SLACK_CHANNEL_ID }}
payload: |
{
"text": "Upload Failure",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Failure: <https://github.com/trunk-io/plugins/actions/runs/${{ github.run_id }}| Upload Test Results to Staging >"
}
}
]
}
channel: ${{ env.SLACK_CHANNEL_ID }}
text: "Upload Failure"
blocks:
- type: section
text:
type: mrkdwn
text: "Failure: <https://github.com/trunk-io/plugins/actions/runs/${{ github.run_id }}| Upload Test Results to Staging >"
env:
SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}

- name: Slack Notification For Prod Upload Failure
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
if: inputs.upload-validated-versions == true && steps.upload-prod.outcome == 'failure'
with:
channel-id: ${{ env.SLACK_CHANNEL_ID }}
payload: |
{
"text": "Upload Failure",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Failure: <https://github.com/trunk-io/plugins/actions/runs/${{ github.run_id }}| Upload Test Results to Prod >"
}
}
]
}
channel: ${{ env.SLACK_CHANNEL_ID }}
text: "Upload Failure"
blocks:
- type: section
text:
type: mrkdwn
text: "Failure: <https://github.com/trunk-io/plugins/actions/runs/${{ github.run_id }}| Upload Test Results to Prod >"
env:
SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
generate_snapshots_pr:
Expand Down
5 changes: 3 additions & 2 deletions tests/parse/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as fs from "fs";
import path from "path";
import YAML from "yaml";
import {
FailedVersion,
FailureMode,
Expand All @@ -13,7 +14,7 @@ import { REPO_ROOT } from "tests/utils";
import { getTrunkVersion } from "tests/utils/trunk_config";

const RESULTS_FILE = path.resolve(REPO_ROOT, "results.json");
const FAILURES_FILE = path.resolve(REPO_ROOT, "failures.json");
const FAILURES_FILE = path.resolve(REPO_ROOT, "failures.yaml");
const RERUN_FILE = path.resolve(REPO_ROOT, "reruns.txt");

const VALIDATED_LINTER_BLOCKLIST: string[] = [];
Expand Down Expand Up @@ -302,7 +303,7 @@ const writeFailuresForNotification = (failures: FailedVersion[]) => {
text: `${failures.length} failures encountered running plugins tests for ${TEST_REF}`,
blocks,
};
const failuresString = JSON.stringify(failuresObject);
const failuresString = YAML.stringify(failuresObject);
fs.writeFileSync(FAILURES_FILE, failuresString);
console.log(`Wrote ${failures.length} failures out to ${FAILURES_FILE}:`);
console.log(failuresString);
Expand Down

0 comments on commit 2b52d16

Please sign in to comment.