Skip to content

Commit 9760a61

Browse files
committed
(test) setup
1 parent da719c9 commit 9760a61

13 files changed

Lines changed: 118 additions & 10 deletions

File tree

.circleci/config.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Golang CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-go/ for more details
4+
version: 2
5+
jobs:
6+
build:
7+
docker:
8+
# specify the version
9+
- image: circleci/golang:1.9
10+
11+
# Specify service dependencies here if necessary
12+
# CircleCI maintains a library of pre-built images
13+
# documented at https://circleci.com/docs/2.0/circleci-images/
14+
# - image: circleci/postgres:9.4
15+
16+
#### TEMPLATE_NOTE: go expects specific checkout path representing url
17+
#### expecting it in the form of
18+
#### /go/src/github.com/circleci/go-tool
19+
#### /go/src/bitbucket.org/circleci/go-tool
20+
working_directory: /go/src/github.com/AkselsLedins/google-hashcode-2018-live-simulation
21+
steps:
22+
- checkout
23+
24+
# specify any bash command here prefixed with `run: `
25+
- run: sudo apt-get install libgl1-mesa-dev xorg-dev
26+
- run: make deps
27+
- run: make build
28+
- run: bash test/score-a.sh
29+
- run: bash test/score-b.sh
30+
- run: bash test/score-c.sh
31+
- run: bash test/score-d.sh
32+
- run: bash test/score-e.sh

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ insert_final_newline = true
99
end_of_line = lf
1010
# editorconfig-tools is unable to ignore longs strings or urls
1111
max_line_length = null
12+
13+
[{Makefile,**.mk}]
14+
# Use tabs for indentation (Makefiles require tabs)
15+
indent_style = tab

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Go parameters
2+
GOCMD=go
3+
GOBUILD=$(GOCMD) build
4+
GOCLEAN=$(GOCMD) clean
5+
GOTEST=$(GOCMD) test
6+
GOGET=$(GOCMD) get
7+
BINARY_NAME=google-hashcode-2018
8+
BINARY_UNIX=$(BINARY_NAME)_unix
9+
10+
all: build
11+
build:
12+
$(GOBUILD) -o $(BINARY_NAME) -v
13+
clean:
14+
$(GOCLEAN)
15+
rm -f $(BINARY_NAME)
16+
rm -f $(BINARY_UNIX)
17+
run:
18+
$(GOBUILD) -o $(BINARY_NAME) -v ./...
19+
./$(BINARY_NAME)
20+
deps:
21+
$(GOGET) github.com/faiface/glhf
22+
$(GOGET) github.com/faiface/pixel
23+
$(GOGET) github.com/go-gl/glfw/v3.2/glfw
24+
25+
26+
# Cross compilation
27+
build-linux:
28+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v
29+
# docker-build:
30+
# docker run --rm -it -v "$(GOPATH)":/go -w /go/src/bitbucket.org/rsohlich/makepost golang:latest go build -o "$(BINARY_UNIX)" -v

ghashcode/trip.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import (
44
"image/color"
55
"math"
66

7-
"golang.org/x/image/colornames"
8-
9-
config "../config"
7+
config "github.com/AkselsLedins/google-hashcode-2018-live-simulation/config"
108

119
"github.com/faiface/pixel"
1210
"github.com/faiface/pixel/imdraw"
11+
"golang.org/x/image/colornames"
1312
)
1413

1514
// Trip a structure which represents a trip in the simulation

ghashcode/vehicle.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package ghashcode
33
import (
44
"math"
55

6-
config "../config"
6+
config "github.com/AkselsLedins/google-hashcode-2018-live-simulation/config"
7+
78
"github.com/faiface/pixel"
89
"github.com/faiface/pixel/imdraw"
910
)

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"math"
77
"time"
88

9-
config "./config"
10-
simulator "./simulator"
11-
ui "./ui"
9+
config "github.com/AkselsLedins/google-hashcode-2018-live-simulation/config"
10+
simulator "github.com/AkselsLedins/google-hashcode-2018-live-simulation/simulator"
11+
ui "github.com/AkselsLedins/google-hashcode-2018-live-simulation/ui"
1212

1313
"github.com/faiface/pixel"
1414
"github.com/faiface/pixel/imdraw"
@@ -118,7 +118,7 @@ func noGui() {
118118
for !simulation.Ended {
119119
simulation.Run(nil)
120120
}
121-
fmt.Printf("Score: %d in %d steps\n", simulation.Score, simulation.Step)
121+
fmt.Printf("%d\n", simulation.Score)
122122
}
123123

124124
func main() {

simulator/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strconv"
99
"strings"
1010

11-
ghashcode "../ghashcode"
11+
ghashcode "github.com/AkselsLedins/google-hashcode-2018-live-simulation/ghashcode"
1212
)
1313

1414
// ParseOutputFile it parse the file that your program has created

simulator/simulation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package simulator
22

33
import (
4-
ghashcode "../ghashcode"
4+
ghashcode "github.com/AkselsLedins/google-hashcode-2018-live-simulation/ghashcode"
55

66
"github.com/faiface/pixel/imdraw"
77
)

test/score-a.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
result=$(go run main.go -o resources/output-files/a.out -i resources/input-files/a_example.in -noGui)
2+
echo "A) result " $result
3+
if [ $result == 10 ]; then
4+
echo "Good :)"
5+
exit 0
6+
fi
7+
echo "Bad :)"
8+
exit 1

test/score-b.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
result=$(go run main.go -o resources/output-files/b.out -i resources/input-files/b_should_be_easy.in -noGui)
2+
echo "B) result " $result
3+
if [ $result == 171231 ]; then
4+
echo "Good :)"
5+
exit 0
6+
fi
7+
echo "Bad :)"
8+
exit 1

0 commit comments

Comments
 (0)