-
Notifications
You must be signed in to change notification settings - Fork 19
Added go linting #493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Added go linting #493
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
47cc0b7
Bump actions/checkout from 4 to 5
dependabot[bot] 1704638
Merge branch 'main' into dependabot/github_actions/actions/checkout-5
goruha e0be611
Add CodeQL workflow for code analysis
goruha 3fed699
Delete PR Semver and Size Labeler workflows
goruha adabc1b
Add autofix CI workflow configuration
goruha b186bea
Add pre-commit workflow for pull requests
goruha d68c544
Create .pre-commit-config.yaml
goruha c5c1262
Add GolangCI-Lint configuration file
goruha 00a1262
Add Codecov configuration for coverage tracking
goruha 9791eb0
Fix linting
goruha 296e76a
Added aqua
goruha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
# The workflow name **must** be "autofix.ci" for Autofix CI to function correctly. | ||
# Any deviation from this name will cause Autofix CI to fail, as it relies on this | ||
# specific identifier for execution. This is a strict requirement of Autofix CI. | ||
name: autofix.ci | ||
on: pull_request | ||
permissions: {} | ||
jobs: | ||
autofix: | ||
runs-on: ubuntu-24.04 | ||
permissions: {} | ||
timeout-minutes: 15 | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
persist-credentials: false | ||
- uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 | ||
with: | ||
aqua_version: v2.43.0 | ||
|
||
- name: Update aqua-checksums.json | ||
run: aqua upc -prune | ||
|
||
# go mod tidy | ||
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | ||
with: | ||
go-version-file: go.mod | ||
- run: go mod tidy | ||
|
||
# gofumpt | ||
- name: Get changed Go files | ||
id: changed-files | ||
uses: tj-actions/changed-files@e7b157b1c4ad44acfc8d9be14b8cd8f5058636e3 # v45.0.6 | ||
with: | ||
use_rest_api: "true" | ||
files: | | ||
**/*.go | ||
- if: steps.changed-files.outputs.all_changed_files_count != '0' | ||
env: | ||
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | ||
run: | | ||
# shellcheck disable=SC2086 | ||
gofumpt -l -w $ALL_CHANGED_FILES | ||
|
||
# Run pre-commit hooks for whitespace fixes | ||
- name: Install pre-commit | ||
run: | | ||
pip install pre-commit | ||
|
||
- name: Run pre-commit whitespace fixes | ||
run: | | ||
# Run only the whitespace-related hooks from pre-commit | ||
pre-commit run trailing-whitespace --all-files || true | ||
pre-commit run end-of-file-fixer --all-files || true | ||
|
||
- uses: autofix-ci/action@2891949f3779a1cafafae1523058501de3d4e944 # v1.3.1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: ["main"] | ||
types: [opened, labeled, unlabeled, synchronize] | ||
schedule: | ||
# runs on 19:17 every Tuesday | ||
- cron: "27 19 * * 2" | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 360 | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: ["go", "javascript-typescript"] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
|
||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs | ||
# queries: security-extended,security-and-quality | ||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v3 | ||
|
||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun | ||
|
||
# If the Autobuild fails above, remove it and uncomment the following three lines. | ||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. | ||
|
||
# - run: | | ||
# echo "Run, Build Application using script" | ||
# ./location_of_script_within_repo/buildscript.sh | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 | ||
with: | ||
category: "/language:${{matrix.language}}" | ||
|
||
lint-golangci: | ||
name: "Lint (golangci)" | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' | ||
permissions: | ||
# Required: allow read access to the content for analysis. | ||
contents: read | ||
# allow read access to pull request. Use with `only-new-issues` option. | ||
pull-requests: read | ||
# allow write access to checks to allow the action to annotate code in the PR. | ||
checks: write | ||
# allow write access to security events to allow the action to upload SARIF files. | ||
security-events: write | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v8 | ||
id: golangci | ||
with: | ||
version: v2.4.0 | ||
only-new-issues: true # Shows only issues introduced in the PR | ||
# Not all line numbers in diff may match the linter's line outputs | ||
# See: https://github.com/golangci/golangci-lint/issues/4376#issuecomment-1938874827 | ||
# Always exit 0 so we upload the sarif file to CodeQL | ||
args: > | ||
--output.sarif.path=golangci-lint.sarif | ||
--issues-exit-code=0 | ||
|
||
- name: Upload filtered SARIF results | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: golangci-lint.sarif | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Pre-commit | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
env: | ||
# Ensure pre-commit uses the right Python version | ||
PYTHON_VERSION: "3.11" | ||
# Skip hooks that are already running in other CI jobs to avoid redundant work | ||
# go-build-mod: Already runs in test.yml build job | ||
# golangci-lint: Already runs in codeql.yml lint-golangci job | ||
SKIP: go-build-mod,golangci-lint | ||
|
||
jobs: | ||
pre-commit: | ||
name: Run pre-commit hooks | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
# Fetch full history for proper diff checking | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache: true | ||
|
||
- name: Install Go tools | ||
run: | | ||
# Install gofumpt for pre-commit | ||
go install mvdan.cc/gofumpt@latest | ||
|
||
# Install golangci-lint v2 | ||
go install github.com/golangci/golangci-lint/v2/cmd/[email protected] | ||
|
||
# Add Go bin to PATH | ||
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Run CloudPosse pre-commit action | ||
uses: cloudposse/[email protected] | ||
with: | ||
# Run against files changed in the PR only | ||
# This prevents formatting/checking unrelated files | ||
extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref HEAD |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout source code at current commit" | ||
uses: actions/checkout@v4 | ||
uses: actions/checkout@v5 | ||
# Leave pinned at 0.7.1 until https://github.com/mszostok/codeowners-validator/issues/173 is resolved | ||
- uses: mszostok/[email protected] | ||
if: github.event.pull_request.head.repo.full_name == github.repository | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.