From 1148dffa377e4b3eba6b30c49e22b31a79c616f6 Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 8 Aug 2024 19:56:00 +0200 Subject: [PATCH] ci: try merging github actions for testing --- .github/workflows/go-test.yml | 46 --------------- .github/workflows/http-test.yml | 50 ---------------- .github/workflows/test.yml | 101 ++++++++++++++++++++++++++++++++ http-test/test.sh | 2 +- 4 files changed, 102 insertions(+), 97 deletions(-) delete mode 100644 .github/workflows/go-test.yml delete mode 100644 .github/workflows/http-test.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml deleted file mode 100644 index 6f3931c..0000000 --- a/.github/workflows/go-test.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Go-Tests -on: - push: - branches: - - "*" - -jobs: - Go-Tests: - permissions: - contents: read - actions: read - checks: write - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4.1.7 - - name: Setup Go - uses: actions/setup-go@v5.0.2 - - 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-Results - path: TestResults.json - - name: Convert GoTest JSON to JUnit XML - uses: pl-strflt/gotest-json-to-junit-xml@v1 - with: - input: TestResults.json - output: TestResults-JUnit.xml - - 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: TestResults-JUnit.xml - - name: Upload Go test JUnit report - uses: actions/upload-artifact@v4 - with: - name: Go-Test-JUnit-Report - path: TestResults-JUnit.xml diff --git a/.github/workflows/http-test.yml b/.github/workflows/http-test.yml deleted file mode 100644 index 6c01161..0000000 --- a/.github/workflows/http-test.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: HTTP-Tests -on: - push: - branches: - - "*" - -jobs: - HTTP-Tests: - permissions: - contents: read - actions: read - checks: write - 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/checkout@v4.1.7 - - name: Setup Go - uses: actions/setup-go@v5.0.2 - - 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: Publish Test Report - uses: mikepenz/action-junit-report@v4 - if: success() || failure() # always run even if the previous step fails - with: - detailed_summary: true - include_passed: true - require_passed_tests: true - update_check: true - report_paths: ./http-test-reports/report.xml - - name: Upload Test results - uses: actions/upload-artifact@v4.3.4 - with: - name: http-test-reports - path: ./http-test-reports/report.xml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..86985dd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,101 @@ +name: Tests +on: + push: + branches: + - "*" + +jobs: + Build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.7 + - name: Setup Go + uses: actions/setup-go@v5.0.2 + - 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/checkout@v4.1.7 + - name: Setup Go + uses: actions/setup-go@v5.0.2 + - 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/upload-artifact@v4.3.4 + with: + name: HTTP Test Report + path: ./test-reports/report.xml + Go-Tests: + needs: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.7 + - name: Setup Go + uses: actions/setup-go@v5.0.2 + - 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" diff --git a/http-test/test.sh b/http-test/test.sh index 5bc7ba8..ea47152 100755 --- a/http-test/test.sh +++ b/http-test/test.sh @@ -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