feat(linter): Use golangci-lint for linting and error checking #73
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: main | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "*" | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.ref }}-${{ github.workflow }} | |
| cancel-in-progress: true | |
| jobs: | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| set-safe-directory: true | |
| - uses: actions/setup-python@v3 | |
| - uses: actions/setup-go@v5 | |
| - name: Install Deps | |
| run: | | |
| go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0 | |
| pip install pre-commit | |
| pre-commit run --all-files | |
| test: | |
| name: test | |
| runs-on: ubuntu-latest | |
| container: golang:1.24.5-alpine3.22 | |
| steps: | |
| - name: Install git | |
| run: apk add --update --no-cache git | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| set-safe-directory: true | |
| - name: Test | |
| run: | | |
| go test ./... | |
| build: | |
| name: build | |
| runs-on: ubuntu-latest | |
| container: golang:1.24.5-alpine3.22 | |
| strategy: | |
| matrix: | |
| include: | |
| - os: darwin | |
| arch: arm64 | |
| suffix: '' | |
| - os: linux | |
| arch: amd64 | |
| suffix: '' | |
| - os: windows | |
| arch: amd64 | |
| suffix: .exe | |
| steps: | |
| - name: Install git | |
| run: apk add --update --no-cache git | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| set-safe-directory: true | |
| - name: Build | |
| run: | | |
| GOFLAGS=-buildvcs=false GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o . ./... | |
| shell: sh | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Archive release artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: infinity-dialog-${{ matrix.os }}-${{ matrix.arch }} | |
| path: ./infinity_dialog${{ matrix.suffix }} | |
| create-release: | |
| name: Create Release | |
| needs: | |
| [pre-commit, test, build] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| outputs: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| tag_name: ${{ steps.get_tag.outputs.git_tag }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| set-safe-directory: true | |
| - name: Create Release | |
| id: create_release | |
| uses: ncipollo/release-action@v1.18.0 | |
| with: | |
| generateReleaseNotes: true | |
| release-artifacts: | |
| name: Release Artifacts | |
| needs: | |
| [create-release] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - os: darwin | |
| arch: arm64 | |
| suffix: '' | |
| - os: linux | |
| arch: amd64 | |
| suffix: '' | |
| - os: windows | |
| arch: amd64 | |
| suffix: .exe | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: infinity-dialog-${{ matrix.os }}-${{ matrix.arch }} | |
| - name: Upload Release Asset - ${{ matrix.os }}-${{ matrix.arch }} | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ needs.create-release.outputs.upload_url }} | |
| asset_path: ./infinity_dialog${{ matrix.suffix }} | |
| asset_name: infinity-dialog-${{ matrix.os }}${{ matrix.suffix }} | |
| asset_content_type: application/octet-stream |