Skip to content

Commit

Permalink
add unit test pipeline and fix release artifact's semver (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
windycrypto authored Jun 15, 2023
1 parent 5f7c18c commit 3c7833c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Test and Lint"

on:
pull_request:
branches: [ main ]

workflow_dispatch:

jobs:
gotest-and-golint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50
only-new-issues: true
skip-pkg-cache: true
skip-build-cache: true

- name: Go-Test
run: |
timeout 300s go test --tags unittest ./...
5 changes: 3 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
app_id: ${{ secrets.RELEASE_APP_ID }}
private_key: ${{ secrets.RELEASE_APP_SECRECT }}

- name: Make binaries
run: |
go build
Expand All @@ -41,7 +41,7 @@ jobs:
echo "REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "ARCHIVE_FILE_NAME=derelay-$(git rev-parse --short HEAD)-linux-amd64" >> $GITHUB_ENV
echo "ARCHIVE_FILE_NAME=derelay-${GITHUB_REF/refs\/tags\//}-linux-amd64" >> $GITHUB_ENV
- name: Archive artifacts
run: |
Expand All @@ -55,6 +55,7 @@ jobs:
with:
name: derelay-artifact
path: $ARCHIVE_FILE_NAME.tar.gz

- name: Get release
id: get_release
uses: bruceadams/get-release@v1.2.3
Expand Down
15 changes: 10 additions & 5 deletions relay/wsconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestSendChanWithNoReceiver(t *testing.T) {
select {
case i := <-send:
fmt.Printf("received: %v\n", i)
if i == 5 {
if i == 3 {
fmt.Printf("receiving routine exit\n")
return
}
Expand All @@ -33,10 +33,15 @@ func TestSendChanWithNoReceiver(t *testing.T) {

i := 0
for {
send <- i
fmt.Printf("send: %v\n", i)
i++
time.Sleep(3 * time.Second)
select {
case send <- i:
fmt.Printf("send: %v\n", i)
i++
time.Sleep(1 * time.Second)
default:
fmt.Printf("send buffer is full\n")
return
}
}
}()

Expand Down

0 comments on commit 3c7833c

Please sign in to comment.