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