Skip to content

Commit 5a8b2ec

Browse files
authored
ci: skip reporting coverage from forked repositories (#145)
* ci: skip reporting coverage from forked repositories
1 parent 132b131 commit 5a8b2ec

File tree

4 files changed

+32
-46
lines changed

4 files changed

+32
-46
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ jobs:
2626
- uses: actions/setup-go@v5
2727
with:
2828
go-version: "1.20"
29-
- uses: actions/cache@v4
30-
with:
31-
path: |
32-
~/go/pkg/mod
33-
~/.cache/go-build
34-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
35-
restore-keys: |
36-
${{ runner.os }}-go-
3729
- name: Install dependencies
3830
run: |
3931
go get -t -v ./...
@@ -52,8 +44,6 @@ jobs:
5244
version: latest
5345
only-new-issues: true
5446
skip-cache: true
55-
skip-pkg-cache: true
56-
skip-build-cache: true
5747
args: --timeout=120s
5848
- name: Run Go unit tests for example/subscription
5949
run: |
@@ -63,13 +53,13 @@ jobs:
6353
- name: Run Go unit tests
6454
run: go test -v -race -timeout 3m -coverprofile=coverage.out ./...
6555
- name: Go coverage format
66-
if: ${{ github.event_name == 'pull_request' }}
56+
if: ${{ github.event_name == 'pull_request' && github.repository == 'hasura/go-graphql-client' }}
6757
run: |
6858
go get github.com/boumenot/gocover-cobertura
6959
go install github.com/boumenot/gocover-cobertura
7060
gocover-cobertura < coverage.out > coverage.xml
7161
- name: Code Coverage Summary Report
72-
if: ${{ github.event_name == 'pull_request' }}
62+
if: ${{ github.event_name == 'pull_request' && github.repository == 'hasura/go-graphql-client' }}
7363
uses: irongut/[email protected]
7464
with:
7565
filename: coverage.xml
@@ -83,7 +73,7 @@ jobs:
8373
thresholds: "60 80"
8474
- name: Add Coverage PR Comment
8575
uses: marocchino/sticky-pull-request-comment@v2
86-
if: ${{ github.event_name == 'pull_request' }}
76+
if: ${{ github.event_name == 'pull_request' && github.repository == 'hasura/go-graphql-client' }}
8777
with:
8878
path: code-coverage-results.md
8979
- name: Dump docker logs on failure

example/graphql-ws-bc/server/package-lock.json

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/graphql-ws-bc/server/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
},
99
"license": "MIT",
1010
"dependencies": {
11-
"graphql": "^16.8.1",
12-
"graphql-ws": "^5.14.3",
11+
"graphql": "^16.9.0",
12+
"graphql-ws": "^5.16.0",
1313
"subscriptions-transport-ws": "^0.11.0",
14-
"ws": "^8.16.0"
14+
"ws": "^8.17.1"
1515
},
1616
"devDependencies": {
1717
"@types/ws": "^8.5.10",
1818
"ts-node": "^10.9.2",
19-
"typescript": "^5.3.3"
19+
"typescript": "^5.5.2"
2020
}
2121
}

example/subscription/subscription_test.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"log"
99
"net/http"
1010
"sync"
11+
"sync/atomic"
1112
"testing"
1213
"time"
1314

@@ -370,8 +371,7 @@ func testSubscription_LifeCycleEvents(t *testing.T, syncMode bool) {
370371

371372
var lock sync.Mutex
372373
subscriptionResults := []gql.Subscription{}
373-
wasConnected := false
374-
wasDisconnected := false
374+
var wasConnected, wasDisconnected int32
375375
addResult := func(s gql.Subscription) int {
376376
lock.Lock()
377377
defer lock.Unlock()
@@ -436,20 +436,16 @@ func testSubscription_LifeCycleEvents(t *testing.T, syncMode bool) {
436436
WithTimeout(3 * time.Second).
437437
WithSyncMode(syncMode).
438438
OnConnected(func() {
439-
lock.Lock()
440-
defer lock.Unlock()
441439
log.Println("connected")
442-
wasConnected = true
440+
atomic.StoreInt32(&wasConnected, 1)
443441
}).
444442
OnError(func(sc *gql.SubscriptionClient, err error) error {
445443
t.Fatalf("got error: %v, want: nil", err)
446444
return err
447445
}).
448446
OnDisconnected(func() {
449-
lock.Lock()
450-
defer lock.Unlock()
451447
log.Println("disconnected")
452-
wasDisconnected = true
448+
atomic.StoreInt32(&wasDisconnected, 1)
453449
}).
454450
OnSubscriptionComplete(func(s gql.Subscription) {
455451
log.Println("OnSubscriptionComplete: ", s)
@@ -542,10 +538,10 @@ func testSubscription_LifeCycleEvents(t *testing.T, syncMode bool) {
542538
}
543539
}
544540

545-
if !wasConnected {
541+
if atomic.LoadInt32(&wasConnected) != 1 {
546542
t.Fatalf("expected OnConnected event, got none")
547543
}
548-
if !wasDisconnected {
544+
if atomic.LoadInt32(&wasDisconnected) != 1 {
549545
t.Fatalf("expected OnDisconnected event, got none")
550546
}
551547
}

0 commit comments

Comments
 (0)