Skip to content

Commit

Permalink
Migrate to GH actions (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia authored Jan 20, 2021
1 parent 831ac26 commit 72c2fb5
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 75 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: release
on:
push:
tags:
- '*'
jobs:
release:
name: Release with Go ${{ matrix.go-version }}
environment: release
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.15.7]
steps:
- name: Install rpm
run: sudo apt-get install rpm

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2

- name: Install gox
run: GO111MODULE=off go get github.com/mitchellh/gox

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Release on Github
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist --release-notes=misc/release/notes.md
env:
# note custom secret here since we need access to Centrifugo Homebrew repo.
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Release on Packagecloud
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
run: misc/scripts/release_packagecloud.sh
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: test
on: [push, pull_request]
jobs:
golangci:
name: Lint
runs-on: ubuntu-latest
# Prevent duplicate builds on internal PRs.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.29
test:
name: Test with Go ${{ matrix.go-version }}
runs-on: ubuntu-latest
# Prevent duplicate builds on internal PRs.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
go-version: [1.15]
steps:
- name: Install Go stable version
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2

- name: Install cover
run: GO111MODULE=off go get golang.org/x/tools/cmd/cover

- name: Test
run: make test
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ release:
prerelease: false
brews:
-
github:
tap:
owner: centrifugal
name: homebrew-centrifugo
folder: Formula
Expand Down Expand Up @@ -73,7 +73,7 @@ signs:
artifacts: none
dockers:
-
binaries:
ids:
- centrifugo
goos: linux
goarch: amd64
Expand Down
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,3 @@ local-deps:

build:
CGO_ENABLED=0 go build -mod=vendor

ci: deps test
12 changes: 3 additions & 9 deletions internal/api/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ func GetCommandDecoder(enc Encoding, data []byte) CommandDecoder {
}

// PutCommandDecoder ...
func PutCommandDecoder(_ Encoding, _ CommandDecoder) {
return
}
func PutCommandDecoder(_ Encoding, _ CommandDecoder) {}

// GetDecoder ...
func GetDecoder(enc Encoding) Decoder {
Expand All @@ -67,9 +65,7 @@ func GetDecoder(enc Encoding) Decoder {
}

// PutDecoder ...
func PutDecoder(_ Encoding, _ Decoder) {
return
}
func PutDecoder(_ Encoding, _ Decoder) {}

// GetEncoder ...
func GetEncoder(enc Encoding) Encoder {
Expand All @@ -80,6 +76,4 @@ func GetEncoder(enc Encoding) Encoder {
}

// PutEncoder ...
func PutEncoder(_ Encoding, _ Encoder) {
return
}
func PutEncoder(_ Encoding, _ Encoder) {}
1 change: 0 additions & 1 deletion internal/api/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func (r Raw) MarshalTo(data []byte) (n int, err error) {
// Unmarshal exists to fit gogoprotobuf custom type interface.
func (r *Raw) Unmarshal(data []byte) error {
if len(data) == 0 {
r = nil
return nil
}
id := Raw(make([]byte, len(data)))
Expand Down
8 changes: 0 additions & 8 deletions internal/client/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ func newTestTransport() *testTransport {
}
}

func (t *testTransport) setProtocolType(pType centrifuge.ProtocolType) {
t.protoType = pType
}

func (t *testTransport) setSink(sink chan []byte) {
t.sink = sink
}

func (t *testTransport) Write(data []byte) error {
t.mu.Lock()
defer t.mu.Unlock()
Expand Down
1 change: 0 additions & 1 deletion internal/health/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type Config struct{}

// Handler handles health endpoint.
type Handler struct {
mux *http.ServeMux
node *centrifuge.Node
config Config
}
Expand Down
5 changes: 3 additions & 2 deletions internal/jwks/cache_ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ func (tc *TTLCache) run() {
d = time.Second
}

ticker := time.Tick(d)
ticker := time.NewTicker(d)
go func() {
for {
select {
case <-ticker:
case <-ticker.C:
tc.cleanup()
case <-tc.stop:
ticker.Stop()
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/middleware/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func LogRequest(h http.Handler) http.Handler {
} else {
h.ServeHTTP(w, r)
}
return
})
}

Expand Down Expand Up @@ -69,5 +68,6 @@ func (lrw *logResponseWriter) Flush() {

// CloseNotify as SockJS uses http.CloseNotifier.
func (lrw *logResponseWriter) CloseNotify() <-chan bool {
//nolint:staticcheck
return lrw.ResponseWriter.(http.CloseNotifier).CloseNotify()
}
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ func handleSignals(configFile string, n *centrifuge.Node, ruleContainer *rule.Co
}()
}

ctx, _ := context.WithTimeout(context.Background(), shutdownTimeout)
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)

for _, srv := range httpServers {
wg.Add(1)
Expand All @@ -749,6 +749,7 @@ func handleSignals(configFile string, n *centrifuge.Node, ruleContainer *rule.Co
_ = n.Shutdown(ctx)

wg.Wait()
cancel()

if pidFile != "" {
_ = os.Remove(pidFile)
Expand Down
7 changes: 7 additions & 0 deletions misc/scripts/release_packagecloud.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
sudo gem install rake
sudo gem install package_cloud
sudo gem install fpm
sudo apt-get install -y rpm
make package
make packagecloud
6 changes: 0 additions & 6 deletions misc/scripts/travis_packagecloud.sh

This file was deleted.

0 comments on commit 72c2fb5

Please sign in to comment.