Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Remove travis support
Browse files Browse the repository at this point in the history
Add GHA
  • Loading branch information
rustatian committed Feb 3, 2021
1 parent 02f1ff5 commit a232fd3
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 56 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: gomod # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: daily

85 changes: 85 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Linux

on:
push:
pull_request:
branches:
# Branches from forks have the form 'user:branch-name' so we only run
# this job on pull_request events for branches that look like fork
# branches. Without this we would end up running this job twice for non
# forked PRs, once for the push and then once for opening the PR.
- "**:**"

jobs:
golang:
name: Build (Go ${{ matrix.go }}, PHP ${{ matrix.php }}, OS ${{matrix.os}})
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
php: [ "7.2","7.3", "7.4", "8.0" ]
go: [ "1.14", "1.15" ]
os: [ ubuntu-20.04 ]
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v2 # action page: <https://github.com/actions/setup-go>
with:
go-version: ${{ matrix.go }}

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2 # action page: <https://github.com/shivammathur/setup-php>
with:
php-version: ${{ matrix.php }}
extensions: sockets

- name: Check out code
uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Init Composer Cache # Docs: <https://git.io/JfAKn#php---composer>
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer update --prefer-dist --no-progress --ansi

- name: Init Go modules Cache # Docs: <https://git.io/JfAKn#go---modules>
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-

- name: Install Go dependencies
run: go mod download

- name: Run golang tests on Linux
run: |
mkdir ./coverage-ci
go test -v -race -cover -coverpkg=./... -coverprofile=./coverage-ci/broadcast-ws.txt -covermode=atomic
- uses: codecov/codecov-action@v1 # Docs: <https://github.com/codecov/codecov-action>
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage-ci/broadcast-ws.txt
fail_ci_if_error: false

golangci-lint:
name: Golang-CI (lint)
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Run linter
uses: golangci/golangci-lint-action@v2 # Action page: <https://github.com/golangci/golangci-lint-action>
with:
version: v1.35 # without patch version
only-new-issues: false # show only new issues if it's a pull request
66 changes: 66 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: macOS

on:
push:
pull_request:
branches:
# Branches from forks have the form 'user:branch-name' so we only run
# this job on pull_request events for branches that look like fork
# branches. Without this we would end up running this job twice for non
# forked PRs, once for the push and then once for opening the PR.
- "**:**"

jobs:
golang:
name: Build (Go ${{ matrix.go }}, PHP ${{ matrix.php }}, OS ${{matrix.os}})
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
php: [ "7.2","7.3", "7.4", "8.0" ]
go: [ "1.14", "1.15" ]
os: [ macos-latest ]
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v2 # action page: <https://github.com/actions/setup-go>
with:
go-version: ${{ matrix.go }}

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2 # action page: <https://github.com/shivammathur/setup-php>
with:
php-version: ${{ matrix.php }}
extensions: sockets

- name: Check out code
uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Init Composer Cache # Docs: <https://git.io/JfAKn#php---composer>
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer update --prefer-dist --no-progress --ansi

- name: Init Go modules Cache # Docs: <https://git.io/JfAKn#go---modules>
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-

- name: Install Go dependencies
run: go mod download

- name: Run golang tests
run: |
mkdir ./coverage-ci
go test -v -race -cover -coverpkg=./... -coverprofile=./coverage-ci/broadcast-ws.txt -covermode=atomic
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea
go.sum
vendor
vendor_php
composer.lock
.php_cs.cache
tests/log.txt
tests/log.txt
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"email": "[email protected]"
}
],
"config": {
"vendor-dir": "vendor_php"
},
"require": {
"php": ">=7.2",
"ext-json": "*",
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/spiral/broadcast-ws

go 1.12
go 1.15

require (
github.com/gorilla/websocket v1.4.2
github.com/prometheus/client_golang v1.7.1
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v1.0.0
github.com/spiral/broadcast/v2 v2.0.5-beta.1
github.com/spiral/broadcast/v2 v2.0.5
github.com/spiral/roadrunner v1.9.2
github.com/stretchr/testify v1.6.1
)
24 changes: 12 additions & 12 deletions service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func Test_HttpService_Echo(t *testing.T) {
}))

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 3000)
defer c.Stop()

req, err := http.NewRequest("GET", "http://localhost:6041/", nil)
Expand Down Expand Up @@ -102,7 +102,7 @@ func Test_HttpService_Echo400(t *testing.T) {
}))

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 3000)
defer c.Stop()

req, err := http.NewRequest("GET", "http://localhost:6040/", nil)
Expand Down Expand Up @@ -138,7 +138,7 @@ func Test_Service_EnvPath(t *testing.T) {
}))

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 3000)
defer c.Stop()

req, err := http.NewRequest("GET", "http://localhost:6029/", nil)
Expand Down Expand Up @@ -198,7 +198,7 @@ func Test_Service_JoinTopic(t *testing.T) {
}))

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6038", Path: "/ws"}
Expand Down Expand Up @@ -248,7 +248,7 @@ func Test_Service_DenyJoin(t *testing.T) {
}))

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6037", Path: "/ws"}
Expand Down Expand Up @@ -299,7 +299,7 @@ func Test_Service_DenyJoinServer(t *testing.T) {
}))

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6037", Path: "/ws"}
Expand Down Expand Up @@ -330,7 +330,7 @@ func Test_Service_EmptyTopics(t *testing.T) {
}))

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6036", Path: "/ws"}
Expand Down Expand Up @@ -390,7 +390,7 @@ func Test_Service_BadTopics(t *testing.T) {
}))

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6035", Path: "/ws"}
Expand Down Expand Up @@ -439,7 +439,7 @@ func Test_Service_BadTopicsLeave(t *testing.T) {
}))

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6034", Path: "/ws"}
Expand Down Expand Up @@ -498,7 +498,7 @@ func Test_Service_Events(t *testing.T) {
})

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

u := url.URL{Scheme: "ws", Host: "localhost:6033", Path: "/ws"}
Expand Down Expand Up @@ -562,7 +562,7 @@ func Test_Service_Warmup(t *testing.T) {
})

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

client, err := rp.(*rpc.Service).Client()
Expand Down Expand Up @@ -641,7 +641,7 @@ func Test_Service_Stop(t *testing.T) {
})

go func() { c.Serve() }()
time.Sleep(time.Millisecond * 100)
time.Sleep(time.Millisecond * 1000)
defer c.Stop()

client, err := rp.(*rpc.Service).Client()
Expand Down
2 changes: 1 addition & 1 deletion tests/worker-deny.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// worker.php
ini_set('display_errors', 'stderr');
include __DIR__ . '/../vendor/autoload.php';
include __DIR__ . '/../vendor_php/autoload.php';

$relay = new Spiral\Goridge\StreamRelay(STDIN, STDOUT);
$psr7 = new Spiral\RoadRunner\PSR7Client(new Spiral\RoadRunner\Worker($relay));
Expand Down
2 changes: 1 addition & 1 deletion tests/worker-ok.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
declare(strict_types=1);

ini_set('display_errors', 'stderr');
include __DIR__ . '/../vendor/autoload.php';
include __DIR__ . '/../vendor_php/autoload.php';

$relay = new Spiral\Goridge\StreamRelay(STDIN, STDOUT);
$psr7 = new Spiral\RoadRunner\PSR7Client(new Spiral\RoadRunner\Worker($relay));
Expand Down
2 changes: 1 addition & 1 deletion tests/worker-stop.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// worker.php
ini_set('display_errors', 'stderr');
include __DIR__ . '/../vendor/autoload.php';
include __DIR__ . '/../vendor_php/autoload.php';

$relay = new Spiral\Goridge\StreamRelay(STDIN, STDOUT);
$psr7 = new Spiral\RoadRunner\PSR7Client(new Spiral\RoadRunner\Worker($relay));
Expand Down

0 comments on commit a232fd3

Please sign in to comment.