summaryrefslogtreecommitdiff
path: root/.github/workflows/ci-build.yml
blob: 8b462f81d439e0984bd2ea58a7cce8ed5bd6f343 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: CI

on: [ push, pull_request ]

jobs:
  build:
    name: Build (PHP ${{ matrix.php }}, Go ${{ matrix.go }}, OS ${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        php: [ 7.4 ]
        go: [ 1.14, 1.15 ]
        os: [ ubuntu-latest ]
    env:
      GO111MODULE: on
    steps:
      - name: Set up Go ${{ matrix.go }}
        uses: actions/setup-go@v1
        with:
          go-version: ${{ matrix.go }}

      - name: Set up PHP ${{ matrix.php }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom
          coverage: xdebug

      - name: Check out code
        uses: actions/checkout@v2
        with:
          fetch-depth: 1

      - name: Show versions
        run: php -v ; composer -V ; go version

      - name: Debug if needed
        env:
          DEBUG: ${{ secrets.DEBUG }}
        run: if [[ "$DEBUG" == "true" ]]; then env && go env; fi

      - name: Syntax check only (lint)
        run: find ./src/ -name "*.php" -print0 | xargs -0 -n1 -P8 php -l

      - name: Get Composer Cache Directory # Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
        id: composer-cache
        run: echo "::set-output name=dir::$(composer config cache-files-dir)"

      - name: Cache dependencies # Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
        uses: actions/cache@v1
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
          restore-keys: ${{ runner.os }}-composer-

      - name: Install Composer dependencies
        run: composer install --prefer-dist --no-interaction --no-suggest # --prefer-source

      #      - name: Analyze PHP sources
      #        run: composer analyze

      - name: Install Go dependencies
        run: go mod download

      - name: Run golang tests
        run: |
          go test -v -race . -tags=debug -coverprofile=lib.txt -covermode=atomic
          go test -v -race ./plugins/rpc -tags=debug -coverprofile=rpc_config.txt -covermode=atomic
          go test -v -race ./plugins/rpc/tests -tags=debug -coverprofile=rpc.txt -covermode=atomic
          go test -v -race ./plugins/config/tests -tags=debug -coverprofile=plugin_config.txt -covermode=atomic
          go test -v -race ./plugins/logger/tests -tags=debug -coverprofile=logger.txt -covermode=atomic
          go test -v -race ./plugins/server/tests -tags=debug -coverprofile=server.txt -covermode=atomic
          go test -v -race ./plugins/metrics/tests -tags=debug -coverprofile=metrics.txt -covermode=atomic
          go test -v -race ./plugins/informer/tests -tags=debug -coverprofile=informer.txt -covermode=atomic
          go test -v -race ./plugins/resetter/tests -tags=debug -coverprofile=informer.txt -covermode=atomic

      - name: Run code coverage
        uses: codecov/codecov-action@v1
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: lib.txt, rpc_config.txt, rpc.txt, plugin_config.txt, logger.txt, server.txt, metrics.txt, informer.txt
          flags: unittests
          name: codecov-umbrella
          fail_ci_if_error: false
          verbose: true


  golangci-check:
    name: runner / golangci-lint
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v1
      - name: golangci-lint
        uses: reviewdog/action-golangci-lint@v1
        with:
          github_token: ${{ secrets.github_token }}

#  image:
#    name: Build docker image
#    runs-on: ubuntu-latest
#    steps:
#      - name: Check out code
#        uses: actions/checkout@v2
#        with:
#          fetch-depth: 1
#
#      - name: Build image
#        run: docker build -t rr:local -f Dockerfile .