Skip to content

Commit

Permalink
ci: try merging github actions for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hpr1999 committed Aug 8, 2024
1 parent ac80577 commit 1148dff
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 97 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/go-test.yml

This file was deleted.

50 changes: 0 additions & 50 deletions .github/workflows/http-test.yml

This file was deleted.

101 changes: 101 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Tests
on:
push:
branches:
- "*"

jobs:
Build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Go
uses: actions/[email protected]
- name: Install dependencies
run: go get .
HTTP-Tests:
runs-on: ubuntu-latest
needs: Build
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: 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:
needs: Build
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"
2 changes: 1 addition & 1 deletion http-test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ while
do echo Waiting for Go Drink; sleep 1; done
set -e

docker run --network="host" --rm -v $PWD:/workdir jetbrains/intellij-http-client -e dev -v http-test/http-client.env.json -r http-test-reports http-test/*.http
docker run --network="host" --rm -v $PWD:/workdir jetbrains/intellij-http-client -e dev -v http-test/http-client.env.json -r test-reports http-test/*.http

0 comments on commit 1148dff

Please sign in to comment.