Skip to content

Commit

Permalink
Feat(update): Testing and adding scenarios for golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaviral2609 committed Jul 28, 2023
1 parent b83c562 commit 4de0b52
Showing 1 changed file with 44 additions and 42 deletions.
86 changes: 44 additions & 42 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}

0 comments on commit 4de0b52

Please sign in to comment.