Skip to content

Commit 77ebf52

Browse files
committed
Add go 1.17 as the baseline
1 parent 5ed168c commit 77ebf52

File tree

7 files changed

+123
-5
lines changed

7 files changed

+123
-5
lines changed

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module github.com/signalsciences/sigsci-module-golang
22

3-
go 1.18
3+
go 1.17
44

55
require (
6-
github.com/philhofer/fwd v1.0.0 // indirect
76
github.com/signalsciences/tlstext v1.2.0
87
github.com/tinylib/msgp v1.1.0
98
)
9+
10+
require github.com/philhofer/fwd v1.0.0 // indirect

scripts/test-golang117/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM golang:1.17-alpine
2+
3+
# we will mount the current directory here
4+
VOLUME [ "/go/src/github.com/signalsciences/sigsci-module-golang" ]
5+
WORKDIR /go/src/github.com/signalsciences/sigsci-module-golang
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3"
2+
3+
services:
4+
# this defines our webserver uses our sigsci-module
5+
# we only define it so it is attached to our fake network
6+
# it will be run a few times with different options manually
7+
#
8+
# The volumes spec is a bit weird.. this script is run in scripts/test but
9+
# needs stuff in ../../examples. Consider moving.
10+
web:
11+
volumes:
12+
- ../..:/go/src/github.com/signalsciences/sigsci-module-golang
13+
command: [ "go", "run", "/go/src/github.com/signalsciences/sigsci-module-golang/examples/mtest/main.go" ]
14+
environment:
15+
- DEBUG=0
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: "3"
2+
networks:
3+
mtest:
4+
5+
services:
6+
# this defines our webserver uses our sigsci-module
7+
# we only define it so it is attached to our fake network
8+
# it will be run a few times with different options manually
9+
#
10+
#
11+
web:
12+
build:
13+
context: .
14+
dockerfile: Dockerfile
15+
expose:
16+
- "8085"
17+
networks:
18+
- mtest
19+
depends_on:
20+
- agent
21+
22+
# agent
23+
agent:
24+
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/sigsci-agent:latest
25+
command: [ "-debug-log-web-inputs", "2", "-rpc-address", "9090", "-debug-rpc-test-harness", "-debug-standalone", "3" ]
26+
expose:
27+
- "9090"
28+
- "12345"
29+
networks:
30+
- mtest
31+
32+
# punching bag
33+
punchingbag:
34+
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/module-testing:latest
35+
networks:
36+
- mtest
37+
expose:
38+
- "8086"
39+
command: [ "/bin/punchingbag", "-addr", ":8086" ]
40+
41+
# mtest
42+
#
43+
mtest:
44+
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/module-testing:latest
45+
networks:
46+
- mtest
47+
depends_on:
48+
- web
49+
- agent
50+
- punchingbag
51+
environment:
52+
- DISABLE_HTTP_OPTIONS=1
53+
- DISABLE_NOCOOKIE=1
54+
- MTEST_BASEURL=web:8085
55+
- MTEST_AGENT=agent:12345
56+
- "MTEST_RUN_TEST_BLOCK_VIA_REDIRECT=true"
57+
command: [ "/bin/wait-for", "web:8085", "--", "/bin/mtest", "-test.v" ]
58+

scripts/test-golang117/test.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -e
3+
4+
DOCKERCOMPOSE="docker-compose"
5+
6+
# run at end no matter what
7+
cleanup() {
8+
echo "shutting down"
9+
# capture log output
10+
$DOCKERCOMPOSE logs --no-color agent >& agent.log
11+
$DOCKERCOMPOSE logs --no-color web >& web.log
12+
$DOCKERCOMPOSE logs --no-color mtest >& mtest.log
13+
$DOCKERCOMPOSE logs --no-color punchingbag >& punchingbag.log
14+
15+
# delete everything
16+
$DOCKERCOMPOSE down
17+
18+
# show output of module testing
19+
cat mtest.log
20+
}
21+
trap cleanup 0 1 2 3 6
22+
23+
set -x
24+
25+
# attempt to clean up any leftover junk
26+
$DOCKERCOMPOSE down
27+
28+
$DOCKERCOMPOSE pull --ignore-pull-failures
29+
30+
# start everything, run tests
31+
#
32+
# --no-color --> safe for ci
33+
# --build --> alway build test server/module container
34+
# --abort-on-container-exit --> without this, the other servers keep the process running
35+
# --exit-code-from mtest --> make exit code be the result of module test
36+
#
37+
# > /dev/null --> output of all servers is mixed together and ugly
38+
# we get the individual logs at end
39+
#
40+
$DOCKERCOMPOSE up --no-color --build --abort-on-container-exit --exit-code-from mtest > /dev/null
41+

scripts/test-golang118/test.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,5 @@ $DOCKERCOMPOSE pull --ignore-pull-failures
3737
# > /dev/null --> output of all servers is mixed together and ugly
3838
# we get the individual logs at end
3939
#
40-
if [ -d "goroot" ]; then
41-
rm -rf goroot
42-
fi
4340
$DOCKERCOMPOSE up --no-color --build --abort-on-container-exit --exit-code-from mtest > /dev/null
4441

scripts/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
set -ex
44

5+
(cd ./scripts/test-golang117 && ./test.sh)
56
(cd ./scripts/test-golang118 && ./test.sh)
67
(cd ./scripts/test-golang119 && ./test.sh)

0 commit comments

Comments
 (0)