From 4de0b52d2410ed5e7862a11aaaa0d404d6c9b1c8 Mon Sep 17 00:00:00 2001 From: Aviral Singh Date: Fri, 28 Jul 2023 15:47:24 +0530 Subject: [PATCH] Feat(update): Testing and adding scenarios for golangci-lint --- .github/workflows/lint.yml | 86 +++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c4c3152c141..0f5b5130e75 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -45,48 +45,50 @@ jobs: continue-on-error: true go-lint: - name: Lint Go - runs-on: ubuntu-22.04 - steps: - - name: Adding markdown - run: echo '### Lint Go ✨' >> $GITHUB_STEP_SUMMARY - - name: Checkout - uses: actions/checkout@v3.3.0 - - name: Setup Golang with Cache - uses: magnetikonline/action-golang-cache@v4 - with: - go-version: "1.20" - - name: Lint using golangci-lint - id: go-lint - uses: golangci/golangci-lint-action@v3 - with: - skip-pkg-cache: true - skip-build-cache: true - version: v1.52.2 - only-new-issues: true - args: --timeout=10m --issues-exit-code=1 --sort-results ./... + name: Lint Go + runs-on: ubuntu-22.04 + env: + LINT_RESULTS: "" + steps: + - name: Adding markdown + run: echo '### Lint Go ✨' >> $GITHUB_STEP_SUMMARY + - name: Checkout + uses: actions/checkout@v3.3.0 + - name: Setup Golang with Cache + uses: magnetikonline/action-golang-cache@v4 + with: + go-version: "1.20" + - name: Lint using golangci-lint + id: go-lint + uses: golangci/golangci-lint-action@v3 + with: + skip-pkg-cache: true + skip-build-cache: true + version: v1.52.2 + only-new-issues: true + args: --timeout=10m --issues-exit-code=1 --sort-results ./... - - name: Save Go linting results - if: ${{ always() }} - run: | - echo "${{ steps.go-lint.outputs.stdout }}" | grep "::error" | awk -F "::error file=" '{print $2}' | sed 's/ column=/:/; s/::error /: /' > lint_results.txt - export LINT_RESULTS=$(cat lint_results.txt) - continue-on-error: true + - name: Save Go linting results + if: ${{ always() }} + run: | + echo "${{ steps.go-lint.outputs.stdout }}" | grep "::error" | awk -F "::error file=" '{print $2}' | sed 's/ column=/:/; s/::error /: /' > lint_results.txt + export LINT_RESULTS=$(cat lint_results.txt) + continue-on-error: true - - name: Generate list using Markdown - id: go-lint-summary - run: | - echo "- ✔️ Checked out the repository" >> $GITHUB_STEP_SUMMARY - echo "- ✔️ Set up Go with version 1.20 and cached dependencies" >> $GITHUB_STEP_SUMMARY - - if [ -n "$LINT_RESULTS" ]; then - echo "- ❌ Go lint check failed" >> $GITHUB_STEP_SUMMARY - echo "::error::Linting issues found. Check the details below." >> $GITHUB_STEP_SUMMARY - echo "$LINT_RESULTS" >> $GITHUB_STEP_SUMMARY - exit 1 - else - echo "- ✔️ Go lint check passed" >> $GITHUB_STEP_SUMMARY - fi - continue-on-error: true - if: always() + - name: Generate list using Markdown + id: go-lint-summary + run: | + echo "- ✔️ Checked out the repository" >> $GITHUB_STEP_SUMMARY + echo "- ✔️ Set up Go with version 1.20 and cached dependencies" >> $GITHUB_STEP_SUMMARY + if [ -n "$LINT_RESULTS" ]; then + echo "- ❌ Go lint check failed" >> $GITHUB_STEP_SUMMARY + echo "::error::Linting issues found. Check the details below." >> $GITHUB_STEP_SUMMARY + echo "$LINT_RESULTS" >> $GITHUB_STEP_SUMMARY + exit 1 + else + echo "- ✔️ Go lint check passed" >> $GITHUB_STEP_SUMMARY + echo "::warning::No linting issues found." >> $GITHUB_STEP_SUMMARY + fi + continue-on-error: true + if: ${{ always() }}