gitlab-ci: include flags to make reproducible builds

* https://github.com/golang/go/issues/33772
This commit is contained in:
Hans-Christoph Steiner 2020-07-16 20:09:20 +02:00
parent 1318b6a9ec
commit 51f2c026fd
No known key found for this signature in database
GPG key ID: 3E177817BA1B9BFA
2 changed files with 10 additions and 7 deletions

View file

@ -1,4 +1,9 @@
variables:
DEBIAN_FRONTEND: noninteractive
REPRODUCIBLE_FLAGS: -trimpath -ldflags=-buildid=
# set up apt for automated use
.apt-template: &apt-template .apt-template: &apt-template
- export LC_ALL=C.UTF-8 - export LC_ALL=C.UTF-8
- export DEBIAN_FRONTEND=noninteractive - export DEBIAN_FRONTEND=noninteractive
@ -13,13 +18,13 @@
- apt-get update - apt-get update
- apt-get dist-upgrade - apt-get dist-upgrade
# Set things up to use the OS-native packages for Go. Anything that # 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 # 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 # Debian/Ubuntu repo. So those would need to be packaged for this to
# make it into Debian and/or Ubuntu. # make it into Debian and/or Ubuntu.
.debian-native-template: &debian-native-template .debian-native-template: &debian-native-template
variables: variables:
DEBIAN_FRONTEND: noninteractive
GOPATH: /usr/share/gocode GOPATH: /usr/share/gocode
before_script: before_script:
- apt-get update - apt-get update
@ -47,8 +52,6 @@
# use Go installed as part of the official, Debian-based Docker images # use Go installed as part of the official, Debian-based Docker images
.golang-docker-debian-template: &golang-docker-debian-template .golang-docker-debian-template: &golang-docker-debian-template
variables:
DEBIAN_FRONTEND: noninteractive
before_script: before_script:
- apt-get update - apt-get update
- apt-get -qy install --no-install-recommends - apt-get -qy install --no-install-recommends
@ -63,7 +66,7 @@
- cd $CI_PROJECT_DIR/client/ - cd $CI_PROJECT_DIR/client/
- go get - go get
- go build - go build $REPRODUCIBLE_FLAGS
.test-template: &test-template .test-template: &test-template
artifacts: artifacts:
@ -86,7 +89,6 @@ android:
image: debian:bullseye-backports image: debian:bullseye-backports
variables: variables:
ANDROID_HOME: /usr/lib/android-sdk ANDROID_HOME: /usr/lib/android-sdk
DEBIAN_FRONTEND: noninteractive
GOPATH: "/go" GOPATH: "/go"
LANG: C.UTF-8 LANG: C.UTF-8
PATH: "/go/bin:/usr/lib/go-1.16/bin:/usr/bin:/bin" PATH: "/go/bin:/usr/lib/go-1.16/bin:/usr/bin:/bin"
@ -135,7 +137,7 @@ android:
# gomobile builds a shared library not a CLI executable # gomobile builds a shared library not a CLI executable
- sed -i 's,^package main$,package snowflakeclient,' snowflake.go - sed -i 's,^package main$,package snowflakeclient,' snowflake.go
- go get golang.org/x/mobile/bind - go get golang.org/x/mobile/bind
- gomobile bind -v -target=android -trimpath . - gomobile bind -v -target=android $REPRODUCIBLE_FLAGS .
go-1.13: go-1.13:
image: golang:1.13-stretch image: golang:1.13-stretch

3
Vagrantfile vendored
View file

@ -7,7 +7,8 @@ configfile = YAML.load_file(File.join(srvpath, "/.gitlab-ci.yml"))
remote_url = 'https://git.torproject.org/pluggable-transports/snowflake.git' remote_url = 'https://git.torproject.org/pluggable-transports/snowflake.git'
# set up essential environment variables # set up essential environment variables
env = configfile['android']['variables'] env = configfile['variables']
env = env.merge(configfile['android']['variables'])
env['CI_PROJECT_DIR'] = '/builds/tpo/anti-censorship/pluggable-transports/snowflake' env['CI_PROJECT_DIR'] = '/builds/tpo/anti-censorship/pluggable-transports/snowflake'
env_file = Tempfile.new('env') env_file = Tempfile.new('env')
File.chmod(0644, env_file.path) File.chmod(0644, env_file.path)