aboutsummaryrefslogtreecommitdiffstats
path: root/testing/buf/APKBUILD
blob: 98cfb9a9d17a3249721546ec401873fb0db9ec62 (plain)
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
# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=buf
pkgver=1.26.1
pkgrel=1
pkgdesc="CLI to work with Protocol Buffers"
url="https://buf.build/"
# 32bit: fail tests with int overflow
arch="all !x86 !armhf !armv7"
license="Apache-2.0"
makedepends="go"
checkdepends="protobuf-dev"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	$pkgname-protoc-plugins:_protoc
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/bufbuild/buf/archive/refs/tags/v$pkgver.tar.gz"

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

build() {
	for binary in buf protoc-gen-buf-breaking protoc-gen-buf-lint; do
		go build -v ./cmd/$binary
	done

	for shell in bash fish zsh; do
		./buf completion $shell > buf.$shell
	done
}

check() {
	# /private/pkg/git: try to clone a remote repo
	# /private/bufpkg/bufimage/bufimagebuild: TestCompareGoogleapis test fails
	# /private/buf/cmd/buf/command/{generate,alpha/protoc}: fails with a lot of unused proto import warnings
	# shellcheck disable=2046
	go test $(go list ./... | grep -v \
		-e '/private/pkg/git$' \
		-e '/private/bufpkg/bufimage/bufimagebuild$' \
		-e '/private/buf/cmd/buf/command/generate$' \
		-e '/private/buf/cmd/buf/command/alpha/protoc$' \
	)
}

package() {
	install -Dm755 buf -t "$pkgdir"/usr/bin/

	install -Dm644 buf.bash \
		"$pkgdir"/usr/share/bash-completion/completions/buf
	install -Dm644 buf.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/buf.fish
	install -Dm644 buf.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_buf

	install -Dm755 protoc-gen-buf-breaking protoc-gen-buf-lint \
		-t "$pkgdir"/usr/bin/
}

_protoc() {
	depends="protoc"

	amove usr/bin/protoc-gen-buf-*
}

sha512sums="
8d0f3c0a0d0821cb9d3d279e187add692854121bab531f7daae2c205d00ab7cc091530498dad3f8207c4ad1dc2a483f19a3f0bb86c969b841fd2817c7ea51373  buf-1.26.1.tar.gz
"