CI Improvements

Added a custom docker compiler image which includes the packr2 dependency
This commit is contained in:
Stash Dev 2019-03-05 13:14:00 -08:00
parent 8d23357a13
commit 1a2c53a710
8 changed files with 102 additions and 7 deletions

View File

@ -12,13 +12,13 @@ before_install:
- yarn install
- ./node_modules/@angular/cli/bin/ng build --prod
- cd ../..
- go get -v github.com/mgechev/revive
#- go get -v github.com/mgechev/revive
script:
- make lint
- make vet
#- make lint
#- make vet
- go test
before_deploy:
- docker pull bepsays/ci-goreleaser
- docker pull stashappdev/compiler
- sh ./scripts/cross-compile.sh
- git tag -f v0.0.0-alpha
- git push -f --tags

View File

@ -70,4 +70,4 @@ This project makes use of [this](https://github.com/bep/dockerfiles/tree/master/
where the app can be cross compiled. This process is kicked off by CI via the `scripts/cross-compile.sh` script. Run the following
command to open a bash shell to the container to poke around:
`docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -i -t bepsays/ci-goreleaser:1.11-2 /bin/bash`
`docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -i -t stashappdev/compiler:latest /bin/bash`

1
docker/compiler/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sdk.tar.*

View File

@ -0,0 +1,66 @@
FROM golang:1.11.5
LABEL maintainer="stashappdev@gmail.com"
ENV GORELEASER_VERSION=0.95.0
ENV GORELEASER_SHA=4f3b9fc978a3677806ebd959096a1f976a7c7bb5fbdf7a9a1d01554c8c5c31c5
ENV GORELEASER_DOWNLOAD_FILE=goreleaser_Linux_x86_64.tar.gz
ENV GORELEASER_DOWNLOAD_URL=https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/${GORELEASER_DOWNLOAD_FILE}
ENV PACKR2_VERSION=2.0.2
ENV PACKR2_SHA=f95ff4c96d7a28813220df030ad91700b8464fe292ab3e1dc9582305c2a338d2
ENV PACKR2_DOWNLOAD_FILE=packr_${PACKR2_VERSION}_linux_amd64.tar.gz
ENV PACKR2_DOWNLOAD_URL=https://github.com/gobuffalo/packr/releases/download/v${PACKR2_VERSION}/${PACKR2_DOWNLOAD_FILE}
# Install tools
RUN apt-get update && \
apt-get install -y automake autogen \
libtool libxml2-dev uuid-dev libssl-dev bash \
patch make tar xz-utils bzip2 gzip sed cpio \
gcc-multilib g++-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev --no-install-recommends || exit 1; \
rm -rf /var/lib/apt/lists/*;
# Cross compile setup
ENV OSX_SDK_VERSION 10.11
ENV OSX_SDK MacOSX$OSX_SDK_VERSION.sdk
ENV OSX_NDK_X86 /usr/local/osx-ndk-x86
ENV OSX_SDK_PATH /$OSX_SDK.tar.gz
COPY $OSX_SDK.tar.gz /go
RUN git clone https://github.com/tpoechtrager/osxcross.git && \
git -C osxcross checkout c47ff0aeed1a7d0e1f884812fc170e415f05be5a || exit 1; \
mv $OSX_SDK.tar.gz osxcross/tarballs/ && \
UNATTENDED=yes SDK_VERSION=${OSX_SDK_VERSION} OSX_VERSION_MIN=10.9 osxcross/build.sh || exit 1; \
mv osxcross/target $OSX_NDK_X86; \
rm -rf osxcross;
ENV PATH $OSX_NDK_X86/bin:$PATH
RUN mkdir -p /root/.ssh; \
chmod 0700 /root/.ssh; \
ssh-keyscan github.com > /root/.ssh/known_hosts;
RUN wget ${GORELEASER_DOWNLOAD_URL}; \
echo "$GORELEASER_SHA $GORELEASER_DOWNLOAD_FILE" | sha256sum -c - || exit 1; \
tar -xzf $GORELEASER_DOWNLOAD_FILE -C /usr/bin/ goreleaser; \
rm $GORELEASER_DOWNLOAD_FILE;
RUN wget ${PACKR2_DOWNLOAD_URL}; \
echo "$PACKR2_SHA $PACKR2_DOWNLOAD_FILE" | sha256sum -c - || exit 1; \
tar -xzf $PACKR2_DOWNLOAD_FILE -C /usr/bin/ packr2; \
rm $PACKR2_DOWNLOAD_FILE;
CMD ["goreleaser", "-v"]
CMD ["packr2", "version"]
# Notes for self:
# Windows:
# GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -ldflags "-extldflags '-static'" -tags extended
# Darwin
# CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -tags extended
# env GO111MODULE=on goreleaser --config=goreleaser-extended.yml --skip-publish --skip-validate --rm-dist --release-notes=temp/0.48-relnotes-ready.md

16
docker/compiler/Makefile Normal file
View File

@ -0,0 +1,16 @@
user=stashappdev
repo=compiler
version=1
latest:
docker build -t ${user}/${repo}:latest .
build:
docker build -t ${user}/${repo}:${version} -t ${user}/${repo}:latest .
build-no-cache:
docker build --no-cache -t ${user}/${repo}:${version} -t ${user}/${repo}:latest .
install: build
docker push ${user}/${repo}:${version}
docker push ${user}/${repo}:latest

View File

@ -0,0 +1 @@
Modified from https://github.com/bep/dockerfiles/tree/master/ci-goreleaser

View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
TMP=$(mktemp -d /tmp/XXXXXXXXXXX)
SDK="MacOSX10.11.sdk"
mkdir -p $TMP/$SDK/usr/include/c++
cp -rf /Applications/Xcode7.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$SDK $TMP &>/dev/null || true
cp -rf /Applications/Xcode7.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 $TMP/$SDK/usr/include/c++ || exit -1
tar -C $TMP -czf $SDK.tar.gz $SDK

View File

@ -1,10 +1,10 @@
#!/bin/sh
SETUP="go install github.com/gobuffalo/packr/v2/packr2; export GO111MODULE=on; export CGO_ENABLED=1;"
SETUP="export GO111MODULE=on; export CGO_ENABLED=1;"
WINDOWS="GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ packr2 build -o dist/stash-win.exe -ldflags \"-extldflags '-static'\" -tags extended -v -mod=vendor;"
DARWIN="GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang++ packr2 build -o dist/stash-osx -tags extended -v -mod=vendor;"
LINUX="packr2 build -o dist/stash-linux -v -mod=vendor;"
COMMAND="$SETUP $WINDOWS $DARWIN $LINUX"
docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash bepsays/ci-goreleaser:1.11-2 /bin/bash -c "$COMMAND"
docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash stashappdev/compiler:1 /bin/bash -c "$COMMAND"