github.com/timandy/routine@v1.1.4/.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@v6 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', '1.23' ] 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: loong64 70 - os: darwin 71 arch: mips 72 - os: darwin 73 arch: mipsle 74 - os: darwin 75 arch: mips64 76 - os: darwin 77 arch: mips64le 78 - os: darwin 79 arch: ppc64 80 - os: darwin 81 arch: ppc64le 82 - os: darwin 83 arch: riscv64 84 - os: darwin 85 arch: s390x 86 - os: darwin 87 arch: wasm 88 # linux excludes 89 - os: linux 90 arch: loong64 91 go: 1.18 92 - os: linux 93 arch: wasm 94 # windows excludes 95 - os: windows 96 arch: armv6 97 - os: windows 98 arch: armv7 99 - os: windows 100 arch: arm64 101 - os: windows 102 arch: loong64 103 - os: windows 104 arch: mips 105 - os: windows 106 arch: mipsle 107 - os: windows 108 arch: mips64 109 - os: windows 110 arch: mips64le 111 - os: windows 112 arch: ppc64 113 - os: windows 114 arch: ppc64le 115 - os: windows 116 arch: riscv64 117 - os: windows 118 arch: s390x 119 - os: windows 120 arch: wasm 121 # freebsd excludes 122 - os: freebsd 123 arch: armv6 124 - os: freebsd 125 arch: armv7 126 - os: freebsd 127 arch: arm64 128 - os: freebsd 129 arch: loong64 130 - os: freebsd 131 arch: mips 132 - os: freebsd 133 arch: mipsle 134 - os: freebsd 135 arch: mips64 136 - os: freebsd 137 arch: mips64le 138 - os: freebsd 139 arch: ppc64 140 - os: freebsd 141 arch: ppc64le 142 - os: freebsd 143 arch: riscv64 144 - os: freebsd 145 arch: s390x 146 - os: freebsd 147 arch: wasm 148 # js excludes 149 - os: js 150 arch: 386 151 - os: js 152 arch: amd64 153 - os: js 154 arch: armv6 155 - os: js 156 arch: armv7 157 - os: js 158 arch: arm64 159 - os: js 160 arch: loong64 161 - os: js 162 arch: mips 163 - os: js 164 arch: mipsle 165 - os: js 166 arch: mips64 167 - os: js 168 arch: mips64le 169 - os: js 170 arch: ppc64 171 - os: js 172 arch: ppc64le 173 - os: js 174 arch: riscv64 175 - os: js 176 arch: s390x 177 include: 178 # combine runs on 179 - os: darwin 180 runs-on: macos-13 181 - os: darwin 182 arch: arm64 183 runs-on: macos-latest 184 - os: linux 185 runs-on: ubuntu-latest 186 - os: windows 187 runs-on: windows-latest 188 - os: freebsd 189 runs-on: ubuntu-latest 190 - os: js 191 runs-on: ubuntu-latest 192 193 steps: 194 - name: Checkout scm 195 uses: actions/checkout@v4 196 197 - name: Set up Go 198 uses: actions/setup-go@v5 199 with: 200 go-version: ${{ matrix.go }} 201 cache: false 202 203 # darwin 204 - name: 'Test on [darwin] arch [amd64]' 205 if: ${{ matrix.os == 'darwin' && contains(fromJson('["amd64"]'), matrix.arch) }} 206 env: 207 GOOS: ${{ matrix.os }} 208 GOARCH: ${{ matrix.arch }} 209 run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... 210 211 - name: 'Test on [darwin] arch [arm64]' 212 if: ${{ matrix.os == 'darwin' && contains(fromJson('["arm64"]'), matrix.arch) }} 213 env: 214 GOOS: ${{ matrix.os }} 215 GOARCH: ${{ matrix.arch }} 216 run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... 217 218 # linux 219 - name: 'Test on [linux] arch [386]' 220 if: ${{ matrix.os == 'linux' && contains(fromJson('["386"]'), matrix.arch) }} 221 env: 222 GOOS: ${{ matrix.os }} 223 GOARCH: ${{ matrix.arch }} 224 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 225 226 - name: 'Test on [linux] arch [amd64]' 227 if: ${{ matrix.os == 'linux' && contains(fromJson('["amd64"]'), matrix.arch) }} 228 env: 229 GOOS: ${{ matrix.os }} 230 GOARCH: ${{ matrix.arch }} 231 run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... 232 233 - name: 'Setup qemu-user-static on [linux] arch [armv6, armv7, arm64, mips, mipsle, mips64, mips64le, ppc64, ppc64le, riscv64, s390x]' 234 if: ${{ matrix.os == 'linux' && contains(fromJson('["armv6", "armv7", "arm64", "mips", "mipsle", "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x"]'), matrix.arch) }} 235 run: | 236 sudo apt-get update 237 sudo apt-get -y install qemu-user-static 238 239 - name: 'Test on [linux] arch [armv6]' 240 if: ${{ matrix.os == 'linux' && contains(fromJson('["armv6"]'), matrix.arch) }} 241 env: 242 GOOS: ${{ matrix.os }} 243 GOARCH: arm 244 GOARM: 6 245 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 246 247 - name: 'Test on [linux] arch [armv7]' 248 if: ${{ matrix.os == 'linux' && contains(fromJson('["armv7"]'), matrix.arch) }} 249 env: 250 GOOS: ${{ matrix.os }} 251 GOARCH: arm 252 GOARM: 7 253 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 254 255 - name: 'Test on [linux] arch [mips, mipsle]' 256 if: ${{ matrix.os == 'linux' && contains(fromJson('["mips", "mipsle"]'), matrix.arch) }} 257 env: 258 GOOS: ${{ matrix.os }} 259 GOARCH: ${{ matrix.arch }} 260 GOMIPS: softfloat 261 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 262 263 - name: 'Test on [linux] arch [arm64, mips64, mips64le, ppc64, ppc64le, riscv64, s390x]' 264 if: ${{ matrix.os == 'linux' && contains(fromJson('["arm64", "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x"]'), matrix.arch) }} 265 env: 266 GOOS: ${{ matrix.os }} 267 GOARCH: ${{ matrix.arch }} 268 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 269 270 - name: 'Setup qemu-loongarch64-static on [linux] arch [loong64]' 271 if: ${{ matrix.os == 'linux' && contains(fromJson('["loong64"]'), matrix.arch) }} 272 run: | 273 sudo wget -O /usr/bin/qemu-loongarch64-static https://github.com/loongson/build-tools/releases/download/2022.09.06/qemu-loongarch64 274 sudo chmod +x /usr/bin/qemu-loongarch64-static 275 sudo mkdir -p /usr/libexec/qemu-binfmt 276 sudo ln -s /usr/bin/qemu-loongarch64-static /usr/libexec/qemu-binfmt/loongarch64-binfmt-P 277 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' 278 279 - name: 'Test on [linux] arch [loong64]' 280 if: ${{ matrix.os == 'linux' && contains(fromJson('["loong64"]'), matrix.arch) }} 281 env: 282 GOOS: ${{ matrix.os }} 283 GOARCH: ${{ matrix.arch }} 284 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 285 286 # windows 287 - name: 'Test on [windows] arch [386]' 288 if: ${{ matrix.os == 'windows' && contains(fromJson('["386"]'), matrix.arch) }} 289 env: 290 GOOS: ${{ matrix.os }} 291 GOARCH: ${{ matrix.arch }} 292 run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 293 294 - name: 'Test on [windows] arch [amd64]' 295 if: ${{ matrix.os == 'windows' && contains(fromJson('["amd64"]'), matrix.arch) }} 296 env: 297 GOOS: ${{ matrix.os }} 298 GOARCH: ${{ matrix.arch }} 299 run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... 300 301 # freebsd 302 - name: 'Build for [freebsd] arch [386, amd64]' 303 if: ${{ matrix.os == 'freebsd' && contains(fromJson('["386", "amd64"]'), matrix.arch) }} 304 env: 305 GOOS: ${{ matrix.os }} 306 GOARCH: ${{ matrix.arch }} 307 run: go test -v -c -covermode=atomic 308 309 - name: 'Test on [freebsd] arch [386, amd64]' 310 if: ${{ matrix.os == 'freebsd' && contains(fromJson('["386", "amd64"]'), matrix.arch) }} 311 uses: vmactions/freebsd-vm@v1 312 with: 313 run: ./routine.test -test.v -test.coverprofile="coverage.txt" 314 315 # js 316 - name: 'Setup Node.js on [js] arch [wasm]' 317 if: ${{ matrix.os == 'js' && contains(fromJson('["wasm"]'), matrix.arch) }} 318 uses: actions/setup-node@v4 319 with: 320 node-version: 18 321 322 - name: 'Test on [js] arch [wasm]' 323 if: ${{ matrix.os == 'js' && contains(fromJson('["wasm"]'), matrix.arch) }} 324 env: 325 GOOS: ${{ matrix.os }} 326 GOARCH: ${{ matrix.arch }} 327 run: | 328 GOROOT=$(go env GOROOT) 329 PATH=$PATH:"${GOROOT}/misc/wasm" 330 go test -v -coverprofile="coverage.txt" -covermode=atomic ./... 331 332 - name: Codecov 333 uses: codecov/codecov-action@v4 334 with: 335 name: Codecov on ${{ matrix.os }}/${{ matrix.arch }} go${{ matrix.go }} 336 token: ${{ secrets.CODECOV_TOKEN }} 337 fail_ci_if_error: false