github.com/anycable/anycable-go@v1.5.1/.github/workflows/test.yml (about) 1 name: Test 2 3 on: 4 push: 5 branches: 6 - master 7 pull_request: 8 9 jobs: 10 test: 11 if: "!contains(github.event.head_commit.message, '[ci skip tests]')" 12 runs-on: ubuntu-20.04 13 env: 14 GO111MODULE: on 15 GOFLAGS: "-mod=vendor" 16 COVERAGE: "true" 17 REDIS_URL: "redis://localhost:6379/2" 18 services: 19 redis: 20 image: redis:7.0-alpine 21 ports: ["6379:6379"] 22 options: --health-cmd="redis-cli ping" --health-interval 1s --health-timeout 3s --health-retries 30 23 steps: 24 - uses: actions/checkout@v4 25 - name: Install system deps 26 run: | 27 sudo apt-get update 28 sudo apt-get install bison 29 - uses: actions/cache@v1 30 with: 31 path: vendor 32 key: vendor-${{ hashFiles('**/go.sum') }} 33 restore-keys: | 34 vendor- 35 - run: go mod vendor 36 - name: Build mruby 37 run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' 38 - uses: actions/setup-go@v4 39 with: 40 go-version-file: go.mod 41 - name: Run tests 42 run: make test 43 - name: Report coverage 44 uses: coverallsapp/github-action@v2 45 with: 46 file: coverage.out 47 parallel: true 48 flag-name: ${{ matrix.go-version }}-ubuntu 49 - name: Build 50 run: | 51 make build 52 - name: Upload linux build 53 if: (github.ref == 'refs/head/master' || contains(github.event.pull_request.body, '[Build]')) 54 uses: actions/upload-artifact@v1 55 with: 56 name: anycable-go-Linux-x86_64 57 path: dist/anycable-go 58 59 test-macos: 60 if: "!contains(github.event.head_commit.message, '[ci skip tests]')" 61 runs-on: macos-latest 62 env: 63 GO111MODULE: on 64 GOFLAGS: "-mod=vendor" 65 COVERAGE: "true" 66 steps: 67 - uses: actions/checkout@v4 68 - uses: actions/setup-go@v4 69 with: 70 go-version-file: go.mod 71 - name: Install system deps 72 run: | 73 brew install bison 74 - uses: actions/cache@v3 75 with: 76 path: vendor 77 key: vendor-${{ hashFiles('**/go.sum') }} 78 restore-keys: | 79 vendor- 80 - uses: ruby/setup-ruby@v1 81 with: 82 # Use <3.0 since go-mruby's Rakefile has some problems with keyword arguments compatibility 83 ruby-version: 2.7 84 bundler-cache: true 85 - run: go mod vendor 86 - name: Build mruby 87 run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' 88 - name: Run tests 89 run: make test 90 - name: Report coverage 91 uses: coverallsapp/github-action@v2 92 with: 93 file: coverage.out 94 parallel: true 95 flag-name: ${{ matrix.go-version }}-macos 96 - name: Build 97 run: | 98 make build 99 - name: Upload MacOS build 100 if: (github.ref == 'refs/head/master' || contains(github.event.pull_request.body, '[Build]')) 101 uses: actions/upload-artifact@v1 102 with: 103 name: anycable-go-Darwin-x86_64 104 path: dist/anycable-go 105 106 test-conformance: 107 if: "!contains(github.event.head_commit.message, '[ci skip tests]')" 108 needs: [test, test-macos] 109 strategy: 110 matrix: 111 test_command: 112 - benchmarks 113 - test-features 114 - test-conformance 115 - test-conformance-http 116 - test-conformance-nats 117 - test-conformance-nats-embedded 118 - test-conformance-ssl 119 - test-conformance-broker-http 120 - test-conformance-broker-redis 121 - test-conformance-broker-nats 122 - test-conformance-embedded 123 runs-on: ubuntu-latest 124 env: 125 GO111MODULE: on 126 GOFLAGS: "-mod=vendor" 127 BUILD_ARGS: "-race" 128 GORACE: "halt_on_error=1" 129 COVERAGE: "true" 130 GOCOVERDIR: "_icoverdir_" 131 BUNDLE_PATH: ./vendor/bundle 132 # Specify REDIS_URL explicitly, so Makefile doesn't check the presence of Redis 133 REDIS_URL: redis://localhost:6379/ 134 ANYCABLE_DISABLE_TELEMETRY: "true" 135 services: 136 redis: 137 image: redis:6.2-alpine 138 ports: ["6379:6379"] 139 options: --health-cmd="redis-cli ping" --health-interval 1s --health-timeout 3s --health-retries 30 140 nats: 141 image: nats:alpine 142 ports: ["4222:4222"] 143 steps: 144 - uses: actions/checkout@v4 145 - uses: actions/setup-go@v4 146 with: 147 go-version-file: go.mod 148 - name: Install system deps 149 run: | 150 sudo apt-get update 151 sudo apt-get install bison 152 - uses: ruby/setup-ruby@v1 153 with: 154 # Use <3.0 since go-mruby's Rakefile has some problems with keyword arguments compatibility 155 ruby-version: 2.7 156 bundler-cache: true 157 - uses: actions/cache@v3 158 with: 159 path: vendor 160 key: vendor-${{ hashFiles('**/go.sum') }} 161 restore-keys: | 162 vendor- 163 - run: go mod vendor 164 - name: Build mruby 165 run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' 166 - name: Install websocket-bench & gops 167 if: matrix.test_command == 'benchmarks' 168 env: 169 GO111MODULE: off 170 run: | 171 go get -u github.com/anycable/websocket-bench 172 go get -u github.com/google/gops 173 - name: Run tests 174 run: | 175 bundle install 176 mkdir _icoverdir_ 177 make ${{ matrix.test_command }} 178 - name: Format coverage 179 continue-on-error: true 180 run: | 181 go tool covdata textfmt -i _icoverdir_ -o coverage.out 182 - name: Check if has coverage? 183 id: coverage 184 run: | 185 if [ -s coverage.out ]; then 186 echo "coverage found" 187 echo "COVERAGE=yes" >> $GITHUB_OUTPUT 188 else 189 echo "no coverage found" 190 echo "COVERAGE=no" >> $GITHUB_OUTPUT 191 fi 192 - name: Report coverage 193 if: steps.coverage.outputs.COVERAGE == 'yes' 194 uses: coverallsapp/github-action@v2 195 with: 196 file: coverage.out 197 parallel: true 198 format: golang 199 flag-name: integration-${{ matrix.test_command }} 200 201 coverage: 202 runs-on: ubuntu-latest 203 needs: [test, test-macos, test-conformance] 204 steps: 205 - uses: coverallsapp/github-action@v2 206 with: 207 parallel-finished: true