All Projects → golangci → Golangci Lint Action

golangci / Golangci Lint Action

Licence: mit
Official GitHub action for golangci-lint from it's authors

Programming Languages

go
31211 projects - #10 most used programming language
typescript
32286 projects
golang
3204 projects

Projects that are alternatives of or similar to Golangci Lint Action

RxReduxK
Micro-framework for Redux implemented in Kotlin
Stars: ✭ 65 (-75.93%)
Mutual labels:  action
action-autotag
Automatically generate a new tag when the manifest file (package.json, Dockerfile, custom file, etc) version changes.
Stars: ✭ 45 (-83.33%)
Mutual labels:  action
openwrt-k2t-build
github actions build openwrt firmware
Stars: ✭ 14 (-94.81%)
Mutual labels:  action
setup-clang
GitHub action to set up Clang & LLVM
Stars: ✭ 28 (-89.63%)
Mutual labels:  action
lychee-action
Github action to check for broken links in Markdown, HTML, and text files using lychee, a fast link checker written in Rust.
Stars: ✭ 89 (-67.04%)
Mutual labels:  action
cuda-toolkit
GitHub Action to install CUDA
Stars: ✭ 34 (-87.41%)
Mutual labels:  action
deployment-status
GitHub action for updating deployments with status events.
Stars: ✭ 24 (-91.11%)
Mutual labels:  action
hookr
PHP action and filter hook system
Stars: ✭ 39 (-85.56%)
Mutual labels:  action
git-actions
A GitHub Action to run arbitrary git commands
Stars: ✭ 72 (-73.33%)
Mutual labels:  action
k-redux-factory
Factory of Redux reducers and their associated actions and selectors.
Stars: ✭ 18 (-93.33%)
Mutual labels:  action
trueChart-Menubar4Sense
MENUBAR as visualization extension for Qlik Sense® allows for vertical and horizontal buttons and selections (fields, master dimensions and variables) as well as unlimited trigger based Actions. #trueChart #menubar #highcoordination
Stars: ✭ 19 (-92.96%)
Mutual labels:  action
helm
GitHub action for deploying Helm charts.
Stars: ✭ 107 (-60.37%)
Mutual labels:  action
gha-setup-scancentral-client
GitHub Action to set up Fortify ScanCentral Client
Stars: ✭ 15 (-94.44%)
Mutual labels:  action
Github-Release-Action
Publish Github releases in an action
Stars: ✭ 100 (-62.96%)
Mutual labels:  action
github-run-tests-action
mabl Github Actions implementation
Stars: ✭ 39 (-85.56%)
Mutual labels:  action
broken seals
An open source third person action RPG with multiplayer support.
Stars: ✭ 223 (-17.41%)
Mutual labels:  action
server-action-service
Generic and reusable Lightning service component that calls server-side actions
Stars: ✭ 19 (-92.96%)
Mutual labels:  action
action
A GitHub Action that deploys live environments for your pull requests and branches
Stars: ✭ 63 (-76.67%)
Mutual labels:  action
upx-action
Strips and runs upx on binaries
Stars: ✭ 17 (-93.7%)
Mutual labels:  action
action-sync-node-meta
GitHub Action that syncs package.json with the repository metadata.
Stars: ✭ 25 (-90.74%)
Mutual labels:  action

golangci-lint-action

Build Status

It's the official GitHub action for golangci-lint from its authors. The action runs golangci-lint and reports issues from linters.

GitHub Annotations

Compatibility

  • v2.0.0+ works with golangci-lint version >= v1.28.3
  • v1.2.2 is deprecated due to we forgot to change the minimum version of golangci-lint to v1.28.3 (issue)
  • v1.2.1 works with golangci-lint version >= v1.14.0 (issue)

How to use

Add .github/workflows/golangci-lint.yml with the following contents:

name: golangci-lint
on:
  push:
    tags:
      - v*
    branches:
      - master
      - main
  pull_request:
jobs:
  golangci:
    name: lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: golangci-lint
        uses: golangci/[email protected]
        with:
          # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
          version: v1.29

          # Optional: working directory, useful for monorepos
          # working-directory: somedir

          # Optional: golangci-lint command line arguments.
          # args: --issues-exit-code=0

          # Optional: show only new issues if it's a pull request. The default value is `false`.
          # only-new-issues: true

          # Optional: if set to true then the action will use pre-installed Go.
          # skip-go-installation: true

          # Optional: if set to true then the action don't cache or restore ~/go/pkg.
          # skip-pkg-cache: true

          # Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
          # skip-build-cache: true

We recommend running this action in a job separate from other jobs (go test, etc) because different jobs run in parallel.

Multiple OS Support

If you need to run linters for specific operating systems, you will need to use v2 of the action. Here is a sample configuration file:

name: golangci-lint
on:
  push:
    tags:
      - v*
    branches:
      - master
      - main
  pull_request:
jobs:
  golangci:
    strategy:
      matrix:
        go-version: [1.15.x]
        os: [macos-latest, windows-latest]
    name: lint
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/[email protected]
      - name: golangci-lint
        uses: golangci/[email protected]
        with:
          # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
          version: v1.29
          # Optional: working directory, useful for monorepos
          # working-directory: somedir

          # Optional: golangci-lint command line arguments.
          # args: --issues-exit-code=0

          # Optional: show only new issues if it's a pull request. The default value is `false`.
          # only-new-issues: true

You will also likely need to add the following .gitattributes file to ensure that line endings for windows builds are properly formatted:

*.go text eol=lf

Comments and Annotations

Currently, GitHub parses the action's output and creates annotations.

The restrictions of annotations are the following:

  1. Currently, they don't support markdown formatting (see the feature request)
  2. They aren't shown in list of comments like it was with golangci.com. If you would like to have comments - please, up-vote the issue.

Performance

The action was implemented with performance in mind:

  1. We cache data by @actions/cache between builds: Go build cache, Go modules cache, golangci-lint analysis cache.
  2. We don't use Docker because image pulling is slow.
  3. We do as much as we can in parallel, e.g. we download cache, go and golangci-lint binary in parallel.

For example, in a repository of golangci-lint running this action without the cache takes 50s, but with cache takes 14s:

  • in parallel:
    • 13s to download Go
    • 4s to restore 50 MB of cache
    • 1s to find and install golangci-lint
  • 1s to run golangci-lint (it takes 35s without cache)

Internals

We use JavaScript-based action. We don't use Docker-based action because:

  1. docker pulling is slow currently
  2. it's easier to use caching from @actions/cache

We support different platforms, such as ubuntu, macos and windows with x32 and x64 archs.

Inside our action we perform 3 steps:

  1. Setup environment running in parallel:
  1. Run golangci-lint with specified by user args
  2. Save cache for later builds

Caching internals

  1. We save and restore the following directories: ~/.cache/golangci-lint, ~/.cache/go-build, ~/go/pkg.
  2. The primary caching key looks like golangci-lint.cache-{platform-arch}-{interval_number}-{go.mod_hash}. Interval number ensures that we periodically invalidate our cache (every 7 days). go.mod hash ensures that we invalidate the cache early - as soon as dependencies have changed.
  3. We use restore keys: golangci-lint.cache-{interval_number}-, golangci-lint.cache-. GitHub matches keys by prefix if we have no exact match for the primary cache.

This scheme is basic and needs improvements. Pull requests and ideas are welcome.

Development of this action

  1. Install act
  2. Make a symlink for act to work properly: ln -s . golangci-lint-action
  3. Prepare deps once: npm run prepare-deps
  4. Run npm run local after any change to test it
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].