Skip to content

Commit

Permalink
Merge branch 'main' into renovate/actions-checkout-4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
EliSchleifer authored Dec 7, 2023
2 parents 7da7308 + 2b7039b commit 0367707
Show file tree
Hide file tree
Showing 30 changed files with 1,105 additions and 283 deletions.
6 changes: 3 additions & 3 deletions .github/actions/linter_tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ runs:

- name: Run plugin tests
if: runner.os == 'Windows'
run: npm test --ci ${{ inputs.append-args }} ${{ env.PLATFORM_APPEND_ARGS }}
run: npm test ${{ inputs.append-args }} ${{ env.PLATFORM_APPEND_ARGS }} --ci
shell: bash
working-directory: ${{ inputs.path }}
env:
Expand All @@ -87,10 +87,10 @@ runs:
working-directory: ${{ inputs.path }}
trunk-token: ${{ inputs.trunk-token }}
org: trunk-staging-org
run: npm test --ci ${{ inputs.append-args }} ${{ env.PLATFORM_APPEND_ARGS }}
run: npm test ${{ inputs.append-args }} ${{ env.PLATFORM_APPEND_ARGS }} --ci
env:
PLUGINS_TEST_LINTER_VERSION: ${{ inputs.linter-version }}
PLUGINS_TEST_CLI_VERSION: ${{ inputs.cli-version }}
PLUGINS_TEST_CLI_PATH: ${{ env.CLI_PATH }}
SOURCERY_TOKEN: ${{ inputs.sourcery-token }}
DEBUG: Driver:nixpkgs-fmt:*
DEBUG: Driver:nixpkgs-fmt:*, Driver:eslint:*
4 changes: 2 additions & 2 deletions .github/actions/tool_tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ runs:

- name: Run plugin tests
if: runner.os == 'Windows'
run: npm test --ci ${{ inputs.append-args }} ${{ env.PLATFORM_APPEND_ARGS }}
run: npm test ${{ inputs.append-args }} ${{ env.PLATFORM_APPEND_ARGS }} --ci
shell: bash
working-directory: ${{ inputs.path }}
env:
Expand All @@ -67,7 +67,7 @@ runs:
working-directory: ${{ inputs.path }}
trunk-token: ${{ inputs.trunk-token }}
org: trunk-staging-org
run: npm test --ci ${{ inputs.append-args }} ${{ env.PLATFORM_APPEND_ARGS }}
run: npm test ${{ inputs.append-args }} ${{ env.PLATFORM_APPEND_ARGS }} --ci
env:
PLUGINS_TEST_CLI_VERSION: ${{ inputs.cli-version }}
PLUGINS_TEST_CLI_PATH: ${{ env.CLI_PATH }}
218 changes: 44 additions & 174 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,184 +190,22 @@ jobs:
name: ${{ matrix.results-file }}-test-results
path: ${{ matrix.results-file }}-res.json

upload_test_results:
name: Upload Test Results
upload_linter_tests:
name: Upload Linter Test Results
needs: linter_tests_release
runs-on: ubuntu-x64
# Still run on test failure
if: always()
timeout-minutes: 10
env:
SLACK_CHANNEL_ID: plugins-notifications
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Retrieve Test Outputs ubuntu
id: download-ubuntu
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
continue-on-error: true
with:
name: ubuntu-latest-test-results

- name: Retrieve Test Outputs macOS
id: download-macos
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
continue-on-error: true
with:
name: macos-latest-test-results

- name: Retrieve Test Outputs Windows
id: download-windows
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
continue-on-error: true
with:
name: windows-latest-test-results

- name: Print Test Outputs
continue-on-error: true
shell: bash
run: |
echo "::group::Ubuntu results"
cat "ubuntu-latest-res.json" || echo "missing"
echo "::endgroup::"
echo "::group::Macos results"
cat "macos-latest-res.json" || echo "missing"
echo "::endgroup::"
echo "::group::Windows results"
cat "windows-latest-res.json" || echo "missing"
echo "::endgroup::"
- name: Slack Notification For Missing Artifacts
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
if:
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 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 }}

- name: Setup Node
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
node-version: 18

- name: Install Dependencies
shell: bash
run: npm ci

- name: Add npm bin to path
shell: bash
run: echo "$PWD/node_modules/.bin" >> "$GITHUB_PATH"

- name: Parse Test Results
shell: bash
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"
env:
PLUGIN_VERSION: ${{needs.linter_tests_release.outputs.plugin-version}}
# Used to format Slack notification for failures
RUN_ID: ${{ github.run_id }}
TEST_REF: Release

- name: Upload Test Results Staging
continue-on-error: true
id: upload-staging
env:
TRUNK_API_TOKEN: ${{ secrets.TRUNK_STAGING_API_TOKEN }}
TRUNK_API_ADDRESS: api.trunk-staging.io:8443
# upload-linter-versions is a hidden command reserved exclusively for uploading
# validated results from the plugins repo.
# daemon must be restarted in order to propagate environment variable
shell: bash
run: |
trunk daemon shutdown
trunk upload-linter-versions --token="$TRUNK_API_TOKEN" results.json
- name: Upload Test Results Prod
continue-on-error: true
id: upload-prod
env:
TRUNK_API_TOKEN: ${{ secrets.TRUNK_API_TOKEN }}
TRUNK_API_ADDRESS: api.trunk.io:8443
# upload-linter-versions is a hidden command reserved exclusively for uploading
# validated results from the plugins repo.
# daemon must be restarted in order to propagate environment variable
shell: bash
run: |
trunk daemon shutdown
trunk upload-linter-versions --token="$TRUNK_API_TOKEN" results.json
# Slack notifications
- name: Slack Notification For Failures
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
if: always() && steps.parse.outputs.failures == 'true'
with:
channel-id: ${{ env.SLACK_CHANNEL_ID }}
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@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
if: 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 >"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}

- name: Slack Notification For Prod Upload Failure
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
if: 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 >"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
uses: ./.github/workflows/upload_results.reusable.yaml
secrets:
TRUNKBOT_SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
TRUNK_STAGING_API_TOKEN: ${{ secrets.TRUNK_STAGING_API_TOKEN }}
TRUNK_API_TOKEN: ${{ secrets.TRUNK_API_TOKEN }}
with:
plugin-version: ${{ needs.linter_tests_release.outputs.plugin-version }}
upload-validated-versions: true
test-type: linter
test-ref: latest release

# Run tool tests only on main
tool_tests_main:
Expand All @@ -379,6 +217,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-x64, macOS, windows-latest]
include:
# Normalize the filenames as inputs for ease of parsing
- os: ubuntu-x64
results-file: ubuntu-latest
- os: macOS
results-file: macos-latest
- os: windows-latest
results-file: windows-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -388,8 +234,32 @@ jobs:
- name: Tool Tests ${{ matrix.os }}
uses: ./.github/actions/tool_tests
with:
append-args: tools -- --json --outputFile=${{ matrix.results-file }}-res.json
trunk-token: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}

- name: Upload Test Outputs for Notification Job
# Always run, except when cancelled.
if: (failure() || success())
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: tools-${{ matrix.results-file }}-test-results
path: ${{ matrix.results-file }}-res.json

upload_tool_tests:
name: Upload Tool Test Results
needs: tool_tests_main
# Still run on test failure
if: always()
uses: ./.github/workflows/upload_results.reusable.yaml
secrets:
TRUNKBOT_SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
with:
plugin-version: main
results-prefix: tools-
upload-validated-versions: false
test-type: tool
test-ref: main

# Run repo healthcheck tests
repo_tests:
name: Repo Tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/repo_tests.reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: npm ci

- name: Run repo tests
run: npm test --ci tests/repo_tests
run: npm test tests/repo_tests --ci
env:
PLUGINS_TEST_CLI_VERSION: ${{ inputs.cli-version }}
PLUGINS_TEST_CLI_PATH: ${{ inputs.cli-path }}
Loading

0 comments on commit 0367707

Please sign in to comment.