snowflake/.gitlab-ci.yml
Cecylia Bocovich eaac9f5b6b Use go modules to build android library
This commit removes the symlinks and turns go modules back on to run
gomobile bind locally on the project.
2020-07-14 09:16:23 -04:00

131 lines
3.9 KiB
YAML

# Set things up to use the OS-native packages for Go. Anything that
# is downloaded by go during the `go fmt` stage is not coming from the
# Debian/Ubuntu repo. So those would need to be packaged for this to
# make it into Debian and/or Ubuntu.
.debian-native-template: &debian-native-template
variables:
DEBIAN_FRONTEND: noninteractive
GOPATH: /usr/share/gocode
before_script:
- apt-get -qy update
- apt-get -qy install --no-install-recommends
build-essential
ca-certificates
git
golang
golang-github-cheekybits-genny-dev
golang-github-jtolds-gls-dev
golang-github-klauspost-reedsolomon-dev
golang-github-lucas-clemente-quic-go-dev
golang-github-smartystreets-assertions-dev
golang-github-smartystreets-goconvey-dev
golang-github-tjfoc-gmsm-dev
golang-github-xtaci-kcp-dev
golang-github-xtaci-smux-dev
golang-golang-x-crypto-dev
golang-golang-x-net-dev
golang-golang-x-sys-dev
golang-golang-x-text-dev
golang-golang-x-xerrors-dev
lbzip2
# use Go installed as part of the official, Debian-based Docker images
.golang-docker-debian-template: &golang-docker-debian-template
variables:
DEBIAN_FRONTEND: noninteractive
before_script:
- apt-get -qy update
- apt-get -qy install --no-install-recommends
ca-certificates
git
lbzip2
.go_test: &go-test
- test -z "$(go fmt ./...)"
- go vet ./...
- go test -v -race ./...
- cd $CI_PROJECT_DIR/client/
- go get
- go build
.test-template: &test-template
artifacts:
name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths:
- client/*.aar
- client/*.jar
- client/client
expire_in: 1 day
when: on_success
after_script:
- echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
# -- jobs ------------------------------------------------------------
android:
image: registry.gitlab.com/fdroid/ci-images-client
variables:
GOPATH: "/go"
cache:
paths:
- .gradle/wrapper
- .gradle/caches
before_script:
- apt-get -qy update
- apt-get -qy install --no-install-recommends
build-essential
gnupg
wget
- cd /usr/local
- export gotarball="go1.13.12.linux-amd64.tar.gz"
- wget -q https://dl.google.com/go/${gotarball}
- wget -q https://dl.google.com/go/${gotarball}.asc
- curl https://dl.google.com/linux/linux_signing_key.pub | gpg --import
- gpg --verify ${gotarball}.asc
- echo "9cacc6653563771b458c13056265aa0c21b8a23ca9408278484e4efde4160618 ${gotarball}" | sha256sum -c
- tar -xzf ${gotarball}
- export PATH="/usr/local/go/bin:$GOPATH/bin:$PATH" # putting this in 'variables:' cause weird runner errors
- cd $CI_PROJECT_DIR
script:
- *go-test
- export GRADLE_USER_HOME=$PWD/.gradle
- go version
- go env
- go get golang.org/x/mobile/cmd/gomobile
- go get golang.org/x/mobile/cmd/gobind
- go install golang.org/x/mobile/cmd/gomobile
- go install golang.org/x/mobile/cmd/gobind
- echo y | $ANDROID_HOME/tools/bin/sdkmanager 'ndk-bundle' > /dev/null
- gomobile init
- git -C $CI_PROJECT_DIR reset --hard
- git -C $CI_PROJECT_DIR clean -fdx
- cd $CI_PROJECT_DIR/client
# gomobile builds a shared library not a CLI executable
- sed -i 's,^package main$,package snowflakeclient,' snowflake.go client_test.go
- gomobile bind -v -target=android .
<<: *test-template
go-1.13:
image: golang:1.13-stretch
<<: *golang-docker-debian-template
<<: *test-template
script:
- *go-test
go-1.14:
image: golang:1.14-stretch
<<: *golang-docker-debian-template
<<: *test-template
script:
- *go-test
debian-testing:
image: debian:testing
<<: *debian-native-template
<<: *test-template
script:
- *go-test