summaryrefslogtreecommitdiff
path: root/testing/buf/APKBUILD
blob: 54807478ef6f87ca79640dddf8ab78ddf882d0fe (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
70
71
72
73
# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=buf
pkgver=1.29.0
pkgrel=0
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 protoc-gen-go"
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

	# These programs are required for check phase
	mkdir -p "$builddir"/bin
	for cmd in writer receiver; do
		go build -v -o bin/ ./private/buf/cmd/buf/command/alpha/protoc/internal/protoc-gen-insertion-point-$cmd
	done
}

check() {
	export PATH="$PATH:$builddir/bin"

	# TestCompareGeneratedStubsGoogleapisGo fails due to difference in protoc versions
	# TestCompareGoogleapis fails (TODO: investigate more)
	# TestGitCloner tries to clone a remote repository
	# TestWorkspaceGit checks the project root whether it is a git repo
	go test -skip 'TestCompareGeneratedStubsGoogleapisGo|TestCompareGoogleapis|TestGitCloner|TestWorkspaceGit' ./...
}

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() {
	pkgdesc="$pkgdesc (protoc plugins)"
	depends="protoc"

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

sha512sums="
4b7e034429cb4eb3607546f6e671919ed3863221a52b374fb608148836dafb8aba7609716a2c3ceb30dc6b30370e8956a74d1d187cec3a48f7cf3216501e3466  buf-1.29.0.tar.gz
"