Commit 634d3e10 authored by Thomas Boni's avatar Thomas Boni
Browse files

Merge branch '479-golint' into 'latest'

Resolve "[New job] - go_lint"

Closes #479

See merge request r2devops/hub!317
parents 21383ebe d0dfac6f
Loading
Loading
Loading
Loading

jobs/golint/README.md

0 → 100644
+30 −0
Original line number Diff line number Diff line
## Objective

A ready-to-use job to lint your Golang project. It includes a lot of linters such as gosimple, errcheck, ... For more informations, check the [documentation](https://golangci-lint.run/usage/linters/)

## How to use it

1. Add this job URL inside the `include` list of your `.gitlab-ci.yml` file (see the [quick setup](/use-the-hub/#quick-setup)). You can specify [a fixed version](#changelog) instead of `latest`.
    ```yaml
      - remote: 'https://jobs.r2devops.io/latest/golint.yml'
    ```
1. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/use-the-hub/#jobs-customization)
1. Well done, your job is ready to work ! 😀

## Job details

* Job name: `golint`
* Docker image:
[`golangci/golangci-lint:v1.43.0`](https://hub.docker.com/r/golangci/golangci-lint)
* Default stage: `static_tests`
* When: `always`

### Variables

| Name | Description | Default |
| ---- | ----------- | ------- |
| `CONFIG_LOCATION` <img width=100/> | Specify whether a config file needs to be used <img width=175/>| ` ` <img width=100/>|
| `PROJECT_ROOT` | Path to the root of project to lint | `.` |
| `ADDITIONAL_OPTIONS` | [Additional options](https://golangci-lint.run/usage/configuration/) available for the user, they are added at the end of test command | ` ` |
| `GOLINT_OUTPUT` | Name of the output file | `report-golint.xml` |

jobs/golint/golint.yml

0 → 100644
+25 −0
Original line number Diff line number Diff line
# Job from R2Devops hub --> r2devops.io

stages:
  - static_tests

golint:
  image: golangci/golangci-lint:v1.43.0
  stage: static_tests
  variables:
    PROJECT_ROOT: "."
    CONFIG_LOCATION: ""
    ADDITIONAL_OPTIONS: ""
    GOLINT_OUTPUT: "report-golint.xml"

  script:
    - cd $PROJECT_ROOT
    - $([ ${CONFIG_LOCATION} != "" ]) && CONFIG_LOCATION="--config $CONFIG_LOCATION"
    - golangci-lint run $(find -type f -name "*.go" ) $ADDITIONAL_OPTIONS $CONFIG_LOCATION --out-format "junit-xml" > $GOLINT_OUTPUT

  artifacts:
    when: always
    paths:
    - ${PROJECT_ROOT}/$GOLINT_OUTPUT
    reports:
      junit: ${PROJECT_ROOT}/$GOLINT_OUTPUT

jobs/golint/job.yml

0 → 100644
+12 −0
Original line number Diff line number Diff line
name: golint
description: A ready-to-use job to lint a project written in Golang
default_stage: static_tests
icon: 🔎
maintainer: alexiaognard
license: Apache-2.0
images:
  golangci/golangci-lint:v1.43.0
tools:
labels:
    - Go
    - Linter
 No newline at end of file
+0 −0

Empty file added.

+1 −0
Original line number Diff line number Diff line
* Initial version
 No newline at end of file