From cd72f932624e59652b591953a965ecbce66d2e5d Mon Sep 17 00:00:00 2001 From: momentmaker Date: Wed, 11 Sep 2024 07:34:02 -0500 Subject: [PATCH] fix: golangci-lint-action working directory bug (#14387) --- .github/actions/golangci-lint/action.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/actions/golangci-lint/action.yml b/.github/actions/golangci-lint/action.yml index 86e15f80b2f..a90a764ef2f 100644 --- a/.github/actions/golangci-lint/action.yml +++ b/.github/actions/golangci-lint/action.yml @@ -10,8 +10,7 @@ inputs: required: true go-directory: description: Go directory to run commands from - # XXX: Don't use `.` here due to issues with the golangci-lint-action. - default: "" + default: "." # setup-go inputs only-modules: description: Set to 'true' to only cache modules @@ -54,13 +53,23 @@ runs: working-directory: ${{ inputs.go-directory }} shell: bash run: go build ./... + - name: Set golangci-lint working directory + shell: bash + id: set-working-directory + # XXX: Don't use `.` default working directory here due to issues with the golangci-lint-action. + run: | + if [ "${{ inputs.go-directory }}" == "." ]; then + echo "golangci-lint-working-directory=" | tee -a $GITHUB_OUTPUT + else + echo "golangci-lint-working-directory=${{ inputs.go-directory }}" | tee -a $GITHUB_OUTPUT + fi - name: golangci-lint uses: golangci/golangci-lint-action@38e1018663fa5173f3968ea0777460d3de38f256 # v5.3.0 with: version: v1.60.3 only-new-issues: true args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml - working-directory: ${{ inputs.go-directory }} + working-directory: ${{ steps.set-working-directory.outputs.golangci-lint-working-directory }} - name: Print lint report artifact if: failure() shell: bash