Set up basic pipeline for testing and building the application

This commit is contained in:
2020-03-01 18:06:39 +11:00
parent de96e65bef
commit 74678ff376
7 changed files with 86 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
name: Docker Image CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Unit test
run: auto/test
- name: Build the Docker image
run: auto/build
+25
View File
@@ -0,0 +1,25 @@
FROM golang:1.13-alpine3.10 AS build
RUN apk add --no-cache git openssh
ENV GOOS=linux
ENV GOARCH=amd64
WORKDIR /app/zendesk
COPY . .
RUN go mod download
RUN go build -o bin/app main.go
FROM alpine:3.10
RUN adduser -D -u 1000 zendesk
WORKDIR /home/zendesk
USER zendesk
COPY --from=build /app/zendesk/bin/app .
CMD [ "/home/zendesk/app" ]
Executable
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash -eu
cd $(dirname $0)/..
VERSION=1.0.${GITHUB_RUN_NUMBER-1}
docker build . --file Dockerfile --tag junwei-zhao/zendesk:${VERSION}
Executable
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash -eu
cd $(dirname $0)/..
docker-compose run --rm app go test ./... -cover
+11
View File
@@ -0,0 +1,11 @@
version: "3"
services:
app:
image: golang:1.13
working_dir: /app/zendesk
volumes:
- .:/app/zendesk
- go-libs:/go/pkg
command: ["sh", "-c", "go run main.go"]
volumes:
go-libs: {}
+7
View File
@@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("I am placeholder of application")
}
+16
View File
@@ -3,12 +3,28 @@ package search
import (
"encoding/json"
"fmt"
"io/ioutil"
"github.com/wahyd4/zendesk/model"
"github.com/wahyd4/zendesk/view"
)
// type dataHandler func(jsonContent []byte) error
func (app *APP) Parse(jsonFiles []string) error {
// dataHandlers := map[string]dataHandler{
// "organisations": app.LoadOrganisationsFromJSON,
// "users": app.LoadUsersFromJSON,
// "tickets": app.LoadTicketsFromJSON,
// }
for _, file := range jsonFiles {
_, err := ioutil.ReadFile(file)
if err != nil {
return fmt.Errorf("failed to read %s data file with error: %s", file, err.Error())
}
}
return nil
}