-
Notifications
You must be signed in to change notification settings - Fork 2
85 lines (79 loc) · 3.47 KB
/
go-lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright 2023 The Authors (see AUTHORS file)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: 'go-lint'
on:
workflow_call:
inputs:
runs-on:
description: 'The GitHub runner on which to execute. This must be a valid JSON but can represent a string, array of strings, or object.'
type: 'string'
default: '"ubuntu-latest"'
go_version:
description: 'The version of Go to install and use.'
type: 'string'
go_version_file:
description: 'Path to the go.mod file to extract a version.'
type: 'string'
default: 'go.mod'
golangci_url:
description: 'The URL to a golangci file. This is only used if no file is found in the local directory.'
type: 'string'
default: 'https://raw.githubusercontent.com/abcxyz/pkg/main/.golangci.yml'
directory:
description: 'Directory in which Go files reside.'
type: 'string'
default: '.'
golangci_lint_version:
description: 'Version of golangci linter to use'
type: 'string'
default: 'v1.64'
jobs:
# modules checks if the go modules are all up-to-date. While rare with modern
# versions of Go, it's possible to take a dependency on a package without
# updating the module file.
#
# Do not change this job name. Job names are used as identifiers in status
# checks, and changing this name will cause status checks to fail.
modules:
runs-on: ${{ fromJSON(inputs.runs-on) }} # yamllint disable-line
steps:
- name: 'Checkout'
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
- name: 'Lint Go Modules'
uses: 'abcxyz/actions/.github/actions/lint-go-modules@main' # ratchet:exclude
with:
go_version: '${{ inputs.go_version }}'
go_version_file: '${{ inputs.go_version_file }}'
golangci_url: '${{ inputs.golangci_url }}'
directory: '${{ inputs.directory }}'
golangci_lint_version: '${{ inputs.golangci_lint_version }}'
# golangci runs golangci-lint. If a .golangci.yml or .golangci.yaml file
# exists at the root of the repository, it uses those custom settings. If no
# such file exists, it uses a selection of sane defaults.
#
# Do not change this job name. Job names are used as identifiers in status
# checks, and changing this name will cause status checks to fail.
golangci:
runs-on: ${{ fromJSON(inputs.runs-on) }} # yamllint disable-line
steps:
- name: 'Checkout'
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
- name: 'Lint Go'
uses: 'abcxyz/actions/.github/actions/lint-go@main' # ratchet:exclude
with:
go_version: '${{ inputs.go_version }}'
go_version_file: '${{ inputs.go_version_file }}'
golangci_url: '${{ inputs.golangci_url }}'
directory: '${{ inputs.directory }}'
golangci_lint_version: '${{ inputs.golangci_lint_version }}'