Skip to content

ci: run go tests in ci #4

ci: run go tests in ci

ci: run go tests in ci #4

Workflow file for this run

name: Tests
on:
push:
branches:
- "*"
jobs:
HTTP-Tests:
runs-on: ubuntu-latest
services:
db:
image: postgres:16
env:
POSTGRES_PASSWORD: "changeme"
POSTGRES_USER: "godrink"
POSTGRES_DB: "godrink"
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Go
uses: actions/[email protected]
- name: Install dependencies
run: go get .
- name: Run Go-Drink
env:
GODRINK_DB: postgresql://godrink:changeme@localhost:5432/godrink?sslmode=disable
run: "go run . &"
- name: Execute HTTP requests
run: ./http-test/test.sh
timeout-minutes: 3
- name: Upload Test results
if: success() || failure() # always run even if the previous step fails
uses: actions/[email protected]
with:
name: HTTP Test Report
path: ./test-reports/report.xml
Go-Tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Go
uses: actions/[email protected]
- name: Install dependencies
run: go get .
- name: Test with Go
run: go test -json ./... > TestResults.json
- name: Upload Go test results
if: success() || failure() # always run even if the previous step fails
uses: actions/upload-artifact@v4
with:
name: Go Test Result
path: TestResults.json
- name: Convert GoTest JSON to JUnit XML
uses: pl-strflt/gotest-json-to-junit-xml@v1
with:
input: TestResults.json
output: test-reports/TestResults-JUnit.xml
- name: Upload Go test JUnit report
uses: actions/upload-artifact@v4
with:
name: Go Test Report
path: test-reports/TestResults-JUnit.xml
Report:
needs:
- Go-Tests
- HTTP-Tests
if: always()
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
checks: write
steps:
- name: Download Http-Test-Report
uses: actions/download-artifact@v4
with:
pattern: "*Test Report*"
path: test-reports
merge-multiple: true
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
with:
detailed_summary: true
include_passed: true
require_passed_tests: true
update_check: true
report_paths: "test-reports/*.xml"