From 88301f3e0bee69b6287e4ae277d2abfdd865e83e Mon Sep 17 00:00:00 2001 From: Brian Rectanus Date: Mon, 15 Jun 2020 18:35:50 -0400 Subject: [PATCH] Simplify build --- .github/workflows/build.yml | 5 ++- Makefile | 10 ----- make.sh | 82 ++++++++++++++++--------------------- scripts/build-docker.sh | 8 ---- scripts/build.sh | 20 ++++----- 5 files changed, 48 insertions(+), 77 deletions(-) delete mode 100755 scripts/build-docker.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f9bef5..1616779 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,8 +5,11 @@ on: jobs: build: - name: Build runs-on: ubuntu-latest + strategy: + matrix: + go: [ '1.14' ] + name: Build ${{ matrix.go }} steps: - uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/Makefile b/Makefile index 9142d9d..c966a87 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,3 @@ - - build: ## build and lint locally ./scripts/build.sh @@ -8,15 +6,7 @@ build: ## build and lint locally test: ## build and run integration test ./scripts/test.sh -init: ## install gometalinter and msgp locally - go get -u github.com/alecthomas/gometalinter - gometalinter --install --debug - go get -u github.com/tinylib/msgp/msgp - go get . - - clean: ## cleanup - find . -name 'goroot' -type d | xargs rm -rf rm -rf artifacts find . -name '*.log' | xargs rm -f go clean ./... diff --git a/make.sh b/make.sh index 4844ac0..8d1aa07 100755 --- a/make.sh +++ b/make.sh @@ -1,50 +1,38 @@ #!/bin/sh - set -ex -# build / lint agent in a container -find . -name "goroot" -type d | xargs rm -rf -mkdir goroot - -docker build -f Dockerfile.git -t golang-git:1.14-alpine . -docker run --user $(id -u ${USER}):$(id -g ${USER}) -v ${PWD}/goroot:/go/ --rm golang-git:1.14-alpine /bin/sh -c 'go get github.com/signalsciences/tlstext && go get github.com/tinylib/msgp && go get github.com/alecthomas/gometalinter' -./scripts/build-docker.sh - -# run module tests -./scripts/test.sh - -BASE=$PWD -## setup our package properties by distro -PKG_NAME="sigsci-module-golang" -DEST_BUCKET="package-build-artifacts" -DEST_KEY="${PKG_NAME}/${GITHUB_RUN_NUMBER}" -VERSION=$(cat ./VERSION) - -cd ${BASE} -echo "DONE" - -# Main package -aws s3api put-object \ - --bucket "${DEST_BUCKET}" \ - --cache-control="max-age=300" \ - --content-type="application/octet-stream" \ - --body "./artifacts/${PKG_NAME}.tar.gz" \ - --key "${DEST_KEY}/${PKG_NAME}_${VERSION}.tar.gz" \ - --grant-full-control id="${PROD_ID}" - -# Metadata files -aws s3api put-object \ - --bucket "${DEST_BUCKET}" \ - --cache-control="max-age=300" \ - --content-type="text/plain; charset=UTF-8" \ - --body "VERSION" \ - --key "${DEST_KEY}/VERSION" \ - --grant-full-control id="${PROD_ID}" - -aws s3api put-object \ - --bucket "${DEST_BUCKET}" \ - --cache-control="max-age=300" \ - --content-type="text/plain; charset=UTF-8" \ - --body "CHANGELOG.md" \ - --key "${DEST_KEY}/CHANGELOG.md" \ - --grant-full-control id="${PROD_ID}" +./scripts/build.sh + +if [ -n "${PROD_ID}" ]; then + ## setup our package properties by distro + PKG_NAME="sigsci-module-golang" + DEST_BUCKET="package-build-artifacts" + DEST_KEY="${PKG_NAME}/${GITHUB_RUN_NUMBER}" + VERSION=$(cat ./VERSION) + + # Main package + aws s3api put-object \ + --bucket "${DEST_BUCKET}" \ + --cache-control="max-age=300" \ + --content-type="application/octet-stream" \ + --body "./artifacts/${PKG_NAME}.tar.gz" \ + --key "${DEST_KEY}/${PKG_NAME}_${VERSION}.tar.gz" \ + --grant-full-control id="${PROD_ID}" + + # Metadata files + aws s3api put-object \ + --bucket "${DEST_BUCKET}" \ + --cache-control="max-age=300" \ + --content-type="text/plain; charset=UTF-8" \ + --body "VERSION" \ + --key "${DEST_KEY}/VERSION" \ + --grant-full-control id="${PROD_ID}" + + aws s3api put-object \ + --bucket "${DEST_BUCKET}" \ + --cache-control="max-age=300" \ + --content-type="text/plain; charset=UTF-8" \ + --body "CHANGELOG.md" \ + --key "${DEST_KEY}/CHANGELOG.md" \ + --grant-full-control id="${PROD_ID}" +fi diff --git a/scripts/build-docker.sh b/scripts/build-docker.sh deleted file mode 100755 index e039236..0000000 --- a/scripts/build-docker.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -ex - -docker build -t foo . - - - -rm -rf goroot -docker run -v ${PWD}:/go/src/github.com/signalsciences/sigsci-module-golang --rm foo ./scripts/build.sh diff --git a/scripts/build.sh b/scripts/build.sh index d915cdc..8b6c5f6 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,21 +1,19 @@ #!/bin/sh set -ex -echo "package sigsci" > version.go -echo "" >> version.go -echo "const version = \"$(cat VERSION)\"" >> version.go -find . -name "goroot" -type d | xargs rm -rf -go generate ./... - -# make sure files made in docker are readable by all -chmod a+r *.go +which go +go version +eval $(go env | grep GOROOT) +export GOROOT +export CGO_ENABLED=0 go build . go test . -# --enable=gosimple \ -# --enable=unused \ - +### Run the linter +if [ -z "$(which gometalinter)" ]; then + go get github.com/alecthomas/gometalinter +fi gometalinter \ --vendor \ --deadline=60s \