Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Go Testing Pipeline #142

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
branches: [main]

jobs:
test-server:
uses: ./.github/workflows/go-tests.yml
Copy link
Contributor

@niclasheun niclasheun Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dev.yml is the deployment workflow.
This shall be independent of the testing workflow and not depend on each other. So please change this back and let the testing be a separate workflow.

build-and-push-server:
needs: test-server
uses: ./.github/workflows/build-and-push-server.yml
secrets: inherit
build-and-push-clients:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Go Test

on:
pull_request:
branches: [main]
workflow_call:

jobs:
test:
Expand All @@ -21,10 +20,10 @@ jobs:
- name: Install dependencies
run: cd ${{ matrix.directory }} && go mod download
- name: Test with Go
run: cd ${{ matrix.directory }} && go test ./... -json > TestResults-${{ matrix.directory }}.json
run: cd ${{ matrix.directory }} && go test -race ./... -json > TestResults-${{ matrix.directory }}.json
Copy link
Contributor

@niclasheun niclasheun Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Updated Feedback - sorry)

I honestly do not see how the race flag actually resolve the root cause of the issue.
{"Time":"2025-02-03T10:54:40.078360835Z","Action":"output","Package":"github.com/niclasheun/prompt2.0/student","Test":"TestRouterTestSuite","Output":"2025/02/03 10:54:40 Failed to set up test database: failed to run SQL dump: failed to connect to user=testuser database=prompt:\n"}
{"Time":"2025-02-03T10:54:40.078401362Z","Action":"output","Package":"github.com/niclasheun/prompt2.0/student","Test":"TestRouterTestSuite","Output":"\t127.0.0.1:32780 (localhost): failed to receive message: unexpected EOF\n"}
{"Time":"2025-02-03T10:54:40.078410308Z","Action":"output","Package":"github.com/niclasheun/prompt2.0/student","Test":"TestRouterTestSuite","Output":"\t[::1]:32780 (localhost): failed to receive message: read tcp [::1]:42826-\u003e[::1]:32780: read: connection reset by peer\n"}

Hence, the issue is that Github cannot handle the amount of created test containers or that i.e. the timeout is set too short or something like that.

Race will only check the local storage of Go but not the connections of external containers. I assume it "fixes" the issue, because it introduces overhead and slows down the execution. But I do no see a reason how this actually resolves the root cause.

My Advice:

  • look into the creation of the test containers in server/testutils
  • refer to the test results file generated and uploaded by the workflow

- name: Upload Go test results
if: always()
uses: actions/upload-artifact@v4
with:
name: Go-results-${{ matrix.directory }}
path: ./${{ matrix.directory }}/TestResults-${{ matrix.directory }}.json
path: ./${{ matrix.directory }}/TestResults-${{ matrix.directory }}.json
Loading