mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -08:00
Update golangci-lint
* Update golangci-lint to v1.53.3. * Update the sync script handler for the old golanci-lint action. Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
parent
a605b81b14
commit
c18f5b6487
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -150,7 +150,7 @@ jobs:
|
|||
uses: golangci/golangci-lint-action@v3.4.0
|
||||
with:
|
||||
args: --verbose
|
||||
version: v1.51.2
|
||||
version: v1.53.3
|
||||
fuzzing:
|
||||
uses: ./.github/workflows/fuzzing.yml
|
||||
if: github.event_name == 'pull_request'
|
||||
|
|
|
@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
|
|||
SKIP_GOLANGCI_LINT :=
|
||||
GOLANGCI_LINT :=
|
||||
GOLANGCI_LINT_OPTS ?=
|
||||
GOLANGCI_LINT_VERSION ?= v1.51.2
|
||||
GOLANGCI_LINT_VERSION ?= v1.53.3
|
||||
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
|
||||
# windows isn't included here because of the path separator being different.
|
||||
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
|
||||
|
|
32
scripts/golangci-lint.yml
Normal file
32
scripts/golangci-lint.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
# This action is synced from https://github.com/prometheus/prometheus
|
||||
name: golangci-lint
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "go.sum"
|
||||
- "go.mod"
|
||||
- "**.go"
|
||||
- "scripts/errcheck_excludes.txt"
|
||||
- ".github/workflows/golangci-lint.yml"
|
||||
- ".golangci.yml"
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.20.x
|
||||
- name: Install snmp_exporter/generator dependencies
|
||||
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
|
||||
if: github.repository == 'prometheus/snmp_exporter'
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@v3.4.0
|
||||
with:
|
||||
version: v1.53.3
|
|
@ -37,7 +37,7 @@ if [ -z "${GITHUB_TOKEN}" ]; then
|
|||
fi
|
||||
|
||||
# List of files that should be synced.
|
||||
SYNC_FILES="CODE_OF_CONDUCT.md LICENSE Makefile.common SECURITY.md .yamllint .github/workflows/golangci-lint.yml"
|
||||
SYNC_FILES="CODE_OF_CONDUCT.md LICENSE Makefile.common SECURITY.md .yamllint scripts/golangci-lint.yml"
|
||||
|
||||
# Go to the root of the repo
|
||||
cd "$(git rev-parse --show-cdup)" || exit 1
|
||||
|
@ -115,20 +115,23 @@ process_repo() {
|
|||
local needs_update=()
|
||||
for source_file in ${SYNC_FILES}; do
|
||||
source_checksum="$(sha256sum "${source_dir}/${source_file}" | cut -d' ' -f1)"
|
||||
|
||||
target_file="$(curl -sL --fail "https://raw.githubusercontent.com/${org_repo}/${default_branch}/${source_file}")"
|
||||
if [[ "${source_file}" == 'scripts/golangci-lint.yml' ]] && ! check_go "${org_repo}" "${default_branch}" ; then
|
||||
echo "${org_repo} is not Go, skipping golangci-lint.yml."
|
||||
continue
|
||||
fi
|
||||
if [[ "${source_file}" == 'LICENSE' ]] && ! check_license "${target_file}" ; then
|
||||
echo "LICENSE in ${org_repo} is not apache, skipping."
|
||||
continue
|
||||
fi
|
||||
if [[ "${source_file}" == '.github/workflows/golangci-lint.yml' ]] && ! check_go "${org_repo}" "${default_branch}" ; then
|
||||
echo "${org_repo} is not Go, skipping .github/workflows/golangci-lint.yml."
|
||||
continue
|
||||
target_filename="${source_file}"
|
||||
if [[ "${source_file}" == 'scripts/golangci-lint.yml' ]] ; then
|
||||
target_filename=".github/workflows/${source_file}"
|
||||
fi
|
||||
target_file="$(curl -sL --fail "https://raw.githubusercontent.com/${org_repo}/${default_branch}/${target_filename}")"
|
||||
if [[ -z "${target_file}" ]]; then
|
||||
echo "${source_file} doesn't exist in ${org_repo}"
|
||||
case "${source_file}" in
|
||||
CODE_OF_CONDUCT.md | SECURITY.md | .github/workflows/golangci-lint.yml)
|
||||
CODE_OF_CONDUCT.md | SECURITY.md)
|
||||
echo "${source_file} missing in ${org_repo}, force updating."
|
||||
needs_update+=("${source_file}")
|
||||
;;
|
||||
|
@ -159,8 +162,12 @@ process_repo() {
|
|||
|
||||
# Update the files in target repo by one from prometheus/prometheus.
|
||||
for source_file in "${needs_update[@]}"; do
|
||||
target_filename="${source_file}"
|
||||
if [[ "${source_file}" == 'scripts/golangci-lint.yml' ]] ; then
|
||||
target_filename=".github/workflows/${source_file}"
|
||||
fi
|
||||
case "${source_file}" in
|
||||
*) cp -f "${source_dir}/${source_file}" "./${source_file}" ;;
|
||||
*) cp -f "${source_dir}/${source_file}" "./${target_filename}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue