Skip to content

Commit

Permalink
ci: skip reporting coverage from forked repositories (#145)
Browse files Browse the repository at this point in the history
* ci: skip reporting coverage from forked repositories
  • Loading branch information
hgiasac authored Jun 28, 2024
1 parent 132b131 commit 5a8b2ec
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 46 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand All @@ -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: |
Expand All @@ -63,13 +53,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/[email protected]
with:
filename: coverage.xml
Expand All @@ -83,7 +73,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
Expand Down
38 changes: 19 additions & 19 deletions example/graphql-ws-bc/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions example/graphql-ws-bc/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
16 changes: 6 additions & 10 deletions example/subscription/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"net/http"
"sync"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
}
}
Expand Down

0 comments on commit 5a8b2ec

Please sign in to comment.