Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 166 additions & 19 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,176 @@
image: golang:1.10-stretch

cache:
paths:
- .gradle/wrapper
- .gradle/caches
# use the packages for Go
.ubuntu-template: &ubuntu-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
golang-github-smartystreets-goconvey-dev
golang-race-detector-runtime
libx11-dev

# 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
libx11-dev
- go get github.com/smartystreets/goconvey/convey

before_script:
.build_env_setup: &build_env_setup |
set -x
apt-get -qy update
apt-get -qy install --no-install-recommends git pkg-config wget
# Create symbolic links under $GOPATH, this is needed for local build
- export src=$GOPATH/src
- mkdir -p $src/git.torproject.org/pluggable-transports
- mkdir -p $src/gitlab.com/$CI_PROJECT_NAMESPACE
- ln -s $CI_PROJECT_DIR $src/git.torproject.org/pluggable-transports/snowflake.git
- ln -s $CI_PROJECT_DIR $src/gitlab.com/$CI_PROJECT_PATH
export src=$GOPATH/src
mkdir -p $src/git.torproject.org/pluggable-transports
mkdir -p $src/github.com/keroserene
mkdir -p $src/gitlab.com/$CI_PROJECT_NAMESPACE
ln -s $CI_PROJECT_DIR $src/git.torproject.org/pluggable-transports/snowflake
ln -s $CI_PROJECT_DIR $src/git.torproject.org/pluggable-transports/snowflake.git
Copy link

@uumaro uumaro Nov 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linking both snowflake and snowflake.git feels like voodoo to me. Only the .git one should be needed.

Maybe the cause of this is confusion with the old github.com/keroserene/snowflake repo, which uses a non-.git URL (based on this too). But github.com/keroserene/snowflake shouldn't appear anywhere; see #43 (comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My task was to get this building and running for Android. Since that was quite difficult, I started by getting it building and running on Debian. I don't know Go at all. This is what I did to get things working reliably based on my ignorance. Feel free to change it to something more properly Go. I'm not the one to do that, since I don't know Go.

ln -s $CI_PROJECT_DIR $src/github.com/keroserene/snowflake
ln -s $CI_PROJECT_DIR $src/github.com/keroserene/snowflake.git
ln -s $CI_PROJECT_DIR $src/gitlab.com/$CI_PROJECT_PATH
ln -s $CI_PROJECT_DIR $src/gitlab.com/${CI_PROJECT_PATH}.git
git checkout -B $CI_COMMIT_REF_NAME origin/$CI_COMMIT_REF_NAME # force to a branch for `go get -u`
set +x

build:
.artifacts-template: &artifacts-template
stage: deploy
artifacts:
name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
untracked: true
paths:
- client/client
- client/*.aar
- client/*.jar
when:
always
expire_in: 1 day
after_script:
- echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"

.script-template: &script-template
script:
- apt-get -qy update
- apt-get -qy install libx11-dev
- cd $src/gitlab.com/$CI_PROJECT_PATH/client
- *build_env_setup
- cd $src/github.com/keroserene/snowflake
- go get ./...
- go build ./...
- go vet ./...
- go test -v -race ./...

after_script:
# this file changes every time but should not be cached
- rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
- rm -fr $GRADLE_USER_HOME/caches/*/plugin-resolution/
- wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
- export NVM_DIR="$HOME/.nvm"
- . "$NVM_DIR/nvm.sh"
- export TRAVIS_NODE_VERSION="4.2"
- nvm install $TRAVIS_NODE_VERSION
- cd proxy
- npm install
- npm run-script lint
- npm test

# -- jobs ------------------------------------------------------------

android:
image: registry.gitlab.com/eighthave/ci-image-gomobile
<<: *artifacts-template
variables:
GOPATH: "/go"
script:
- *build_env_setup
- cd $src/github.com/keroserene/snowflake/client
- go get -d -u ./...
- cp $src/github.com/keroserene/go-webrtc/webrtc-android-armeabi-v7a.pc
$src/github.com/keroserene/go-webrtc/webrtc-linux-arm.pc # cgo uses both on Android :-/
- export CGO_CXXFLAGS=-D_GLIBCXX_USE_CXX_ABI=1
- export CGO_CFLAGS="-fsanitize=address"
- export CGO_LDFLAGS="-fsanitize=address"
# gomobile bind won't build code with 'package main'
- sed -i 's,^package main$,package snowflakeclient,' snowflake.go
- gomobile bind -v -x -target=android/arm github.com/keroserene/snowflake/client

# build against Debian/testing and publish .deb to local apt repo
pages:
image: debian:stretch-backports
<<: *artifacts-template
variables:
DEBIAN_FRONTEND: noninteractive
GOPATH: /usr/share/gocode
script:
- *build_env_setup
- apt-get -qy update
- apt-get -qy install --no-install-recommends -t stretch-backports
aptly
golang-github-smartystreets-goconvey-dev
- apt-get -qy install --no-install-recommends
build-essential
ca-certificates
gnupg1
libx11-dev
- cd $src/github.com/keroserene/snowflake
- go get ./...
- go build ./...
- ./build-deb

# build apt repo from freshly built .debs
- rm -rf public $HOME/.aptly
- ln -s $CI_PROJECT_DIR $HOME/.aptly
- export aptly="aptly -gpg-provider=internal"
- export DEB_BUILD_ARCH=`dpkg --print-architecture`
- $aptly repo create autobuilt || true
- $aptly repo add autobuilt *.deb
- $aptly publish repo --skip-signing --distribution autobuilt --architectures all,$DEB_BUILD_ARCH autobuilt
|| $aptly publish update --skip-signing --architectures all,$DEB_BUILD_ARCH autobuilt
# ease debugging since directory indices are disabled
- export JOB_URL="$CI_PROJECT_URL/-/jobs/$CI_JOB_ID"
- export COMMIT_URL="$CI_PROJECT_URL/commit/$CI_COMMIT_SHA"
- export BRANCH_URL="$CI_PROJECT_URL/commits/$CI_COMMIT_REF_NAME"
- cd public
- printf "<html><head><title>apt source for %s</title></head><body>" $CI_PROJECT_PATH > index.html
- printf "<h1>$CI_PROJECT_PATH apt repo</h1>" >> index.html
- printf "<ul><li>`date`</li>" >> index.html
- printf '<li><a href="%s">%s</a></li>\n' $JOB_URL $JOB_URL >> index.html
- printf '<li>branch <a href="%s"><code>%s</code></a></li>' $BRANCH_URL $CI_COMMIT_REF_NAME >> index.html
- printf '<li>commit <a href="%s"><code>%s</code></a></li>' $COMMIT_URL $CI_COMMIT_SHA >> index.html
- printf "<li><code>deb [allow-insecure=yes] https://${CI_PROJECT_NAMESPACE}.gitlab.io/${CI_PROJECT_NAME} autobuilt main</code></li>" >> index.html
- printf "<li><code>apt-get install --allow-unauthenticated -t autobuilt snowflake</code></li>" >> index.html
- printf '</ul>\n' >> index.html
- for f in `find | sort`; do printf '<a href="%s"><code>%s</code></a><br/>\n' $f $f >> index.html; done
- echo "</ul></body></html>" >> index.html

debian-stretch_go-1.10:
image: golang:1.10-stretch
<<: *golang-docker-debian-template
<<: *artifacts-template
<<: *script-template

debian-stretch_go-1.11:
image: golang:1.11-stretch
<<: *golang-docker-debian-template
<<: *artifacts-template
<<: *script-template

ubuntu-devel:
image: ubuntu:devel
<<: *ubuntu-template
<<: *artifacts-template
<<: *script-template

ubuntu-rolling:
image: ubuntu:rolling
<<: *ubuntu-template
<<: *artifacts-template
<<: *script-template

ubuntu-lts:
image: ubuntu:latest
<<: *ubuntu-template
<<: *artifacts-template
<<: *script-template
38 changes: 38 additions & 0 deletions build-deb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
#
# put pieces into Debian binary package layout and build a .deb

set -e
set -x

basedir=$(cd $(dirname $0); pwd)

mkdir -p $basedir/debian/usr/bin/
mkdir -p $basedir/debian/usr/share/doc/snowflake/examples/

cd $basedir/debian/usr/bin
go build github.com/keroserene/snowflake/broker
go build github.com/keroserene/snowflake/client
go build github.com/keroserene/snowflake/proxy-go
go build github.com/keroserene/snowflake/server
go build github.com/keroserene/snowflake/server-webrtc

cd $basedir
cp CONTRIBUTING.md LICENSE README.md \
debian/usr/share/doc/snowflake/
cp client/torrc \
client/torrc-localhost \
client/torrc-manual \
debian/usr/share/doc/snowflake/examples/
chmod -R go-w debian/

export VERSION=0.0.$(git rev-list --count HEAD)~g${CI_COMMIT_SHA:0:7}-1~$(date '+%s')
sed -i "s/^Version:.*/Version: $VERSION/" debian/DEBIAN/control
grep "^Version: $VERSION" debian/DEBIAN/control

dpkg-deb --build debian

if [ -z "$CI_COMMIT_SHA" ]; then
CI_COMMIT_SHA=`git describe --always`
fi
mv --verbose debian.deb snowflake_${VERSION}_$(dpkg --print-architecture).deb
12 changes: 12 additions & 0 deletions debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Source: snowflake
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not put a /debian folder in release tarballs, so if this is accepted tagging realeses would be bad. The reason is Debian proper cannot package non-native, that's this project, cleanly... The source diff looks either ugly or incomplete.

Instead put these files in a staging folder and have build scripts copy or link them into place. Debian has no standard for doing this, but it is a rule not to package projects with a clashing folder.

Section: devel
Priority: optional
Homepage: https://trac.torproject.org/projects/tor/wiki/doc/Snowflake
Maintainer: Hans-Christoph Steiner <[email protected]>
Package: snowflake
Architecture: amd64
Version: 0.0-1
Recommends: nodejs,
tor
Description: Pluggable Transport using WebRTC, inspired by Flashproxy
Snowflake is a Pluggable Transport that pipes traffic through WebRTC proxies.