From 0e3a4b19fc9f5fb507120ea3b130819e8f2cd3be Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 11:53:55 -0400 Subject: [PATCH 01/12] v2 golangci-lint --- go/lint/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/lint/action.yml b/go/lint/action.yml index 6d6ab19..d0345fd 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -1,5 +1,5 @@ name: "Go Lint" -description: "Lint Go Repo" +description: "Lint Go Repo (using golangci-lint v1)" inputs: FLIPPCIRCLECIPULLER_REPO_TOKEN: From 4b349902e6072b2047de1e0f463e7923f4393867 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 11:54:02 -0400 Subject: [PATCH 02/12] v2 golangci-lint --- go/lint-v2/action.yml | 141 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 go/lint-v2/action.yml diff --git a/go/lint-v2/action.yml b/go/lint-v2/action.yml new file mode 100644 index 0000000..da92fd4 --- /dev/null +++ b/go/lint-v2/action.yml @@ -0,0 +1,141 @@ +name: "Go Lint v2" +description: "Lint Go Repo (using golangci-lint v2)" + +inputs: + FLIPPCIRCLECIPULLER_REPO_TOKEN: + description: Flipp circleci repo token + required: true + BUF_BUILD_USER: + description: Buf CI user stored as secret + required: false + BUF_BUILD_API_TOKEN: + description: Buf API token stored as secret + required: false + SLACK_CHANNEL_ID: + description: The Slack channel ID(s) to send the data to + required: false + SLACK_BOT_TOKEN: + description: The Slack bot token to pass the data to + required: false + GOLANG_CI_LINT_VERSION: + description: The version of golangci-lint to use + required: false + default: "" + WORKSPACE: + description: workspace directory + required: false + default: "" + +runs: + using: "composite" + steps: + - name: Set branch variable + id: set-branch + shell: bash + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + branch="${{ github.event.pull_request.head.ref }}" + else + branch="${{ github.ref }}" + branch="${branch#refs/heads/}" + fi + echo "branch=${branch}" >> $GITHUB_OUTPUT + - name: Get short sha + id: get-short-sha + run: echo "short_sha=`echo ${GITHUB_SHA::7}`" > $GITHUB_OUTPUT + shell: bash + - name: Configure Go environment + uses: wishabi/github-actions/go/configure@v0 + with: + FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} + BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} + BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} + FETCH_DEPTH: 0 + - name: Setup Go dependencies + uses: wishabi/github-actions/go/deps@v0 + with: + FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} + - name: Setup safe directory + shell: bash + run: git config --global --add safe.directory ${{ inputs.WORKSPACE || github.workspace }} + - name: Grab golangci-lint version + if: ${{ hashFiles('.tool-versions') != '' }} + run: | + GOLANGCI_LINT_VERSION=$(awk '/^golangci-lint[[:space:]]+/ {print "v"$2}' .tool-versions) + echo "GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION}" >> $GITHUB_ENV + shell: bash + - name: Run Go linter + uses: golangci/golangci-lint-action@v7 + with: + skip-cache: true + args: --verbose + version: ${{ env.GOLANGCI_LINT_VERSION || inputs.GOLANG_CI_LINT_VERSION }} # Optional - if blank, will use the action's default version resolution + - name: Notify slack channel on failure + if: failure() && inputs.SLACK_CHANNEL_ID != null && github.ref == 'refs/heads/main' + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_BOT_TOKEN: ${{ inputs.SLACK_BOT_TOKEN }} + with: + channel-id: ${{ inputs.SLACK_CHANNEL_ID }} + payload: | + { + "text": "Go Lint Failed", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Go Lint Failed", + "emoji": true + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Repository*\n\n\n*${{ github.event_name == 'pull_request' && 'Pull Request' || 'Branch' }}*\n${{ github.event_name == 'pull_request' && format('<{0}|{1}>', github.event.pull_request.html_url, github.event.pull_request.title) || format('', github.repository, github.sha, steps.set-branch.outputs.branch)}}" + }, + "accessory": { + "type": "image", + "image_url": "https://emoji.slack-edge.com/T02AJQYGN/lint/84d851e0ac2b58c1.png", + "alt_text": "lint error icon" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Version/Commit*" + }, + { + "type": "mrkdwn", + "text": "*Event*" + }, + { + "type": "mrkdwn", + "text": "${{ steps.get-short-sha.outputs.short_sha }}" + }, + { + "type": "mrkdwn", + "text": "${{ github.event_name }}" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "*Triggered By:* ${{ github.triggering_actor }}" + } + ] + } + ] + } From aac18b50f127c8c9a90bf0d267c6f18074963d39 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 15:13:33 -0400 Subject: [PATCH 03/12] CR feedback: use step to determine v1 or v2 config and run approp. action version --- go/lint-v2/action.yml | 141 ------------------------------------------ go/lint/action.yml | 56 ++++++++++++++--- 2 files changed, 49 insertions(+), 148 deletions(-) delete mode 100644 go/lint-v2/action.yml diff --git a/go/lint-v2/action.yml b/go/lint-v2/action.yml deleted file mode 100644 index da92fd4..0000000 --- a/go/lint-v2/action.yml +++ /dev/null @@ -1,141 +0,0 @@ -name: "Go Lint v2" -description: "Lint Go Repo (using golangci-lint v2)" - -inputs: - FLIPPCIRCLECIPULLER_REPO_TOKEN: - description: Flipp circleci repo token - required: true - BUF_BUILD_USER: - description: Buf CI user stored as secret - required: false - BUF_BUILD_API_TOKEN: - description: Buf API token stored as secret - required: false - SLACK_CHANNEL_ID: - description: The Slack channel ID(s) to send the data to - required: false - SLACK_BOT_TOKEN: - description: The Slack bot token to pass the data to - required: false - GOLANG_CI_LINT_VERSION: - description: The version of golangci-lint to use - required: false - default: "" - WORKSPACE: - description: workspace directory - required: false - default: "" - -runs: - using: "composite" - steps: - - name: Set branch variable - id: set-branch - shell: bash - run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - branch="${{ github.event.pull_request.head.ref }}" - else - branch="${{ github.ref }}" - branch="${branch#refs/heads/}" - fi - echo "branch=${branch}" >> $GITHUB_OUTPUT - - name: Get short sha - id: get-short-sha - run: echo "short_sha=`echo ${GITHUB_SHA::7}`" > $GITHUB_OUTPUT - shell: bash - - name: Configure Go environment - uses: wishabi/github-actions/go/configure@v0 - with: - FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} - BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} - FETCH_DEPTH: 0 - - name: Setup Go dependencies - uses: wishabi/github-actions/go/deps@v0 - with: - FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - - name: Setup safe directory - shell: bash - run: git config --global --add safe.directory ${{ inputs.WORKSPACE || github.workspace }} - - name: Grab golangci-lint version - if: ${{ hashFiles('.tool-versions') != '' }} - run: | - GOLANGCI_LINT_VERSION=$(awk '/^golangci-lint[[:space:]]+/ {print "v"$2}' .tool-versions) - echo "GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION}" >> $GITHUB_ENV - shell: bash - - name: Run Go linter - uses: golangci/golangci-lint-action@v7 - with: - skip-cache: true - args: --verbose - version: ${{ env.GOLANGCI_LINT_VERSION || inputs.GOLANG_CI_LINT_VERSION }} # Optional - if blank, will use the action's default version resolution - - name: Notify slack channel on failure - if: failure() && inputs.SLACK_CHANNEL_ID != null && github.ref == 'refs/heads/main' - uses: slackapi/slack-github-action@v1.24.0 - env: - SLACK_BOT_TOKEN: ${{ inputs.SLACK_BOT_TOKEN }} - with: - channel-id: ${{ inputs.SLACK_CHANNEL_ID }} - payload: | - { - "text": "Go Lint Failed", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "Go Lint Failed", - "emoji": true - } - }, - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Repository*\n\n\n*${{ github.event_name == 'pull_request' && 'Pull Request' || 'Branch' }}*\n${{ github.event_name == 'pull_request' && format('<{0}|{1}>', github.event.pull_request.html_url, github.event.pull_request.title) || format('', github.repository, github.sha, steps.set-branch.outputs.branch)}}" - }, - "accessory": { - "type": "image", - "image_url": "https://emoji.slack-edge.com/T02AJQYGN/lint/84d851e0ac2b58c1.png", - "alt_text": "lint error icon" - } - }, - { - "type": "divider" - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Version/Commit*" - }, - { - "type": "mrkdwn", - "text": "*Event*" - }, - { - "type": "mrkdwn", - "text": "${{ steps.get-short-sha.outputs.short_sha }}" - }, - { - "type": "mrkdwn", - "text": "${{ github.event_name }}" - } - ] - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "*Triggered By:* ${{ github.triggering_actor }}" - } - ] - } - ] - } diff --git a/go/lint/action.yml b/go/lint/action.yml index d0345fd..3c594a7 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -1,5 +1,5 @@ -name: "Go Lint" -description: "Lint Go Repo (using golangci-lint v1)" +name: "Go Lint v2" +description: "Lint Go Repo (using golangci-lint v2)" inputs: FLIPPCIRCLECIPULLER_REPO_TOKEN: @@ -58,18 +58,60 @@ runs: - name: Setup safe directory shell: bash run: git config --global --add safe.directory ${{ inputs.WORKSPACE || github.workspace }} - - name: Grab golangci-lint version - if: ${{ hashFiles('.tool-versions') != '' }} + - name: Determine golangci-lint and config version run: | - GOLANGCI_LINT_VERSION=$(awk '/^golangci-lint[[:space:]]+/ {print "v"$2}' .tool-versions) + # Default to empty version and v1 config + GOLANGCI_LINT_VERSION="" + IS_V2="false" + + # Check for GOLANG_CI_LINT_VERSION input + if [ -n "${{ inputs.GOLANG_CI_LINT_VERSION }}" ]; then + GOLANGCI_LINT_VERSION="${{ inputs.GOLANG_CI_LINT_VERSION }}" + fi + + # Check .tool-versions if it exists and is not empty + if [ -z "$GOLANGCI_LINT_VERSION" ] && [ -f ".tool-versions" ] && [ -s ".tool-versions" ]; then + GOLANGCI_LINT_VERSION=$(awk '/^golangci-lint[[:space:]]+/ {print $2}' .tool-versions) # Extract version directly + fi + + # Check go.mod for golangci-lint dependency + if [ -z "$GOLANGCI_LINT_VERSION" ] && [ -f "go.mod" ]; then + GOLANGCI_LINT_VERSION=$(grep 'golangci/golangci-lint' go.mod | awk '{print $2}') + # Remove the version comment if it exists + GOLANGCI_LINT_VERSION=$(echo "$GOLANGCI_LINT_VERSION" | sed 's/\/\/.*//') + fi + + # Check .golangci.yml for explicit version declaration + if [ -f ".golangci.yml" ]; then + if grep -q 'version: "2"' .golangci.yml; then + IS_V2="true" + fi + fi + + # Determine v2 based on version if not explicitly set in .golangci.yml + if [ "$IS_V2" == "false" ] && [ -n "$GOLANGCI_LINT_VERSION" ]; then + if [[ "$GOLANGCI_LINT_VERSION" =~ ^v2\..* ]]; then + IS_V2="true" + fi + fi + + echo "IS_V2=${IS_V2}" >> $GITHUB_ENV echo "GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION}" >> $GITHUB_ENV shell: bash - - name: Run Go linter + - name: Run v1 Go linter + if : ${{ steps.golangci_version_config.outputs.IS_V2 == 'false' }} uses: golangci/golangci-lint-action@v4 with: skip-cache: true args: --verbose - version: ${{ env.GOLANGCI_LINT_VERSION || inputs.GOLANG_CI_LINT_VERSION }} # Optional - if blank, will use the action's default version resolution + version: ${{ env.GOLANGCI_LINT_VERSION }} # Optional - if blank, will use the action's default version resolution + - name: Run v2 Go linter + if : ${{ steps.golangci_version_config.outputs.IS_V2 == 'true' }} + uses: golangci/golangci-lint-action@v7 # Note: v7 and up require golangci-lint v2 config + with: + skip-cache: true + args: --verbose + version: ${{ env.GOLANGCI_LINT_VERSION }} # Optional - if blank, will use the action's default version resolution - name: Notify slack channel on failure if: failure() && inputs.SLACK_CHANNEL_ID != null && github.ref == 'refs/heads/main' uses: slackapi/slack-github-action@v1.24.0 From bd90bfcac83d91288ac97aae533b2ddf44d02a88 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 15:26:16 -0400 Subject: [PATCH 04/12] fix --- go/lint/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/lint/action.yml b/go/lint/action.yml index 3c594a7..eac45a7 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -1,5 +1,5 @@ -name: "Go Lint v2" -description: "Lint Go Repo (using golangci-lint v2)" +name: "Go Lint" +description: "Lint Go Repo" inputs: FLIPPCIRCLECIPULLER_REPO_TOKEN: From 30171961e2cf22b414ef0a4b19734793be34ad47 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 15:30:14 -0400 Subject: [PATCH 05/12] debug prints --- go/lint/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/go/lint/action.yml b/go/lint/action.yml index eac45a7..700f028 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -67,11 +67,13 @@ runs: # Check for GOLANG_CI_LINT_VERSION input if [ -n "${{ inputs.GOLANG_CI_LINT_VERSION }}" ]; then GOLANGCI_LINT_VERSION="${{ inputs.GOLANG_CI_LINT_VERSION }}" + echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from input" fi # Check .tool-versions if it exists and is not empty if [ -z "$GOLANGCI_LINT_VERSION" ] && [ -f ".tool-versions" ] && [ -s ".tool-versions" ]; then GOLANGCI_LINT_VERSION=$(awk '/^golangci-lint[[:space:]]+/ {print $2}' .tool-versions) # Extract version directly + echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from .tool-versions" fi # Check go.mod for golangci-lint dependency @@ -79,12 +81,14 @@ runs: GOLANGCI_LINT_VERSION=$(grep 'golangci/golangci-lint' go.mod | awk '{print $2}') # Remove the version comment if it exists GOLANGCI_LINT_VERSION=$(echo "$GOLANGCI_LINT_VERSION" | sed 's/\/\/.*//') + echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from go.mod" fi # Check .golangci.yml for explicit version declaration if [ -f ".golangci.yml" ]; then if grep -q 'version: "2"' .golangci.yml; then IS_V2="true" + echo "Found golangci-lint v2 config in .golangci.yml" fi fi @@ -92,6 +96,7 @@ runs: if [ "$IS_V2" == "false" ] && [ -n "$GOLANGCI_LINT_VERSION" ]; then if [[ "$GOLANGCI_LINT_VERSION" =~ ^v2\..* ]]; then IS_V2="true" + echo "Detected golangci-lint v2 version from GOLANG_CI_LINT_VERSION" fi fi From e7ece697a21cf3dda0bc10b16f767fe841f272a9 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 15:37:28 -0400 Subject: [PATCH 06/12] fix --- go/lint/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/lint/action.yml b/go/lint/action.yml index 700f028..bc65632 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -104,14 +104,14 @@ runs: echo "GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION}" >> $GITHUB_ENV shell: bash - name: Run v1 Go linter - if : ${{ steps.golangci_version_config.outputs.IS_V2 == 'false' }} + if : ${{ env.IS_V2 == 'false' }} uses: golangci/golangci-lint-action@v4 with: skip-cache: true args: --verbose version: ${{ env.GOLANGCI_LINT_VERSION }} # Optional - if blank, will use the action's default version resolution - name: Run v2 Go linter - if : ${{ steps.golangci_version_config.outputs.IS_V2 == 'true' }} + if : ${{ env.IS_V2 == 'true' }} uses: golangci/golangci-lint-action@v7 # Note: v7 and up require golangci-lint v2 config with: skip-cache: true From edc8f900340adf5fe6287eeeb4d1230630650810 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 15:54:16 -0400 Subject: [PATCH 07/12] refactor alittle --- go/lint/action.yml | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/go/lint/action.yml b/go/lint/action.yml index bc65632..b4ec980 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -62,7 +62,7 @@ runs: run: | # Default to empty version and v1 config GOLANGCI_LINT_VERSION="" - IS_V2="false" + IS_V2=false # Check for GOLANG_CI_LINT_VERSION input if [ -n "${{ inputs.GOLANG_CI_LINT_VERSION }}" ]; then @@ -70,48 +70,38 @@ runs: echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from input" fi - # Check .tool-versions if it exists and is not empty + # Check .tool-versions for golangci-lint version if [ -z "$GOLANGCI_LINT_VERSION" ] && [ -f ".tool-versions" ] && [ -s ".tool-versions" ]; then GOLANGCI_LINT_VERSION=$(awk '/^golangci-lint[[:space:]]+/ {print $2}' .tool-versions) # Extract version directly - echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from .tool-versions" + echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from .tool-versions" fi - # Check go.mod for golangci-lint dependency + # Check go.mod for golangci-lint dependency version if [ -z "$GOLANGCI_LINT_VERSION" ] && [ -f "go.mod" ]; then GOLANGCI_LINT_VERSION=$(grep 'golangci/golangci-lint' go.mod | awk '{print $2}') # Remove the version comment if it exists GOLANGCI_LINT_VERSION=$(echo "$GOLANGCI_LINT_VERSION" | sed 's/\/\/.*//') - echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from go.mod" + echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from go.mod" fi - # Check .golangci.yml for explicit version declaration - if [ -f ".golangci.yml" ]; then - if grep -q 'version: "2"' .golangci.yml; then - IS_V2="true" - echo "Found golangci-lint v2 config in .golangci.yml" - fi - fi - - # Determine v2 based on version if not explicitly set in .golangci.yml - if [ "$IS_V2" == "false" ] && [ -n "$GOLANGCI_LINT_VERSION" ]; then - if [[ "$GOLANGCI_LINT_VERSION" =~ ^v2\..* ]]; then - IS_V2="true" - echo "Detected golangci-lint v2 version from GOLANG_CI_LINT_VERSION" - fi + # Check .golangci.yml for version 2 of golangci-lint + if [ -f ".golangci.yml" ] && [ grep -q 'version: "2"' .golangci.yml ]; then + IS_V2=true + echo "Found golangci-lint v2 config in .golangci.yml" fi echo "IS_V2=${IS_V2}" >> $GITHUB_ENV echo "GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION}" >> $GITHUB_ENV shell: bash - name: Run v1 Go linter - if : ${{ env.IS_V2 == 'false' }} + if : ${{ !env.IS_V2 }} uses: golangci/golangci-lint-action@v4 with: skip-cache: true args: --verbose version: ${{ env.GOLANGCI_LINT_VERSION }} # Optional - if blank, will use the action's default version resolution - name: Run v2 Go linter - if : ${{ env.IS_V2 == 'true' }} + if : ${{ env.IS_V2 }} uses: golangci/golangci-lint-action@v7 # Note: v7 and up require golangci-lint v2 config with: skip-cache: true From b4772701b9862b5047fe451bc964e1792ddc733f Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 15:56:50 -0400 Subject: [PATCH 08/12] another fix --- go/lint/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/lint/action.yml b/go/lint/action.yml index b4ec980..5ffd85a 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -72,19 +72,19 @@ runs: # Check .tool-versions for golangci-lint version if [ -z "$GOLANGCI_LINT_VERSION" ] && [ -f ".tool-versions" ] && [ -s ".tool-versions" ]; then - GOLANGCI_LINT_VERSION=$(awk '/^golangci-lint[[:space:]]+/ {print $2}' .tool-versions) # Extract version directly + GOLANGCI_LINT_VERSION=$(awk '/^golangci-lint[[:space:]]+/ {print "v"$2}' .tool-versions) echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from .tool-versions" fi # Check go.mod for golangci-lint dependency version if [ -z "$GOLANGCI_LINT_VERSION" ] && [ -f "go.mod" ]; then - GOLANGCI_LINT_VERSION=$(grep 'golangci/golangci-lint' go.mod | awk '{print $2}') + GOLANGCI_LINT_VERSION=$(grep 'golangci/golangci-lint' go.mod | awk '{print "v"$2}') # Remove the version comment if it exists GOLANGCI_LINT_VERSION=$(echo "$GOLANGCI_LINT_VERSION" | sed 's/\/\/.*//') echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from go.mod" fi - # Check .golangci.yml for version 2 of golangci-lint + # Check .golangci.yml for version 2 config of golangci-lint if [ -f ".golangci.yml" ] && [ grep -q 'version: "2"' .golangci.yml ]; then IS_V2=true echo "Found golangci-lint v2 config in .golangci.yml" From 83464a10c3df87914c24fd156dbd311d5ccb415e Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 15:57:47 -0400 Subject: [PATCH 09/12] bump v1 config to v6 GHA --- go/lint/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/lint/action.yml b/go/lint/action.yml index 5ffd85a..353114d 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -95,7 +95,7 @@ runs: shell: bash - name: Run v1 Go linter if : ${{ !env.IS_V2 }} - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v6 with: skip-cache: true args: --verbose From 8f185c064a8df239357577cbf6c3a8b08b8a17be Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 16:45:16 -0400 Subject: [PATCH 10/12] fix --- go/lint/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/lint/action.yml b/go/lint/action.yml index 353114d..d3cacfa 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -85,7 +85,7 @@ runs: fi # Check .golangci.yml for version 2 config of golangci-lint - if [ -f ".golangci.yml" ] && [ grep -q 'version: "2"' .golangci.yml ]; then + if [ -f ".golangci.yml" ] && grep -q 'version: "2"' .golangci.yml; then IS_V2=true echo "Found golangci-lint v2 config in .golangci.yml" fi @@ -94,14 +94,14 @@ runs: echo "GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION}" >> $GITHUB_ENV shell: bash - name: Run v1 Go linter - if : ${{ !env.IS_V2 }} + if : ${{ env.IS_V2 == "false" }} uses: golangci/golangci-lint-action@v6 with: skip-cache: true args: --verbose version: ${{ env.GOLANGCI_LINT_VERSION }} # Optional - if blank, will use the action's default version resolution - name: Run v2 Go linter - if : ${{ env.IS_V2 }} + if : ${{ env.IS_V2 == "true" }} uses: golangci/golangci-lint-action@v7 # Note: v7 and up require golangci-lint v2 config with: skip-cache: true From 7195ff848e81a6ac7427de95e41a1d04d4ea4921 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 16:50:00 -0400 Subject: [PATCH 11/12] fix --- go/lint/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/lint/action.yml b/go/lint/action.yml index d3cacfa..e67702d 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -94,14 +94,14 @@ runs: echo "GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION}" >> $GITHUB_ENV shell: bash - name: Run v1 Go linter - if : ${{ env.IS_V2 == "false" }} + if : ${{ env.IS_V2 == 'false' }} uses: golangci/golangci-lint-action@v6 with: skip-cache: true args: --verbose version: ${{ env.GOLANGCI_LINT_VERSION }} # Optional - if blank, will use the action's default version resolution - name: Run v2 Go linter - if : ${{ env.IS_V2 == "true" }} + if : ${{ env.IS_V2 == 'true' }} uses: golangci/golangci-lint-action@v7 # Note: v7 and up require golangci-lint v2 config with: skip-cache: true From 9098dfe409fa583d6354cae8cb3897e263a7554c Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 17:13:48 -0400 Subject: [PATCH 12/12] remove go mod parsing --- go/lint/action.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/go/lint/action.yml b/go/lint/action.yml index e67702d..640cfd7 100644 --- a/go/lint/action.yml +++ b/go/lint/action.yml @@ -76,14 +76,6 @@ runs: echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from .tool-versions" fi - # Check go.mod for golangci-lint dependency version - if [ -z "$GOLANGCI_LINT_VERSION" ] && [ -f "go.mod" ]; then - GOLANGCI_LINT_VERSION=$(grep 'golangci/golangci-lint' go.mod | awk '{print "v"$2}') - # Remove the version comment if it exists - GOLANGCI_LINT_VERSION=$(echo "$GOLANGCI_LINT_VERSION" | sed 's/\/\/.*//') - echo "Using GOLANG_CI_LINT_VERSION=${GOLANGCI_LINT_VERSION} from go.mod" - fi - # Check .golangci.yml for version 2 config of golangci-lint if [ -f ".golangci.yml" ] && grep -q 'version: "2"' .golangci.yml; then IS_V2=true