Skip to content

Commit

Permalink
Add backend test based on docker-compose to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rettetdemdativ committed Apr 16, 2024
1 parent 08dc5d3 commit 86d3f4a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
25 changes: 11 additions & 14 deletions .github/workflows/backend_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ jobs:
defaults:
run:
working-directory: backend
strategy:
matrix:
go-version: [ '1.22.x' ]

timeout-minutes: 2
steps:
- uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Install dependencies
run: go get .
- name: Build
run: go build -v ./...
- name: Test with the Go CLI
run: go test
- name: make test
run: make backend-test
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: ./test-results/*.xml
- name: Teardown
run: make down

11 changes: 11 additions & 0 deletions backend/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.22.2-alpine3.18

WORKDIR /opt/backend

COPY . .

RUN go get

RUN go install github.com/jstemmer/go-junit-report/v2@latest

ENTRYPOINT go test -v 2>&1 ./... | go-junit-report -set-exit-code > ./test-results/report.xml
7 changes: 7 additions & 0 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ build:
build-windows:
GOOS=windows GOARCH=amd64 go build -o bin/handler.exe handler.go

.PHONY:
backend-test:
docker-compose -f docker-compose.yml run backend-test

down:
docker-compose down --remove-orphans

all: build build-windows
11 changes: 11 additions & 0 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "2"

services:
backend-test:
build:
context: .
dockerfile: Dockerfile.test
container_name: backend-test
volumes:
- ./test-results:/opt/backend/test-results

0 comments on commit 86d3f4a

Please sign in to comment.