Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Fix): Use new slack schema #920

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,19 @@ jobs:
# This job is used to update the list of validated versions
linter_tests_release:
name: Plugin Tests Release
# runs-on: [self-hosted, "${{ matrix.os }}"] TODO(Tyler): Set after Windows self-hosted are established.
runs-on: ${{ matrix.os }}
timeout-minutes: 150
strategy:
fail-fast: false
matrix:
linter-version: [Snapshots, Latest]
os: [ubuntu-latest, macOS, windows-latest]
os: [ubuntu-latest, macOS]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been failing rather noisily. Until we can invest time to burn it down, I'm disabling it

include:
# Normalize the filenames as inputs for ease of parsing
- os: ubuntu-latest
results-file: ubuntu-latest
- os: macOS
results-file: macos-latest
- os: windows-latest
results-file: windows-latest
outputs:
plugin-version: ${{ steps.get-release.outputs.tag }}

Expand Down
83 changes: 33 additions & 50 deletions .github/workflows/upload_results.reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,16 @@ jobs:
steps.download-ubuntu.outcome == 'failure' || steps.download-macos.outcome == 'failure' ||
steps.download-windows.outcome == 'failure'
with:
channel-id: ${{ env.SLACK_CHANNEL_ID }}
method: chat.postMessage
token: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
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 }}) >"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
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 }}) >"

- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
Expand All @@ -139,15 +133,17 @@ 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"
failures_payload=$(cat failures.yaml)
printf "failures-payload<<EOF\n%s\nEOF\n" "$failures_payload" >> "$GITHUB_OUTPUT"
echo "reruns=$(cat reruns.txt)" >> "$GITHUB_OUTPUT"
env:
PLUGIN_VERSION: ${{ inputs.plugin-version }}
# Used to format Slack notification for failures
RUN_ID: ${{ github.run_id }}
TEST_REF: ${{ inputs.test-ref }}
TEST_TYPE: ${{ inputs.test-type }}
SLACK_CHANNEL_ID: ${{ env.SLACK_CHANNEL_ID }}

- name: Upload Test Results Staging
if: inputs.upload-validated-versions == true
Expand Down Expand Up @@ -184,52 +180,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 }}
method: chat.postMessage
token: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
payload: ${{ 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 }}
method: chat.postMessage
token: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
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 >"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
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 >"

- 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 }}
method: chat.postMessage
token: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
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 >"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
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 >"
generate_snapshots_pr:
name: Generate Snapshots PR
runs-on: ubuntu-latest
Expand Down
49 changes: 28 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@typescript-eslint/parser": "^8.14.0",
"caller": "^1.1.0",
"debug": "^4.3.7",
"eslint": "^9.15.0",
"eslint": "9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.31.0",
Expand Down
6 changes: 4 additions & 2 deletions tests/parse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import {
} from "tests/types";
import { REPO_ROOT } from "tests/utils";
import { getTrunkVersion } from "tests/utils/trunk_config";
import YAML from "yaml";

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 @@ -299,10 +300,11 @@ const writeFailuresForNotification = (failures: FailedVersion[]) => {
const blocks = allBlocks.length > 50 ? allBlocks.slice(0, 49).concat(remainingBlock) : allBlocks;

const failuresObject = {
channel: process.env.SLACK_CHANNEL_ID,
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
Loading