Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
110 additions
and 43 deletions.
- +11 β0 Dockerfile.test
- +7 β0 docker-compose.yml
- +1 β0 script/bootstrap
- +35 β0 script/build-deploy-tarball
- +1 β15 script/cibuild
- +38 β28 script/cibuild-gh-ost-build-deploy-tarball
- +17 β0 script/test
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -0,0 +1,11 @@ | ||
| FROM golang:1.12.1 | ||
| LABEL maintainer="github@github.com" | ||
|
|
||
| RUN apt-get update | ||
| RUN apt-get install -y lsb-release | ||
| RUN rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY . /go/src/github.com/github/gh-ost | ||
| WORKDIR /go/src/github.com/github/gh-ost | ||
|
|
||
| CMD ["script/test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -0,0 +1,7 @@ | ||
| version: "3.5" | ||
| services: | ||
| app: | ||
| image: app | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -0,0 +1,35 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -e | ||
|
|
||
| script/build | ||
|
|
||
| # Get a fresh directory and make sure to delete it afterwards | ||
| build_dir=tmp/build | ||
| rm -rf $build_dir | ||
| mkdir -p $build_dir | ||
| trap "rm -rf $build_dir" EXIT | ||
|
|
||
| commit_sha=$(git rev-parse HEAD) | ||
|
|
||
| if [ $(uname -s) = "Darwin" ]; then | ||
| build_arch="$(uname -sr | tr -d ' ' | tr '[:upper:]' '[:lower:]')-$(uname -m)" | ||
| else | ||
| build_arch="$(lsb_release -sc | tr -d ' ' | tr '[:upper:]' '[:lower:]')-$(uname -m)" | ||
| fi | ||
|
|
||
| tarball=$build_dir/${commit_sha}-${build_arch}.tar | ||
|
|
||
| # Create the tarball | ||
| tar cvf $tarball --mode="ugo=rx" bin/ | ||
|
|
||
| # Compress it and copy it to the directory for the CI to upload it | ||
| gzip $tarball | ||
| mkdir -p "$BUILD_ARTIFACT_DIR"/gh-ost | ||
| cp ${tarball}.gz "$BUILD_ARTIFACT_DIR"/gh-ost/ | ||
|
|
||
| ### HACK HACK HACK ### | ||
| # blame @carlosmn and @mattr- | ||
| # Allow builds on stretch to also be used for jessie | ||
| jessie_tarball_name=$(echo $(basename "${tarball}") | sed s/-stretch-/-jessie-/) | ||
| cp ${tarball}.gz "$BUILD_ARTIFACT_DIR/gh-ost/${jessie_tarball_name}.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -1,17 +1,3 @@ | ||
| #!/bin/bash | ||
|
|
||
| script/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -1,37 +1,47 @@ | ||
| #!/bin/bash | ||
|
|
||
| output_fold() { | ||
| # Exit early if no label provided | ||
| if [ -z "$1" ]; then | ||
| echo "output_fold(): requires a label argument." | ||
| return | ||
| fi | ||
|
|
||
| exit_value=0 # exit_value is used to record exit status of the given command | ||
| label=$1 # human-readable label describing what's being folded up | ||
| shift 1 # having retrieved the output_fold()-specific arguments, strip them off $@ | ||
|
|
||
| # Only echo the tags when in CI_MODE | ||
| if [ "$CI_MODE" ]; then | ||
| echo "%%%FOLD {$label}%%%" | ||
| fi | ||
|
|
||
| # run the remaining arguments. If the command exits non-0, the `||` will | ||
| # prevent the `-e` flag from seeing the failure exit code, and we'll see | ||
| # the second echo execute | ||
| "$@" || exit_value=$? | ||
|
|
||
| # Only echo the tags when in CI_MODE | ||
| if [ "$CI_MODE" ]; then | ||
| echo "%%%END FOLD%%%" | ||
| fi | ||
|
|
||
| # preserve the exit code from the subcommand. | ||
| return $exit_value | ||
| } | ||
|
|
||
| function cleanup() { | ||
| echo | ||
| echo "%%%FOLD {Shutting down services...}%%%" | ||
| docker-compose down | ||
| echo "%%%END FOLD%%%" | ||
| } | ||
|
|
||
| trap cleanup EXIT | ||
|
|
||
| export CI_MODE=true | ||
|
|
||
| output_fold "Bootstrapping container..." docker-compose build | ||
| output_fold "Running tests..." docker-compose run --rm app | ||
|
|
||
| docker-compose run -e BUILD_ARTIFACT_DIR=$BUILD_ARTIFACT_DIR -v $BUILD_ARTIFACT_DIR:$BUILD_ARTIFACT_DIR app script/build-deploy-tarball |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| . script/bootstrap | ||
|
|
||
| echo "Verifying code is formatted via 'gofmt -s -w go/'" | ||
| gofmt -s -w go/ | ||
| git diff --exit-code --quiet | ||
|
|
||
| echo "Building" | ||
| script/build | ||
|
|
||
| cd .gopath/src/github.com/github/gh-ost | ||
|
|
||
| echo "Running unit tests" | ||
| go test ./go/... |