taplo icon indicating copy to clipboard operation
taplo copied to clipboard

Github Action / running taplo in CI

Open jbergstroem opened this issue 2 years ago • 7 comments

It's easy enough to get taplo running in CI. Something like this should work (and version can be maintained with a regex in renovatebot):

  taplo:
    name: Taplo
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install Taplo
        env:
          version: "0.8.1"
        run: |
          curl -Ls "https://github.com/tamasfe/taplo/releases/download/${{ env.version }}/taplo-full-linux-x86_64.gz" | \
          gzip -d > taplo && \
          chmod +x taplo && \
          sudo mv taplo /usr/local/bin/taplo
      - name: Run Taplo
        run: taplo validate --colors never --no-schema

..that said. The very helpful CLI output is very complicated to parse with a problem matcher.

One way to improve this could be to support a custom output template, similar to actionlint. Another approach could be to have a custom format specifically catering problem matchers (which also could serve as a way get improved editor support).

Edit: For people just arriving, the better approach to this problem is to check if GITHUB_ACTIONS is set to true in the environment and emit github actions-consumable output.

jbergstroem avatar Sep 12 '23 21:09 jbergstroem

Thanks for the suggestion!

I'm personally not convinced by sophisticated output (others may disagree). I just use Taplo in CI like this, i.e. by formatting then diffing using git (which has a nice unsophisticated output). (This is also related to #416 when CI as a use-case for Taplo was mentioned.)

That said, I'm not against this feature if someone is ready to design and implement it and someone else is ready to review it.

ia0 avatar Sep 13 '23 16:09 ia0

I think we could output https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message when GITHUB_CI is set (or whichever envvar GitHub used).

panekj avatar Sep 13 '23 17:09 panekj

Was just coming back to suggest that! Probably the best approach.

when GITHUB_CI is set (or whichever envvar GitHub used).

Thinking either GITHUB_ACTIONS on its own or together with CI? https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables

jbergstroem avatar Sep 13 '23 17:09 jbergstroem

Thinking either GITHUB_ACTIONS on its own

This should be sufficient.

panekj avatar Sep 13 '23 17:09 panekj

I'm not entirely sure what the goal of this issue was but I think it would be great if we could turn @jbergstroem's original YAML code into a proper action and publish it.

uncenter avatar Feb 13 '24 02:02 uncenter

I've adapted it into an action! https://github.com/uncenter/setup-taplo Tested and works on ubuntu-latest, macos-latest, and windows-latest runners.

uncenter avatar Feb 13 '24 04:02 uncenter

I'm not entirely sure what the goal of this issue was

The goal is outlined in original post, support for GitHub specific features such as code annotations from CI run.

Taplo as GitHub action is tracked in #326

panekj avatar Aug 16 '24 08:08 panekj