Skip to content

Commit

Permalink
Fixes bundle for action.yml (#249)
Browse files Browse the repository at this point in the history
Most important of the fixes is the first one, which sets
`TRUNK_LAUNCHER_QUIET=false`.

The launcher currently completely suppresses all output (including all
errors),
unless `TRUNK_LAUNCHER_QUIET` env var is set to `false`.

```bash
if [[ ${TRUNK_LAUNCHER_QUIET} != false ]]; then
  exec 3>&1 4>&2 &>/dev/null
fi
```

This prevents each and every one from debugging failed runs.
Redirecting file descriptors like that also disables all `set -vx`
output,
resulting in a complete blackout and painful debugging.

This PR will always enable launcher output, which is what I prefer,
however if you don't like that, it may be changed, so that it's set only
if `RUNNER_DEBUG == 1`.

Also, you can migrate to `actions/download-artifact@v4` and rewrite this
step:

https://github.com/trunk-io/trunk-action/blob/03cb46f406176a84f390fb565960606c2bd0b8b3/action.yaml#L355-L378

---------

Co-authored-by: Eli Schleifer <[email protected]>
  • Loading branch information
rindeal and EliSchleifer authored Oct 10, 2024
1 parent b0ffb2e commit 2eaee16
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ runs:
run: |
cat >>$GITHUB_ENV <<EOF
GITHUB_TOKEN=${{ github.token }}
TRUNK_LAUNCHER_QUIET=false
EOF
# First arg is field to fetch, second arg is default value or empty
Expand All @@ -146,7 +147,7 @@ runs:
# Every inputs.field should be referenced as INPUT_FIELD later in the action. This allows
# the field to be set either as an argument to the github action or via inputs.json.
if [[ "${{ inputs.check-mode }}" = "payload" ]]; then
if [[ "${{ inputs.check-mode }}" == "payload" ]]; then
INPUT_GITHUB_TOKEN=$(payload githubToken)
INPUT_TRUNK_TOKEN=$(payload trunkToken)
Expand Down Expand Up @@ -248,15 +249,15 @@ runs:
- name: Init on-demand
shell: bash
run: |
if [ ! -e .trunk/trunk.yaml ]; then
${TRUNK_PATH:-trunk} init
if [[ ! -e .trunk/trunk.yaml ]]; then
${TRUNK_PATH:-trunk} --ci init
echo "INITIALIZED_TRUNK=true" >>$GITHUB_ENV
fi
- name: Detect setup strategy
shell: bash
run: |
if [ -e .trunk/setup-ci ]; then
if [[ -e .trunk/setup-ci ]]; then
echo "INPUT_SETUP_DEPS=true" >>$GITHUB_ENV
else
mkdir -p .trunk
Expand Down Expand Up @@ -336,15 +337,15 @@ runs:
shell: bash
run: |
echo "::group::.trunk/logs/cli.log"
if [ -f .trunk/logs/cli.log ]; then
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
if [[ -f .trunk/logs/daemon.log ]]; then
cat .trunk/logs/daemon.log
else
echo ".trunk/logs/daemon.log doesn't exist"
Expand All @@ -367,7 +368,7 @@ runs:

- name: Download annotations artifact
if: inputs.post-annotations == 'true'
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
# TODO(chris): We can't use the official download artifact action yet: https://github.com/actions/download-artifact/issues/172
script: |
Expand Down

0 comments on commit 2eaee16

Please sign in to comment.