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: 6522858
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: 86b68ff
Choose a head ref
  • 19 commits
  • 12 files changed
  • 8 contributors

Commits on Feb 19, 2024

  1. Upgrade trunk to 1.20.0 (#220)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    cli upgraded: 1.19.0 → 1.20.0
    
    2 plugins were upgraded:
    
    - trunk-io/configs v1.0.1 → v1.0.2
    - trunk-io/plugins v1.4.2 → v1.4.3
    
    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 <TylerJang27@users.noreply.github.com>
    trunk-open-pr-bot[bot] and TylerJang27 authored Feb 19, 2024
    Copy the full SHA
    76fcbaf View commit details

Commits on Feb 26, 2024

  1. Upgrade trunk to 1.20.1 (#227)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    cli upgraded: 1.20.0 → 1.20.1
    
    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 <TylerJang27@users.noreply.github.com>
    trunk-open-pr-bot[bot] and TylerJang27 authored Feb 26, 2024
    Copy the full SHA
    21be1f4 View commit details

Commits on Feb 27, 2024

  1. (Feat): Add setup-trunk action (#225)

    Factor out trunk-setup
    
    Can be called with:
    uses: trunk-io/trunk-action/setup-trunk@v1
    pat-trunk-io authored Feb 27, 2024
    Copy the full SHA
    7470cc1 View commit details

Commits on Feb 28, 2024

  1. Setup trunk instructions (#228)

    pat-trunk-io authored Feb 28, 2024
    Copy the full SHA
    ca8acdf View commit details

Commits on Mar 4, 2024

  1. Fix upgrade action setup (#229)

    Fixes the path to `locate_trunk.sh` and bumps the `create-pull-request`
    to v6.
    
    Successful
    [run](https://github.com/trunk-io/trunk-action/actions/runs/8145406935/job/22261584720)
    and [PR](#230)
    TylerJang27 authored Mar 4, 2024
    Copy the full SHA
    8fb66f9 View commit details
  2. Upgrade trunk (#230)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    1 plugin was upgraded:
    
    - trunk-io/plugins v1.4.3 → v1.4.4
    
    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 Mar 4, 2024
    Copy the full SHA
    11cf68d View commit details

Commits on Mar 11, 2024

  1. Upgrade trunk (#232)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    1 plugin was upgraded:
    
    - trunk-io/configs v1.0.2 → v1.0.4
    
    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 Mar 11, 2024
    Copy the full SHA
    56bee28 View commit details

Commits on Mar 18, 2024

  1. Upgrade trunk to 1.21.0 (#233)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    cli upgraded: 1.20.1 → 1.21.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 Mar 18, 2024
    Copy the full SHA
    718b71f View commit details

Commits on Mar 25, 2024

  1. Upgrade trunk (#235)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    1 plugin was upgraded:
    
    - trunk-io/plugins v1.4.4 → v1.4.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 Mar 25, 2024
    Copy the full SHA
    4feb07f View commit details
  2. add install action to install all trunk tools in trunk.yaml (#234)

    install will pull trunk launcher from cloud into tmp location and then
    run the `trunk tools install` command.
    
    Optionally installs that are specified - else installs everything.
    
    Example of using it in flaky factory
    
    
    https://github.com/trunk-io/flake-factory/blob/main/.github/workflows/factory.yaml
    
          - name: trunk install
    uses:
    54ccfcf
    EliSchleifer authored Mar 25, 2024
    Copy the full SHA
    540e7fe View commit details

Commits on Apr 4, 2024

  1. feat: continue on node package install failure (#236)

    ### Problem
    
    Currently, most of our check-on-prs/check nightly failures occur while
    installing node packages, for a variety of reasons. Right now, this
    causes the check to fail, and we report that "something went wrong".
    Instead, we may want to disable linters that depend on node-modules
    (specifically, stylelint and eslint) and lint the remaining files to
    report our best-effort results.
    
    Pros:
    - We would report some issues, and some issues is better than no issues
    - We wouldn't be erroring with a message that seems like an internal
    error (because for all we know right now, it could be)
    
    Cons:
    - A user could introduce a lint issue in the same PR as a breaking
    change to package.json and we would pass that PR
    - I am pretty sure that we don't have a great way of surfacing to the
    user that we're disabling eslint without writing an annoying amount of
    boilerplate to send the data through the cli through services back to
    github
      - We do log this in the action logs, but that's the most visible place
    
    ### Solution
    
    After talking with Sam about this, we figured the best solution is to
    disable the linters if we are auto-initing for the user, but not if the
    user has a trunk.yaml and therefore has deliberately opted to see ts/js
    issues.
    
    ### Testing
    
    Added a repo test for
    [prawn-test-staging-rw/node-packages-failure-test](https://github.com/prawn-test-staging-rw/node-packages-failure-test/tree/main)
    that has an invalid package.json, and checks to make sure the action
    disables eslint and stylelint, and continues after the failure.
    puzzler7 authored Apr 4, 2024
    Copy the full SHA
    da67635 View commit details

Commits on Apr 29, 2024

  1. Upgrade trunk to 1.22.0 (#237)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    cli upgraded: 1.21.0 → 1.22.0
    
    1 plugin was upgraded:
    
    - trunk-io/plugins v1.4.5 → v1.5.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 Apr 29, 2024
    Copy the full SHA
    246fbe9 View commit details

Commits on May 8, 2024

  1. feat: add option for Signed-Off-By line in upgrade action (#238)

    Adds support for adding a `Signed-Off-By` line to commits created by the
    upgrade action, as requested
    [here](trunk-io/plugins#764).
    
    Tested in this repo, you can see the commit
    [here](cc7d39d).
    puzzler7 authored May 8, 2024
    Copy the full SHA
    bd68632 View commit details

Commits on May 13, 2024

  1. Upgrade trunk to 1.22.1 (#242)

    [![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io)
    
    cli upgraded: 1.22.0 → 1.22.1
    
    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 13, 2024
    Copy the full SHA
    4a49915 View commit details

Commits on May 14, 2024

  1. Add inputs/outputs to upgrade action (#241)

    Per a user request, adds the following:
    - Input for assignees
    - Input to override the default created branch name
    - Output the PR number and other PR info for consumption from other
    actions
    
    Verified
    [run](https://github.com/trunk-io/trunk-action/actions/runs/9038985803/job/24841100064)
    TylerJang27 authored May 14, 2024
    Copy the full SHA
    d5b1b61 View commit details

Commits on May 16, 2024

  1. fix: attempt to install specified pnpm version (#243)

    Currently, we only install the latest pnpm version, which fails if the
    user has specified a pnpm version under `packageManager` in their
    package.json. This PR changes that to attempt to parse the version out
    of the package.json before defaulting to latest.
    
    The `pnpm/action-setup` action does have logic for parsing the version
    out of the package.json, but we cannot provide both an version and a
    version in the package.json, or it will fail ([source
    link](https://github.com/pnpm/action-setup/blob/master/src/install-pnpm/run.ts#L64)).
    
    Tested manually, both with and without the `packageManager` field.
    puzzler7 authored May 16, 2024
    Copy the full SHA
    f6c5f1b View commit details

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
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:
27 changes: 20 additions & 7 deletions .github/workflows/repo_tests.yaml
Original file line number Diff line number Diff line change
@@ -35,7 +35,8 @@ jobs:
description: (compile-commands.json)
post-init: |
# black complains about py2 code
${TRUNK_PATH} check disable black
# markdownlint fails for some reason, and what we really care about anyways is clang-tidy
${TRUNK_PATH} check disable black markdownlint
mkdir build
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
@@ -44,8 +45,6 @@ jobs:
sed -i "s|lint:|lint:\n compile_commands: json|" .trunk/trunk.yaml
cp local-action/repo_tests/yaml_cpp.yaml .trunk/user.yaml
${TRUNK_PATH} check enable clang-tidy
# markdownlint fails for some reason, and what we really care about anyways is clang-tidy
${TRUNK_PATH} check disable markdownlint
- repo: pallets/flask
ref: 4bcd4be6b7d69521115ef695a379361732bcaea6
@@ -75,6 +74,23 @@ jobs:
fi
description: (test for setup-node)

- repo: prawn-test-staging-rw/node-packages-failure-test
ref: main
post-init: |
if [ "${FAILED_NODE_PACKAGE_INSTALL}" != "true" ]; then
echo "::error::Node package install didn't fail"
exit 1
fi
if grep -q "✔ eslint" <(${TRUNK_PATH} check list --color=false); then
echo "::error::eslint not disabled"
exit 1
fi
if grep -q "✔ stylelint" <(${TRUNK_PATH} check list --color=false); then
echo "::error::stylelint not disabled"
exit 1
fi
description: (test for continuing on node package install failure)

- repo: replayio/devtools
ref: 730a9f0ddaafefc2a1a293d6924ce3910cd156ac
description: (has trunk.yaml)
@@ -95,10 +111,7 @@ jobs:
description: (has trunk.yaml)
post-init: |
# all of these linters have failures
${TRUNK_PATH} check disable svgo
${TRUNK_PATH} check disable golangci-lint
${TRUNK_PATH} check disable prettier
${TRUNK_PATH} check disable oxipng
${TRUNK_PATH} check disable svgo golangci-lint prettier oxipng
- repo: shopify/draggable
ref: e6cf325a98c11b8aefbfb626b7a91b95d1c340c9
1 change: 1 addition & 0 deletions .github/workflows/weekly.yaml
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ jobs:
private_key: ${{ secrets.TRUNK_OPEN_PR_APP_PRIVATE_KEY }}

- name: Trunk Upgrade
id: upgrade
uses: ./upgrade # external users: use trunk-io/trunk-action/upgrade@v1
with:
github-token: ${{ steps.generate-token.outputs.token }}
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.19.0
version: 1.22.2

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

lint:
61 changes: 56 additions & 5 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 }}
@@ -210,7 +224,7 @@ runs:

- name: Locate trunk
shell: bash
run: ${GITHUB_ACTION_PATH}/locate_trunk.sh
run: ${GITHUB_ACTION_PATH}/setup/locate_trunk.sh

- name: Determine check mode
shell: bash
@@ -223,6 +237,7 @@ runs:
run: |
if [ ! -e .trunk/trunk.yaml ]; then
${TRUNK_PATH:-trunk} init
echo "INITIALIZED_TRUNK=true" >>$GITHUB_ENV
fi
- name: Detect setup strategy
@@ -259,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 }}

@@ -268,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 }}
@@ -278,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'
35 changes: 35 additions & 0 deletions install/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Trunk Check
author: trunk.io
description: Install trunk and managed tools to PATH

inputs:
tools:
description: specific tools to install (if not specified will install all enabled tools)
required: false

branding:
icon: check
color: green

runs:
using: composite
steps:
- name: get trunk
shell: bash
run: ${GITHUB_ACTION_PATH}/get_trunk.sh

- name: clean up possible dead symlink
shell: bash
run: |
tools_path=".trunk/tools"
if [ -L "${tools_path}" ] && [ ! -e "${tools_path}" ] ; then
rm "${tools_path}"
fi
- name: Trunk install
shell: bash
run: trunk tools install --ci ${{ inputs.tools }}

- name: Add .trunk/tools to path
shell: bash
run: echo ".trunk/tools" >> $GITHUB_PATH
20 changes: 20 additions & 0 deletions install/get_trunk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -euo pipefail

if [[ ${INPUT_DEBUG:-false} == "true" ]]; then
set -x
fi

tmpdir="$(mktemp -d)"
echo "TRUNK_TMPDIR=${tmpdir}" >>"${GITHUB_ENV}"

curl -fsSL https://trunk.io/releases/trunk -o "${tmpdir}/trunk"
chmod u+x "${tmpdir}/trunk"
trunk_path="${tmpdir}/trunk"

echo "TRUNK_PATH=${trunk_path}" >>"${GITHUB_ENV}"
echo "${tmpdir}" >>"${GITHUB_PATH}"

# Ensure that trunk CLI is downloaded before subsequent steps (swallow output of version command)
(${trunk_path} version >/dev/null 2>&1) || echo "::warning::${trunk_path} does not exist!"
17 changes: 17 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -321,6 +321,23 @@ requests". If you have checks that run on pull requests, you will need to supply
the upgrade action to run those checks. For more information, see
[create-pull-request](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs).

## Automatic trunk setup

To install trunk on your CI machine

```yaml
jobs:
trunk_install:
name: Install trunk
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# >>> After this step, trunk is available as the env var TRUNK_PATH <<<
- name: Trunk install
uses: trunk-io/trunk-action/setup@v1
```

## Feedback

Join the [Trunk Community Slack][slack]. ❤️
34 changes: 33 additions & 1 deletion setup-env/action.yaml
Original file line number Diff line number Diff line change
@@ -71,11 +71,23 @@ runs:
echo "Could not find existing node install, skipping node package installation"
fi
- name: Determine pnpm version
if: env.PACKAGE_MANAGER == 'pnpm'
shell: bash
run: |
if [ -e package.json ] && command -v jq >/dev/null; then
PNPM_VERSION=$(jq -r '.packageManager|split("@")[1]' package.json || echo "")
fi
if [ -z "${PNPM_VERSION}" ]; then
PNPM_VERSION=latest
fi
echo "PNPM_VERSION=${PNPM_VERSION}" >>$GITHUB_ENV
- name: Install pnpm
if: env.PACKAGE_MANAGER == 'pnpm'
uses: pnpm/action-setup@v2
with:
version: latest
version: ${{ env.PNPM_VERSION }}

- name: Install Node dependencies
id: setup_node
@@ -115,6 +127,26 @@ runs:
hashFiles(env.HASH_GLOB) }}

- name: Install ${{ env.PACKAGE_MANAGER }} packages
id: install_packages
if: env.PACKAGE_MANAGER && (env.NODE_VERSION_FILE || env.RUN_INSTALL_NODE_PACKAGES)
shell: bash
run: ${{ env.INSTALL_CMD }}
continue-on-error: true

- name: Check for package install
if: env.PACKAGE_MANAGER && (env.NODE_VERSION_FILE || env.RUN_INSTALL_NODE_PACKAGES)
shell: bash
run: |
if [ ${{ steps.install_packages.outcome }} == "success" ]; then
exit 0
fi
echo "FAILED_NODE_PACKAGE_INSTALL=true" >>$GITHUB_ENV
if [[ -z "${INITIALIZED_TRUNK}" ]]; then
echo "::error::Failed to install node packages."
echo "::error::Aborting because this repo has an existing trunk.yaml file."
exit 1
fi
echo "::warning::Failed to install node packages."
echo "::warning::Disabling linters that depend on node packages."
${TRUNK_PATH} check disable eslint stylelint
Loading