|
| 1 | +name: Linux |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + # Branches from forks have the form 'user:branch-name' so we only run |
| 8 | + # this job on pull_request events for branches that look like fork |
| 9 | + # branches. Without this we would end up running this job twice for non |
| 10 | + # forked PRs, once for the push and then once for opening the PR. |
| 11 | + - "**:**" |
| 12 | + |
| 13 | +jobs: |
| 14 | + golang: |
| 15 | + name: Build (Go ${{ matrix.go }}, PHP ${{ matrix.php }}, OS ${{matrix.os}}) |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + timeout-minutes: 60 |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + php: [ "7.2","7.3", "7.4", "8.0" ] |
| 22 | + go: [ "1.14", "1.15" ] |
| 23 | + os: [ ubuntu-20.04 ] |
| 24 | + steps: |
| 25 | + - name: Set up Go ${{ matrix.go }} |
| 26 | + uses: actions/setup-go@v2 # action page: <https://github.com/actions/setup-go> |
| 27 | + with: |
| 28 | + go-version: ${{ matrix.go }} |
| 29 | + |
| 30 | + - name: Set up PHP ${{ matrix.php }} |
| 31 | + uses: shivammathur/setup-php@v2 # action page: <https://github.com/shivammathur/setup-php> |
| 32 | + with: |
| 33 | + php-version: ${{ matrix.php }} |
| 34 | + extensions: sockets |
| 35 | + |
| 36 | + - name: Check out code |
| 37 | + uses: actions/checkout@v2 |
| 38 | + |
| 39 | + - name: Get Composer Cache Directory |
| 40 | + id: composer-cache |
| 41 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 42 | + |
| 43 | + - name: Init Composer Cache # Docs: <https://git.io/JfAKn#php---composer> |
| 44 | + uses: actions/cache@v2 |
| 45 | + with: |
| 46 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 47 | + key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }} |
| 48 | + restore-keys: ${{ runner.os }}-composer- |
| 49 | + |
| 50 | + - name: Install Composer dependencies |
| 51 | + run: composer update --prefer-dist --no-progress --ansi |
| 52 | + |
| 53 | + - name: Init Go modules Cache # Docs: <https://git.io/JfAKn#go---modules> |
| 54 | + uses: actions/cache@v2 |
| 55 | + with: |
| 56 | + path: ~/go/pkg/mod |
| 57 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 58 | + restore-keys: ${{ runner.os }}-go- |
| 59 | + |
| 60 | + - name: Install Go dependencies |
| 61 | + run: go mod download |
| 62 | + |
| 63 | + - name: Run golang tests on Linux |
| 64 | + run: | |
| 65 | + mkdir ./coverage-ci |
| 66 | + go test -v -race -cover -coverpkg=./... -coverprofile=./coverage-ci/broadcast-ws.txt -covermode=atomic |
| 67 | +
|
| 68 | + - uses: codecov/codecov-action@v1 # Docs: <https://github.com/codecov/codecov-action> |
| 69 | + with: |
| 70 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 71 | + file: ./coverage-ci/broadcast-ws.txt |
| 72 | + fail_ci_if_error: false |
| 73 | + |
| 74 | + golangci-lint: |
| 75 | + name: Golang-CI (lint) |
| 76 | + runs-on: ubuntu-20.04 |
| 77 | + steps: |
| 78 | + - name: Check out code |
| 79 | + uses: actions/checkout@v2 |
| 80 | + |
| 81 | + - name: Run linter |
| 82 | + uses: golangci/golangci-lint-action@v2 # Action page: <https://github.com/golangci/golangci-lint-action> |
| 83 | + with: |
| 84 | + version: v1.35 # without patch version |
| 85 | + only-new-issues: false # show only new issues if it's a pull request |
0 commit comments