Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: trunk-io/trunk-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.15
Choose a base ref
...
head repository: trunk-io/trunk-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.16
Choose a head ref
  • 3 commits
  • 3 files changed
  • 3 contributors

Commits on May 28, 2024

  1. Upgrade trunk (#244)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    1 plugin was upgraded:
    
    - trunk-io/configs v1.0.4 → v1.0.5
    
    This PR was generated by the [Trunk Action]. For more info, see our
    [docs] or reach out on [Slack].
    
    [Trunk Action]: https://github.com/trunk-io/trunk-action
    [docs]: https://docs.trunk.io
    [Slack]: https://slack.trunk.io/
    
    Co-authored-by: TylerJang27 <42743566+TylerJang27@users.noreply.github.com>
    trunk-open-pr-bot[bot] and TylerJang27 authored May 28, 2024
    Copy the full SHA
    f64973b View commit details

Commits on Jun 19, 2024

  1. Upgrade trunk to 1.22.2 (#246)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    cli upgraded: 1.22.1 → 1.22.2
    
    1 plugin was upgraded:
    
    - trunk-io/plugins v1.5.0 → v1.6.0
    
    This PR was generated by the [Trunk Action]. For more info, see our
    [docs] or reach out on [Slack].
    
    [Trunk Action]: https://github.com/trunk-io/trunk-action
    [docs]: https://docs.trunk.io
    [Slack]: https://slack.trunk.io/
    
    Co-authored-by: TylerJang27 <42743566+TylerJang27@users.noreply.github.com>
    trunk-open-pr-bot[bot] and TylerJang27 authored Jun 19, 2024
    Copy the full SHA
    6eac1bb View commit details

Commits on Jun 25, 2024

  1. [feat] add timeout and ability to cat debug logs (#245)

    There may be times where the trunk action is unresponsive and is hung in
    CI.
    To understand whether this is a linter or trunk cli issue, we'll need
    logs to confirm.
    
    This PR adds the following optional inputs `timeout-seconds` and
    `cat-trunk-debug-logs`
    which will wrap the trunk check action with the unix `timeout` command
    should the user supply an argument for `timeout-seconds`
    
    Should the user specify `cat-trunk-debug-logs: true`, the trunk action
    will also cat out cli & daemon logs from `.trunk/logs/`
    
    Unfortunately, `timeout-minutes` doesn't work in `composite-actions` see
    actions/runner#1979
    and https://github.com/orgs/community/discussions/50481
    
    **Test Plan**:
    <details>
    
    <summary>End to End test to ensure timeout + logs work</summary>
    
    <img width="1873" alt="image"
    src="https://github.com/trunk-io/trunk-action/assets/31294356/27ca9a1b-fe54-4e73-928e-63625d1f934e">
    
    
    </details>
    
    <details>
    
    <summary>End to End test to ensure timeout works </summary>
    
    <img width="1878" alt="image"
    src="https://github.com/trunk-io/trunk-action/assets/31294356/8fb7351a-11c0-4e83-9490-864c6ecdafc0">
    
    
    
    </details>
    
    - [ ] Add Regression test (not entirely sure I can run this workflow)
    May need some help here!
    Ryang20718 authored Jun 25, 2024
    Copy the full SHA
    86b68ff View commit details
Showing with 100 additions and 7 deletions.
  1. +43 −0 .github/workflows/action_tests.yaml
  2. +3 −3 .trunk/trunk.yaml
  3. +54 −4 action.yaml
43 changes: 43 additions & 0 deletions .github/workflows/action_tests.yaml
Original file line number Diff line number Diff line change
@@ -419,6 +419,49 @@ jobs:
npm install
./action_tests/assert.js all-hold-the-line-no-upload-id
pull_request_expect_trunk_check_timeout:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: local-action

- name: Set up test
shell: bash
run: |
./local-action/action_tests/setup.sh src-repo repo-under-test
cd repo-under-test
git checkout feature-branch
echo "EXPECTED_UPSTREAM=$(git rev-parse feature-branch^1)" >>$GITHUB_ENV
- name: Run trunk-action
shell: bash
id: trunk-action
run: |
cd repo-under-test
git checkout feature-branch
../local-action/pull_request.sh
env:
INPUT_ARGUMENTS: ""
INPUT_CHECK_RUN_ID: 12345678
INPUT_DEBUG: ""
INPUT_LABEL: ""
TRUNK_PATH: ../local-action/action_tests/stub.js
INPUT_GITHUB_REF_NAME: feature-branch
GITHUB_EVENT_PULL_REQUEST_NUMBER: ""
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ env.EXPECTED_UPSTREAM }}
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ""
GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FORK: ""
INPUT_SAVE_ANNOTATIONS: ""
INPUT_AUTOFIX_AND_PUSH: true
INPUT_TIMEOUT_SECONDS: 1

- name: Assert trunk-action check has failed
shell: bash
if: steps.trunk-action.outcome == 'success'
run: exit 1

pull_request_autofix:
runs-on: ubuntu-latest
steps:
6 changes: 3 additions & 3 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: 0.1

cli:
version: 1.22.1
version: 1.22.2

plugins:
sources:
- id: trunk
ref: v1.5.0
ref: v1.6.0
uri: https://github.com/trunk-io/plugins
- id: configs
ref: v1.0.4
ref: v1.0.5
uri: https://github.com/trunk-io/configs

lint:
58 changes: 54 additions & 4 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -102,6 +102,18 @@ inputs:
required: false
default: "false"

timeout-seconds:
description:
Timeout seconds before we kill the long running trunk check process via unix timeout command.
Default setting of 0 seconds disables the timeout.
required: false
default: 0

cat-trunk-debug-logs:
description: Option to cat .trunk/logs/cli.log && .trunk/logs/daemon.log
required: false
default: false

runs:
using: composite
steps:
@@ -179,6 +191,7 @@ runs:
INPUT_CACHE=${{ inputs.cache }}
INPUT_CACHE_KEY=trunk-${{ inputs.cache-key }}-${{ runner.os }}-${{ hashFiles('.trunk/trunk.yaml') }}
INPUT_CACHE_PATH=~/.cache/trunk
INPUT_CAT_TRUNK_DEBUG_LOGS=${{ inputs.cat-trunk-debug-logs }}
INPUT_CHECK_ALL_MODE=${{ inputs.check-all-mode }}
INPUT_CHECK_MODE=${{ inputs.check-mode }}
INPUT_CHECK_RUN_ID=${{ inputs.check-run-id }}
@@ -189,6 +202,7 @@ runs:
INPUT_SETUP_DEPS=${{ inputs.setup-deps }}
INPUT_TARGET_CHECKOUT=
INPUT_TARGET_CHECKOUT_REF=
INPUT_TIMEOUT_SECONDS=${{ inputs.timeout-seconds }}
INPUT_TRUNK_PATH=${{ inputs.trunk-path }}
INPUT_UPLOAD_LANDING_STATE=false
INPUT_UPLOAD_SERIES=${{ inputs.upload-series }}
@@ -260,7 +274,11 @@ runs:
shell: bash
run: |
# Run 'trunk check' on pull request
${GITHUB_ACTION_PATH}/pull_request.sh
if [[ "${{ inputs.timeout-seconds }}" != "0" ]]; then
timeout ${{ inputs.timeout-seconds }} ${GITHUB_ACTION_PATH}/pull_request.sh
else
${GITHUB_ACTION_PATH}/pull_request.sh
fi
env:
INPUT_SAVE_ANNOTATIONS: ${{ inputs.save-annotations }}

@@ -269,7 +287,11 @@ runs:
shell: bash
run: |
# Run 'trunk check' on push
${GITHUB_ACTION_PATH}/push.sh
if [[ "${{ inputs.timeout-seconds }}" != "0" ]]; then
timeout ${{ inputs.timeout-seconds }} ${GITHUB_ACTION_PATH}/push.sh
else
${GITHUB_ACTION_PATH}/push.sh
fi
env:
GITHUB_EVENT_AFTER: ${{ env.GITHUB_EVENT_AFTER || github.event.after }}
GITHUB_EVENT_BEFORE: ${{ env.GITHUB_EVENT_BEFORE || github.event.before }}
@@ -279,14 +301,42 @@ runs:
shell: bash
run: |
# Run 'trunk check' on all
${GITHUB_ACTION_PATH}/all.sh
if [[ "${{ inputs.timeout-seconds }}" != "0" ]]; then
timeout ${{ inputs.timeout-seconds }} ${GITHUB_ACTION_PATH}/all.sh
else
${GITHUB_ACTION_PATH}/all.sh
fi
- name: Run trunk check on Trunk Merge
if: env.TRUNK_CHECK_MODE == 'trunk_merge'
shell: bash
run: |
# Run 'trunk check' on Trunk Merge
${GITHUB_ACTION_PATH}/trunk_merge.sh
if [[ "${{ inputs.timeout-seconds }}" != "0" ]]; then
timeout ${{ inputs.timeout-seconds }} ${GITHUB_ACTION_PATH}/trunk_merge.sh
else
${GITHUB_ACTION_PATH}/trunk_merge.sh
fi
- name: Cat Trunk Cli / Daemon logs
if: always() && inputs.cat-trunk-debug-logs == 'true'
shell: bash
run: |
echo "::group::.trunk/logs/cli.log"
if [ -f .trunk/logs/cli.log ]; then
cat .trunk/logs/cli.log
else
echo ".trunk/logs/cli.log doesn't exist"
fi
echo "::endgroup::"
echo "::group::.trunk/logs/daemon.log"
if [ -f .trunk/logs/daemon.log ]; then
cat .trunk/logs/daemon.log
else
echo ".trunk/logs/daemon.log doesn't exist"
fi
echo "::endgroup::"
- name: Run trunk install to populate the GitHub Actions cache
if: env.TRUNK_CHECK_MODE == 'populate_cache_only'