From c5415206e6ba4a6d1dcb5e48dcc1f4bc615c0caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Budnik?= Date: Sun, 8 Jan 2023 20:33:08 +0100 Subject: [PATCH 1/2] upgraded docker containers for golang and alpine, added simple integration test --- .github/workflows/docker-image.yml | 15 ++++++++++++++- .github/workflows/go.yml | 2 +- Dockerfile | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 300e8d4..2708f2e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,4 +9,17 @@ jobs: steps: - uses: actions/checkout@v3.3.0 - name: Build the Docker image - run: docker build . --file Dockerfile --tag yosoy-local:$(date +%s) + run: docker build . --file Dockerfile --tag yosoy-local:latest + - name: Run simple integration test + run: | + docker run -p 3333:80 yosoy-local:latest > yosoy.log & + sleep 5 + RESULT=$(curl -s -X DELETE -H 'x-api-key: abc123' 'http://0.0.0.0:3333/sample/path?with=params') + echo "$RESULT" + if [[ $RESULT =~ '"method":"DELETE"' ]] + echo 'Test successful' + exit 0 + else + echo 'Test failure' + exit 1 + endif diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c4cb67b..9031c5c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,7 +11,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.16 + go-version: 1.19 - name: Build run: go build -v ./... diff --git a/Dockerfile b/Dockerfile index 944187a..edcdf10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.3-alpine3.13 as builder +FROM golang:1.19-alpine as builder LABEL maintainer="Łukasz Budnik lukasz.budnik@gmail.com" @@ -6,7 +6,7 @@ LABEL maintainer="Łukasz Budnik lukasz.budnik@gmail.com" ADD . /go/yosoy RUN cd /go/yosoy && go build -FROM alpine:3.16.2 +FROM alpine:3.17 COPY --from=builder /go/yosoy/yosoy /bin # register entrypoint From 196306d1314091b90abd159a774976e18a676dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Budnik?= Date: Sun, 8 Jan 2023 20:36:31 +0100 Subject: [PATCH 2/2] correct bash if-then-else syntax --- .github/workflows/docker-image.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 2708f2e..8c6525e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -17,9 +17,10 @@ jobs: RESULT=$(curl -s -X DELETE -H 'x-api-key: abc123' 'http://0.0.0.0:3333/sample/path?with=params') echo "$RESULT" if [[ $RESULT =~ '"method":"DELETE"' ]] + then echo 'Test successful' exit 0 else echo 'Test failure' exit 1 - endif + fi