Skip to content

Commit

Permalink
Simplify build
Browse files Browse the repository at this point in the history
  • Loading branch information
brectanus-sigsci committed Jun 15, 2020
1 parent 150b4bf commit 88301f3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 77 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


build: ## build and lint locally
./scripts/build.sh

Expand All @@ -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 ./...
Expand Down
82 changes: 35 additions & 47 deletions make.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions scripts/build-docker.sh

This file was deleted.

20 changes: 9 additions & 11 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down

0 comments on commit 88301f3

Please sign in to comment.