# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=actionlint
pkgver=1.7.7
pkgrel=4
pkgdesc="Static checker for GitHub Actions workflow files"
url="https://github.com/rhysd/actionlint"
arch="all"
license="MIT"
makedepends="go ronn"
options="chmod-clean net"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/rhysd/actionlint/archive/refs/tags/v$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build \
		-ldflags="-buildid= -X github.com/rhysd/actionlint.version=$pkgver -s -w" \
		./cmd/$pkgname
	ronn ./man/$pkgname.1.ronn
}

check() {
	# actionlint.version should be empty string when running linter_test.go
	sed -i 's/{{ getVersion | json }}/""/g' testdata/format/sarif_template.txt

	# Some tests expect to be run from a git repository.
	git init --quiet
	go test ./...
	rm -rf .git
}

package() {
	install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
	install -Dm644 man/$pkgname.1 "$pkgdir"/usr/share/man/man1/$pkgname.1
	install -Dm644 LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

sha512sums="
d04e15216fd74a9b6cd281011756c888cacd610a265ad3494e5a471d44cee981e0cc18fb33d46710f526706883e6d63da8cf8cba6198087110ebcf6b0a63026b  actionlint-1.7.7.tar.gz
"
