github.com/xg0n/routine@v0.0.0-20240119033701-c364deb94aee/.github/workflows/build.yml (about) 1 # Workflow file of GitHub Actions 2 3 name: build 4 5 on: 6 push: 7 branches: 8 - main 9 - feature/** 10 pull_request: 11 branches: 12 - main 13 14 jobs: 15 Lint: 16 runs-on: ubuntu-latest 17 steps: 18 - name: Checkout scm 19 uses: actions/checkout@v4 20 21 - name: Set up Go 22 uses: actions/setup-go@v5 23 with: 24 go-version-file: go.mod 25 26 - name: Lint 27 uses: golangci/golangci-lint-action@v3 28 with: 29 skip-pkg-cache: true 30 skip-build-cache: true 31 32 CodeQL: 33 needs: Lint 34 runs-on: ubuntu-latest 35 steps: 36 - name: Checkout scm 37 uses: actions/checkout@v4 38 39 - name: Set up Go 40 uses: actions/setup-go@v5 41 with: 42 go-version-file: go.mod 43 44 - name: Initialize CodeQL 45 uses: github/codeql-action/init@v3 46 with: 47 languages: go 48 49 - name: Perform CodeQL Analysis 50 uses: github/codeql-action/analyze@v3 51 52 Test: 53 needs: Lint 54 runs-on: ${{ matrix.runs-on }} 55 strategy: 56 fail-fast: false 57 matrix: 58 os: [ darwin, linux, windows, freebsd, js ] 59 arch: [ 386, amd64, armv6, armv7, arm64, loong64, mips, mipsle, mips64, mips64le, ppc64, ppc64le, riscv64, s390x, wasm ] 60 go: [ '1.18', '1.19', '1.20', '1.21' ] 61 exclude: 62 # darwin excludes 63 - os: darwin 64 arch: 386 65 - os: darwin 66 arch: armv6 67 - os: darwin 68 arch: armv7 69 - os: darwin 70 arch: arm64 71 - os: darwin 72 arch: loong64 73 - os: darwin 74 arch: mips 75 - os: darwin 76 arch: mipsle 77 - os: darwin 78 arch: mips64 79 - os: darwin 80 arch: mips64le 81 - os: darwin 82 arch: ppc64 83 - os: darwin 84 arch: ppc64le 85 - os: darwin 86 arch: riscv64 87 - os: darwin 88 arch: s390x 89 - os: darwin 90 arch: wasm 91 # linux excludes 92 - os: linux 93 arch: loong64 94 go: 1.13 95 - os: linux 96 arch: loong64 97 go: 1.14 98 - os: linux 99 arch: loong64 100 go: 1.15 101 - os: linux 102 arch: loong64 103 go: 1.16 104 - os: linux 105 arch: loong64 106 go: 1.17 107 - os: linux 108 arch: loong64 109 go: 1.18 110 - os: linux 111 arch: riscv64 112 go: 1.13 113 - os: linux 114 arch: wasm 115 # windows excludes 116 - os: windows 117 arch: armv6 118 - os: windows 119 arch: armv7 120 - os: windows 121 arch: arm64 122 - os: windows 123 arch: loong64 124 - os: windows 125 arch: mips 126 - os: windows 127 arch: mipsle 128 - os: windows 129 arch: mips64 130 - os: windows 131 arch: mips64le 132 - os: windows 133 arch: ppc64 134 - os: windows 135 arch: ppc64le 136 - os: windows 137 arch: riscv64 138 - os: windows 139 arch: s390x 140 - os: windows 141 arch: wasm 142 # freebsd excludes 143 - os: freebsd 144 arch: armv6 145 - os: freebsd 146 arch: armv7 147 - os: freebsd 148 arch: arm64 149 - os: freebsd 150 arch: loong64 151 - os: freebsd 152 arch: mips 153 - os: freebsd 154 arch: mipsle 155 - os: freebsd 156 arch: mips64 157 - os: freebsd 158 arch: mips64le 159 - os: freebsd 160 arch: ppc64 161 - os: freebsd 162 arch: ppc64le 163 - os: freebsd 164 arch: riscv64 165 - os: freebsd 166 arch: s390x 167 - os: freebsd 168 arch: wasm 169 # js excludes 170 - os: js 171 arch: 386 172 - os: js 173 arch: amd64 174 - os: js 175 arch: armv6 176 - os: js 177 arch: armv7 178 - os: js 179 arch: arm64 180 - os: js 181 arch: loong64 182 - os: js 183 arch: mips 184 - os: js 185 arch: mipsle 186 - os: js 187 arch: mips64 188 - os: js 189 arch: mips64le 190 - os: js 191 arch: ppc64 192 - os: js 193 arch: ppc64le 194 - os: js 195 arch: riscv64 196 - os: js 197 arch: s390x 198 include: 199 # combine runs on 200 - os: darwin 201 runs-on: macos-latest 202 - os: linux 203 runs-on: ubuntu-latest 204 - os: windows 205 runs-on: windows-latest 206 - os: freebsd 207 runs-on: ubuntu-latest 208 - os: js 209 runs-on: ubuntu-latest 210 211 steps: 212 - name: Checkout scm 213 uses: actions/checkout@v4 214 215 - name: Set up Go 216 uses: actions/setup-go@v5 217 with: 218 go-version: ${{ matrix.go }} 219 220 # darwin 221 - name: 'Test on [darwin] arch [amd64]' 222 if: ${{ matrix.os == 'darwin' && contains(fromJson('["amd64"]'), matrix.arch) }} 223 env: 224 GOOS: ${{ matrix.os }} 225 GOARCH: ${{ matrix.arch }} 226 run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... 227 228 # linux 229 - name: 'Test on [linux] arch [386]' 230 if: ${{ matrix.os == 'linux' && contains(fromJson('["386"]'), matrix.arch) }} 231 env: 232 GOOS: ${{ matrix.os }} 233 GOARCH: ${{ matrix.arch }} 234 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 235 236 - name: 'Test on [linux] arch [amd64]' 237 if: ${{ matrix.os == 'linux' && contains(fromJson('["amd64"]'), matrix.arch) }} 238 env: 239 GOOS: ${{ matrix.os }} 240 GOARCH: ${{ matrix.arch }} 241 run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... 242 243 - name: 'Setup qemu-user-static on [linux] arch [armv6, armv7, arm64, mips, mipsle, mips64, mips64le, ppc64, ppc64le, riscv64, s390x]' 244 if: ${{ matrix.os == 'linux' && contains(fromJson('["armv6", "armv7", "arm64", "mips", "mipsle", "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x"]'), matrix.arch) }} 245 run: | 246 sudo apt-get update 247 sudo apt-get -y install qemu-user-static 248 249 - name: 'Test on [linux] arch [armv6]' 250 if: ${{ matrix.os == 'linux' && contains(fromJson('["armv6"]'), matrix.arch) }} 251 env: 252 GOOS: ${{ matrix.os }} 253 GOARCH: arm 254 GOARM: 6 255 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 256 257 - name: 'Test on [linux] arch [armv7]' 258 if: ${{ matrix.os == 'linux' && contains(fromJson('["armv7"]'), matrix.arch) }} 259 env: 260 GOOS: ${{ matrix.os }} 261 GOARCH: arm 262 GOARM: 7 263 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 264 265 - name: 'Test on [linux] arch [mips, mipsle]' 266 if: ${{ matrix.os == 'linux' && contains(fromJson('["mips", "mipsle"]'), matrix.arch) }} 267 env: 268 GOOS: ${{ matrix.os }} 269 GOARCH: ${{ matrix.arch }} 270 GOMIPS: softfloat 271 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 272 273 - name: 'Test on [linux] arch [arm64, mips64, mips64le, ppc64, ppc64le, riscv64, s390x]' 274 if: ${{ matrix.os == 'linux' && contains(fromJson('["arm64", "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x"]'), matrix.arch) }} 275 env: 276 GOOS: ${{ matrix.os }} 277 GOARCH: ${{ matrix.arch }} 278 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 279 280 - name: 'Setup qemu-loongarch64-static on [linux] arch [loong64]' 281 if: ${{ matrix.os == 'linux' && contains(fromJson('["loong64"]'), matrix.arch) }} 282 run: | 283 sudo wget -O /usr/bin/qemu-loongarch64-static https://github.com/loongson/build-tools/releases/download/2022.09.06/qemu-loongarch64 284 sudo chmod +x /usr/bin/qemu-loongarch64-static 285 sudo mkdir -p /usr/libexec/qemu-binfmt 286 sudo ln -s /usr/bin/qemu-loongarch64-static /usr/libexec/qemu-binfmt/loongarch64-binfmt-P 287 sudo sh -c 'echo ":qemu-loongarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01:\xff\xff\xff\xff\xff\xff\xff\xfc\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/loongarch64-binfmt-P:" > /proc/sys/fs/binfmt_misc/register' 288 289 - name: 'Test on [linux] arch [loong64]' 290 if: ${{ matrix.os == 'linux' && contains(fromJson('["loong64"]'), matrix.arch) }} 291 env: 292 GOOS: ${{ matrix.os }} 293 GOARCH: ${{ matrix.arch }} 294 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 295 296 # windows 297 - name: 'Test on [windows] arch [386]' 298 if: ${{ matrix.os == 'windows' && contains(fromJson('["386"]'), matrix.arch) }} 299 env: 300 GOOS: ${{ matrix.os }} 301 GOARCH: ${{ matrix.arch }} 302 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 303 304 - name: 'Test on [windows] arch [amd64]' 305 if: ${{ matrix.os == 'windows' && contains(fromJson('["amd64"]'), matrix.arch) }} 306 env: 307 GOOS: ${{ matrix.os }} 308 GOARCH: ${{ matrix.arch }} 309 run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... 310 311 # freebsd 312 - name: 'Build for [freebsd] arch [386, amd64]' 313 if: ${{ matrix.os == 'freebsd' && contains(fromJson('["386", "amd64"]'), matrix.arch) }} 314 env: 315 GOOS: ${{ matrix.os }} 316 GOARCH: ${{ matrix.arch }} 317 run: go test -v -c -covermode=atomic 318 319 - name: 'Test on [freebsd] arch [386, amd64]' 320 if: ${{ matrix.os == 'freebsd' && contains(fromJson('["386", "amd64"]'), matrix.arch) }} 321 uses: vmactions/freebsd-vm@v1 322 with: 323 run: ./routine.test -test.v -test.coverprofile="coverage.txt" 324 325 # js 326 - name: 'Setup Node.js on [js] arch [wasm]' 327 if: ${{ matrix.os == 'js' && contains(fromJson('["wasm"]'), matrix.arch) }} 328 uses: actions/setup-node@v4 329 with: 330 node-version: 18 331 332 - name: 'Test on [js] arch [wasm]' 333 if: ${{ matrix.os == 'js' && contains(fromJson('["wasm"]'), matrix.arch) }} 334 env: 335 GOOS: ${{ matrix.os }} 336 GOARCH: ${{ matrix.arch }} 337 run: | 338 eval "$(go env | grep GOROOT)" 339 PATH=$PATH:"${GOROOT}/misc/wasm" 340 go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 341 342 - name: Codecov 343 uses: codecov/codecov-action@v3 344 with: 345 name: Codecov on ${{ matrix.os }}/${{ matrix.arch }} go${{ matrix.go }} 346 fail_ci_if_error: false