makefile: implement make lint
This commit is contained in:
parent
786f44e7e7
commit
c36367d4cc
5 changed files with 48 additions and 18 deletions
23
.github/workflows/tests.yml
vendored
23
.github/workflows/tests.yml
vendored
|
|
@ -122,28 +122,17 @@ jobs:
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: Apt update
|
- name: Install dependencies
|
||||||
run: sudo apt-get update
|
run: sudo tools/apt-install-deps.sh
|
||||||
|
|
||||||
# This is needed to lint internal/upload/koji package
|
- name: Extract golangci-lint version from Makefile
|
||||||
- name: Install kerberos devel package
|
id: golangci_lint_version
|
||||||
run: sudo apt-get install -y libkrb5-dev
|
run: echo "GOLANGCI_LINT_VERSION=$(awk -F '=' '/^GOLANGCI_LINT_VERSION *=/{print $2}' Makefile)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# This is needed for the container upload dependencies
|
|
||||||
- name: Install libgpgme devel package
|
|
||||||
run: sudo apt-get install -y libgpgme-dev
|
|
||||||
|
|
||||||
# This is needed for the 'github.com/containers/storage' package
|
|
||||||
- name: Install btrfs-progs devel package
|
|
||||||
run: sudo apt-get install -y libbtrfs-dev
|
|
||||||
|
|
||||||
- name: Install libdevmapper devel package
|
|
||||||
run: sudo apt-get install -y libdevmapper-dev
|
|
||||||
|
|
||||||
- name: Run golangci-lint
|
- name: Run golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v6
|
uses: golangci/golangci-lint-action@v6
|
||||||
with:
|
with:
|
||||||
version: v1.54.2
|
version: ${{ steps.golangci_lint_version.outputs.GOLANGCI_LINT_VERSION }}
|
||||||
args: --verbose --timeout 5m0s
|
args: --verbose --timeout 5m0s
|
||||||
|
|
||||||
packit-config-lint:
|
packit-config-lint:
|
||||||
|
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -13,3 +13,5 @@ __pycache__
|
||||||
/tools/appsre-ansible/inventory
|
/tools/appsre-ansible/inventory
|
||||||
|
|
||||||
/docs/osbuild-composer.7
|
/docs/osbuild-composer.7
|
||||||
|
.cache
|
||||||
|
container_composer_golangci_built.info
|
||||||
|
|
|
||||||
5
Containerfile_golangci_lint
Normal file
5
Containerfile_golangci_lint
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
ARG GOLANGCI_LINT_VERSION
|
||||||
|
FROM docker.io/golangci/golangci-lint:${GOLANGCI_LINT_VERSION}
|
||||||
|
|
||||||
|
COPY tools/apt-install-deps.sh /usr/local/bin/.
|
||||||
|
RUN /usr/local/bin/apt-install-deps.sh
|
||||||
19
Makefile
19
Makefile
|
|
@ -19,6 +19,11 @@ SRCDIR ?= .
|
||||||
|
|
||||||
RST2MAN ?= rst2man
|
RST2MAN ?= rst2man
|
||||||
|
|
||||||
|
# v1.55 to get golang 1.21 (1.21.3)
|
||||||
|
# v1.53 to get golang 1.20 (1.20.5)
|
||||||
|
GOLANGCI_LINT_VERSION=v1.53
|
||||||
|
GOLANGCI_LINT_CACHE_DIR=$(HOME)/.cache/golangci-lint/$(GOLANGCI_LINT_VERSION)
|
||||||
|
GOLANGCI_COMPOSER_IMAGE=composer_golangci
|
||||||
#
|
#
|
||||||
# Automatic Variables
|
# Automatic Variables
|
||||||
#
|
#
|
||||||
|
|
@ -82,6 +87,7 @@ help:
|
||||||
@echo " unit-tests: Run unit tests"
|
@echo " unit-tests: Run unit tests"
|
||||||
@echo " push-check: Replicates the github workflow checks as close as possible"
|
@echo " push-check: Replicates the github workflow checks as close as possible"
|
||||||
@echo " (do this before pushing!)"
|
@echo " (do this before pushing!)"
|
||||||
|
@echo " lint: Runs linters as close as github workflow as possible"
|
||||||
|
|
||||||
$(BUILDDIR)/:
|
$(BUILDDIR)/:
|
||||||
mkdir -p "$@"
|
mkdir -p "$@"
|
||||||
|
|
@ -89,6 +95,8 @@ $(BUILDDIR)/:
|
||||||
$(BUILDDIR)/%/:
|
$(BUILDDIR)/%/:
|
||||||
mkdir -p "$@"
|
mkdir -p "$@"
|
||||||
|
|
||||||
|
$(GOLANGCI_LINT_CACHE_DIR):
|
||||||
|
mkdir -p "$@"
|
||||||
#
|
#
|
||||||
# Documentation
|
# Documentation
|
||||||
#
|
#
|
||||||
|
|
@ -156,9 +164,10 @@ install: build
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILDDIR)/bin/
|
rm -rf $(BUILDDIR)/bin/
|
||||||
rm -rf $(CURDIR)/rpmbuild
|
rm -rf $(CURDIR)/rpmbuild
|
||||||
|
rm -rf container_composer_golangci_built.info
|
||||||
|
|
||||||
.PHONY: push-check
|
.PHONY: push-check
|
||||||
push-check: build unit-tests srpm man
|
push-check: lint build unit-tests srpm man
|
||||||
./tools/check-runners
|
./tools/check-runners
|
||||||
./tools/check-snapshots --errors-only .
|
./tools/check-snapshots --errors-only .
|
||||||
rpmlint --config rpmlint.config $(CURDIR)/rpmbuild/SRPMS/*
|
rpmlint --config rpmlint.config $(CURDIR)/rpmbuild/SRPMS/*
|
||||||
|
|
@ -275,3 +284,11 @@ scratch: $(RPM_SPECFILE) $(RPM_TARBALL)
|
||||||
--nocheck \
|
--nocheck \
|
||||||
$(RPM_SPECFILE)
|
$(RPM_SPECFILE)
|
||||||
|
|
||||||
|
container_composer_golangci_built.info: Makefile Containerfile_golangci_lint tools/apt-install-deps.sh
|
||||||
|
podman build -f Containerfile_golangci_lint -t $(GOLANGCI_COMPOSER_IMAGE) --build-arg "GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION)"
|
||||||
|
echo "Image last built on" > $@
|
||||||
|
date >> $@
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint: $(GOLANGCI_LINT_CACHE_DIR) container_composer_golangci_built.info
|
||||||
|
podman run -t --rm -v $(SRCDIR):/app:z -v $(GOLANGCI_LINT_CACHE_DIR):/root/.cache:z -w /app $(GOLANGCI_COMPOSER_IMAGE) golangci-lint run -v
|
||||||
|
|
|
||||||
17
tools/apt-install-deps.sh
Executable file
17
tools/apt-install-deps.sh
Executable file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# just a warning - as "sudo" is not in the container we are using
|
||||||
|
echo "This script should be run as root"
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
|
||||||
|
# This is needed to lint internal/upload/koji package
|
||||||
|
apt-get install -y libkrb5-dev
|
||||||
|
|
||||||
|
# This is needed for the container upload dependencies
|
||||||
|
apt-get install -y libgpgme-dev
|
||||||
|
|
||||||
|
# This is needed for the 'github.com/containers/storage' package
|
||||||
|
apt-get install -y libbtrfs-dev
|
||||||
|
|
||||||
|
apt-get install -y libdevmapper-dev
|
||||||
Loading…
Add table
Add a link
Reference in a new issue