From 0f8e230c9af20c587b10c1559694e1c653235896 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Fri, 28 Jun 2024 23:14:36 +0700 Subject: [PATCH 1/4] ci: only report coverage when running on origin repo --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9da8609..6627bbb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,13 +63,13 @@ jobs: - name: Run Go unit tests run: go test -v -race -timeout 3m -coverprofile=coverage.out ./... - name: Go coverage format - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' && github.repository == 'hasura/go-graphql-client' }} run: | go get github.com/boumenot/gocover-cobertura go install github.com/boumenot/gocover-cobertura gocover-cobertura < coverage.out > coverage.xml - name: Code Coverage Summary Report - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' && github.repository == 'hasura/go-graphql-client' }} uses: irongut/CodeCoverageSummary@v1.3.0 with: filename: coverage.xml @@ -83,7 +83,7 @@ jobs: thresholds: "60 80" - name: Add Coverage PR Comment uses: marocchino/sticky-pull-request-comment@v2 - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' && github.repository == 'hasura/go-graphql-client' }} with: path: code-coverage-results.md - name: Dump docker logs on failure From 16f3bea320d4e2572c7f0c9a71748e6184d6f60d Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Fri, 28 Jun 2024 23:18:27 +0700 Subject: [PATCH 2/4] fix security reports --- .../graphql-ws-bc/server/package-lock.json | 38 +++++++++---------- example/graphql-ws-bc/server/package.json | 8 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/example/graphql-ws-bc/server/package-lock.json b/example/graphql-ws-bc/server/package-lock.json index ce9c413..e5e8253 100644 --- a/example/graphql-ws-bc/server/package-lock.json +++ b/example/graphql-ws-bc/server/package-lock.json @@ -9,15 +9,15 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "graphql": "^16.8.1", - "graphql-ws": "^5.14.3", + "graphql": "^16.9.0", + "graphql-ws": "^5.16.0", "subscriptions-transport-ws": "^0.11.0", - "ws": "^8.16.0" + "ws": "^8.17.1" }, "devDependencies": { "@types/ws": "^8.5.10", "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "typescript": "^5.5.2" } }, "node_modules/@cspotcode/source-map-support": { @@ -152,17 +152,17 @@ "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==" }, "node_modules/graphql": { - "version": "16.8.1", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz", - "integrity": "sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==", + "version": "16.9.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", + "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } }, "node_modules/graphql-ws": { - "version": "5.14.3", - "resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.14.3.tgz", - "integrity": "sha512-F/i2xNIVbaEF2xWggID0X/UZQa2V8kqKDPO8hwmu53bVOcTL7uNkxnexeEgSCVxYBQUTUNEI8+e4LO1FOhKPKQ==", + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.16.0.tgz", + "integrity": "sha512-Ju2RCU2dQMgSKtArPbEtsK5gNLnsQyTNIo/T7cZNp96niC1x0KdJNZV0TIoilceBPQwfb5itrGl8pkFeOUMl4A==", "engines": { "node": ">=10" }, @@ -198,9 +198,9 @@ } }, "node_modules/subscriptions-transport-ws/node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "engines": { "node": ">=8.3.0" }, @@ -269,9 +269,9 @@ } }, "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", + "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -294,9 +294,9 @@ "dev": true }, "node_modules/ws": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", - "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, diff --git a/example/graphql-ws-bc/server/package.json b/example/graphql-ws-bc/server/package.json index 827fa39..fb222ab 100644 --- a/example/graphql-ws-bc/server/package.json +++ b/example/graphql-ws-bc/server/package.json @@ -8,14 +8,14 @@ }, "license": "MIT", "dependencies": { - "graphql": "^16.8.1", - "graphql-ws": "^5.14.3", + "graphql": "^16.9.0", + "graphql-ws": "^5.16.0", "subscriptions-transport-ws": "^0.11.0", - "ws": "^8.16.0" + "ws": "^8.17.1" }, "devDependencies": { "@types/ws": "^8.5.10", "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "typescript": "^5.5.2" } } From 6a807b8d7397d98e72cf70ccc3daba270c86bb62 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Fri, 28 Jun 2024 23:46:42 +0700 Subject: [PATCH 3/4] fix race condition --- example/subscription/subscription_test.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/example/subscription/subscription_test.go b/example/subscription/subscription_test.go index be3a6e8..1bf65cf 100644 --- a/example/subscription/subscription_test.go +++ b/example/subscription/subscription_test.go @@ -8,6 +8,7 @@ import ( "log" "net/http" "sync" + "sync/atomic" "testing" "time" @@ -370,8 +371,7 @@ func testSubscription_LifeCycleEvents(t *testing.T, syncMode bool) { var lock sync.Mutex subscriptionResults := []gql.Subscription{} - wasConnected := false - wasDisconnected := false + var wasConnected, wasDisconnected int32 addResult := func(s gql.Subscription) int { lock.Lock() defer lock.Unlock() @@ -436,20 +436,16 @@ func testSubscription_LifeCycleEvents(t *testing.T, syncMode bool) { WithTimeout(3 * time.Second). WithSyncMode(syncMode). OnConnected(func() { - lock.Lock() - defer lock.Unlock() log.Println("connected") - wasConnected = true + atomic.StoreInt32(&wasConnected, 1) }). OnError(func(sc *gql.SubscriptionClient, err error) error { t.Fatalf("got error: %v, want: nil", err) return err }). OnDisconnected(func() { - lock.Lock() - defer lock.Unlock() log.Println("disconnected") - wasDisconnected = true + atomic.StoreInt32(&wasDisconnected, 1) }). OnSubscriptionComplete(func(s gql.Subscription) { log.Println("OnSubscriptionComplete: ", s) @@ -542,10 +538,10 @@ func testSubscription_LifeCycleEvents(t *testing.T, syncMode bool) { } } - if !wasConnected { + if atomic.LoadInt32(&wasConnected) != 1 { t.Fatalf("expected OnConnected event, got none") } - if !wasDisconnected { + if atomic.LoadInt32(&wasDisconnected) != 1 { t.Fatalf("expected OnDisconnected event, got none") } } From a8f24f85c18f9ee08be0a6091fc4c975a026b733 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Fri, 28 Jun 2024 23:54:26 +0700 Subject: [PATCH 4/4] remove unused step --- .github/workflows/test.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6627bbb..526b6f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,14 +26,6 @@ jobs: - uses: actions/setup-go@v5 with: go-version: "1.20" - - uses: actions/cache@v4 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - name: Install dependencies run: | go get -t -v ./... @@ -52,8 +44,6 @@ jobs: version: latest only-new-issues: true skip-cache: true - skip-pkg-cache: true - skip-build-cache: true args: --timeout=120s - name: Run Go unit tests for example/subscription run: |