Skip to content

Commit 1e547d1

Browse files
committed
packit/tmt: initial enablement
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent e51be96 commit 1e547d1

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

.fmf/version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

.packit.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
# See the documentation for more information:
3+
# https://packit.dev/docs/configuration/
4+
5+
jobs:
6+
# All tests specified in the `/plans/` subdir
7+
- job: tests
8+
trigger: pull_request
9+
#notifications:
10+
#failure_comment:
11+
# message: "validate test failed."
12+
targets: &pr_test_targets
13+
- fedora-latest-stable
14+
skip_build: true
15+
identifier: windows_validate
16+
tmt_plan: "/plans/validate"

Makefile

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ export GOOS=windows
22
export GOARCH=amd64
33
SRC = $(shell find . -type f -name '*.go')
44

5+
GOLANGCI_LINT_VERSION := 1.54.2
6+
.PHONY: .install.golangci-lint
7+
.install.golangci-lint:
8+
VERSION=$(GOLANGCI_LINT_VERSION) ./hack/install_golangci.sh
9+
10+
.PHONY: validate
11+
validate:
12+
./bin/golangci-lint run
13+
514
.PHONY: default
615
default: build
716

hack/install_golangci.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
# This script is intended to be a convenience, to be called from the
4+
# Makefile `.install.golangci-lint` target. Any other usage is not recommended.
5+
6+
die() { echo "${1:-No error message given} (from $(basename $0))"; exit 1; }
7+
8+
[ -n "$VERSION" ] || die "\$VERSION is empty or undefined"
9+
10+
function install() {
11+
local retry=$1
12+
13+
local msg="Installing golangci-lint v$VERSION into $BIN"
14+
if [[ $retry -ne 0 ]]; then
15+
msg+=" - retry #$retry"
16+
fi
17+
echo $msg
18+
19+
curl -sSL --retry 5 https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$VERSION
20+
}
21+
22+
# Undocumented behavior: golangci-lint installer requires $BINDIR in env,
23+
# will default to ./bin but we can't rely on that.
24+
export BINDIR="./bin"
25+
BIN="$BINDIR/golangci-lint"
26+
if [ ! -x "$BIN" ]; then
27+
# This flakes much too frequently with "crit unable to find v1.51.1"
28+
for retry in $(seq 0 5); do
29+
install $retry && exit 0
30+
sleep 5
31+
done
32+
else
33+
# Prints its own file name as part of --version output
34+
$BIN --version | grep "$VERSION"
35+
if [ $? -eq 0 ]; then
36+
echo "Using existing $BINDIR/$($BIN --version)"
37+
else
38+
install
39+
fi
40+
fi

plans/main.fmf

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prepare:
2+
- how: install
3+
package:
4+
- golang
5+
6+
/validate:
7+
summary: Validate code
8+
execute:
9+
how: tmt
10+
script: |
11+
make .install.golangci-lint
12+
make validate

0 commit comments

Comments
 (0)