mirror of
https://github.com/wahyd4/zendesk.git
synced 2026-08-08 21:02:44 +10:00
Set up basic pipeline for testing and building the application
This commit is contained in:
@@ -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
@@ -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
@@ -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}
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
docker-compose run --rm app go test ./... -cover
|
||||
@@ -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: {}
|
||||
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("I am placeholder of application")
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user