Skip to content

Commit 4a8bace

Browse files
Merge pull request #16 from signalsciences/BuildOnGithubActions
Build on GitHub actions
2 parents 86be9a0 + 05698fd commit 4a8bace

File tree

8 files changed

+74
-62
lines changed

8 files changed

+74
-62
lines changed
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: sigsci-module-golang
22
on:
33
push:
4-
branches: [ BuildOnGithubActions ]
4+
branches: [ master ]
55

66
jobs:
77
build:
@@ -15,13 +15,9 @@ jobs:
1515
aws-region: us-west-2
1616
- name: Check out code into the Go module directory
1717
uses: actions/checkout@v2
18-
- name: Set up Go 1.12
19-
uses: actions/setup-go@v1
20-
with:
21-
go-version: 1.12
22-
id: go
2318
- name: Run make script
2419
run: |
20+
$(aws ecr get-login --registry-ids 803688608479 --region us-west-2 --no-include-email)
2521
./make.sh
2622
env:
2723
PROD_ID: ${{ secrets.SIGSCI_PROD_CANONICAL_ID }}

make-jenkins.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

make.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
# build / lint agent in a container
6+
find . -name "goroot" -type d | xargs rm -rf
7+
mkdir goroot
8+
9+
10+
docker build -f Dockerfile.git -t golang-git:1.10.6-alpine3.8 .
11+
docker run --user $(id -u ${USER}):$(id -g ${USER}) -v ${PWD}/goroot:/go/ --rm golang-git:1.10.6-alpine3.8 /bin/sh -c 'go get github.com/signalsciences/tlstext && go get github.com/tinylib/msgp && go get github.com/alecthomas/gometalinter'
12+
./scripts/build-docker.sh
13+
14+
# run module tests
15+
./scripts/test.sh
16+
17+
18+
BASE=$PWD
19+
## setup our package properties by distro
20+
PKG_NAME="sigsci-module-golang"
21+
DEST_BUCKET="package-build-artifacts"
22+
DEST_KEY="${PKG_NAME}/${GITHUB_RUN_NUMBER}"
23+
VERSION=$(cat ./VERSION)
24+
25+
26+
cd ${BASE}
27+
echo "DONE"
28+
29+
# Main package
30+
aws s3api put-object \
31+
--bucket "${DEST_BUCKET}" \
32+
--cache-control="max-age=300" \
33+
--content-type="application/octet-stream" \
34+
--body "./artifacts/${PKG_NAME}.tar.gz" \
35+
--key "${DEST_KEY}/${PKG_NAME}_${VERSION}.tar.gz" \
36+
--grant-full-control id="${PROD_ID}"
37+
38+
# Metadata files
39+
aws s3api put-object \
40+
--bucket "${DEST_BUCKET}" \
41+
--cache-control="max-age=300" \
42+
--content-type="text/plain; charset=UTF-8" \
43+
--body "VERSION" \
44+
--key "${DEST_KEY}/VERSION" \
45+
--grant-full-control id="${PROD_ID}"
46+
47+
aws s3api put-object \
48+
--bucket "${DEST_BUCKET}" \
49+
--cache-control="max-age=300" \
50+
--content-type="text/plain; charset=UTF-8" \
51+
--body "CHANGELOG.md" \
52+
--key "${DEST_KEY}/CHANGELOG.md" \
53+
--grant-full-control id="${PROD_ID}"
54+
55+
56+
57+
58+
59+

scripts/build-docker.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
docker build -t foo .
44

5+
6+
57
rm -rf goroot
68
docker run -v ${PWD}:/go/src/github.com/signalsciences/sigsci-module-golang --rm foo ./scripts/build.sh

scripts/test-golang110/docker-compose.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121

2222
# agent
2323
agent:
24-
image: local-dev/sigsci-agent:latest
24+
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/sigsci-agent:latest
2525
command: [ "-debug-log-web-inputs", "2", "-rpc-address", "9090", "-debug-rpc-test-harness", "-debug-standalone", "3" ]
2626
expose:
2727
- "9090"
@@ -31,7 +31,7 @@ services:
3131

3232
# punching bag
3333
punchingbag:
34-
image: local-dev/module-testing:latest
34+
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/module-testing:latest
3535
networks:
3636
- mtest
3737
expose:
@@ -41,7 +41,7 @@ services:
4141
# mtest
4242
#
4343
mtest:
44-
image: local-dev/module-testing:latest
44+
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/module-testing:latest
4545
networks:
4646
- mtest
4747
depends_on:
@@ -55,3 +55,4 @@ services:
5555
- MTEST_AGENT=agent:12345
5656
command: [ "/bin/wait-for", "web:8085", "--", "/bin/mtest", "-test.v" ]
5757

58+

scripts/test-golang110/test.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -e
2+
set -ex
33

44
DOCKERCOMPOSE="docker-compose"
55

@@ -20,16 +20,14 @@ cleanup() {
2020
}
2121
trap cleanup 0 1 2 3 6
2222

23-
set -x
24-
2523
# attempt to clean up any leftover junk
2624
$DOCKERCOMPOSE down
2725

2826
$DOCKERCOMPOSE pull --ignore-pull-failures
2927

3028
# start everything, run tests
3129
#
32-
# --no-color --> safe for jenkins
30+
# --no-color --> safe for ci
3331
# --build --> alway build test server/module container
3432
# --abort-on-container-exit --> without this, the other servers keep the process running
3533
# --exit-code-from mtest --> make exit code be the result of module test
@@ -41,5 +39,6 @@ if [ -d "goroot" ]; then
4139
rm -rf goroot
4240
fi
4341
docker run -v ${PWD}/goroot:/go/ --rm golang:1.10.6-alpine3.8 /bin/sh -c 'apk --update add git && go get github.com/signalsciences/tlstext && go get github.com/tinylib/msgp && go get github.com/alecthomas/gometalinter'
42+
4443
$DOCKERCOMPOSE up --no-color --build --abort-on-container-exit --exit-code-from mtest > /dev/null
4544

scripts/test-golang111/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121

2222
# agent
2323
agent:
24-
image: local-dev/sigsci-agent:latest
24+
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/sigsci-agent:latest
2525
command: [ "-debug-log-web-inputs", "2", "-rpc-address", "9090", "-debug-rpc-test-harness", "-debug-standalone", "3" ]
2626
expose:
2727
- "9090"
@@ -31,7 +31,7 @@ services:
3131

3232
# punching bag
3333
punchingbag:
34-
image: local-dev/module-testing:latest
34+
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/module-testing:latest
3535
networks:
3636
- mtest
3737
expose:
@@ -41,7 +41,7 @@ services:
4141
# mtest
4242
#
4343
mtest:
44-
image: local-dev/module-testing:latest
44+
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/module-testing:latest
4545
networks:
4646
- mtest
4747
depends_on:

scripts/test-golang111/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $DOCKERCOMPOSE pull --ignore-pull-failures
2929

3030
# start everything, run tests
3131
#
32-
# --no-color --> safe for jenkins
32+
# --no-color --> safe for ci
3333
# --build --> alway build test server/module container
3434
# --abort-on-container-exit --> without this, the other servers keep the process running
3535
# --exit-code-from mtest --> make exit code be the result of module test

0 commit comments

Comments
 (0)