Modify continuous integration script to emulate freebsd on the ubuntu… #61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workflow file of GitHub Actions | |
name: build | |
on: | |
push: | |
branches: | |
- main | |
- feature/** | |
pull_request: | |
branches: | |
- main | |
jobs: | |
Lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout scm | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: Lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
skip-pkg-cache: true | |
skip-build-cache: true | |
CodeQL: | |
needs: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout scm | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: go | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v2 | |
Test: | |
needs: Lint | |
runs-on: ${{ matrix.runs-on }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ darwin, linux, windows, freebsd, js ] | |
arch: [ 386, amd64, armv6, armv7, arm64, loong64, mips, mipsle, mips64, mips64le, ppc64, ppc64le, riscv64, s390x, wasm ] | |
go: [ '1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.19', '1.20', '1.21' ] | |
exclude: | |
# darwin excludes | |
- os: darwin | |
arch: 386 | |
- os: darwin | |
arch: armv6 | |
- os: darwin | |
arch: armv7 | |
- os: darwin | |
arch: arm64 | |
- os: darwin | |
arch: loong64 | |
- os: darwin | |
arch: mips | |
- os: darwin | |
arch: mipsle | |
- os: darwin | |
arch: mips64 | |
- os: darwin | |
arch: mips64le | |
- os: darwin | |
arch: ppc64 | |
- os: darwin | |
arch: ppc64le | |
- os: darwin | |
arch: riscv64 | |
- os: darwin | |
arch: s390x | |
- os: darwin | |
arch: wasm | |
# linux excludes | |
- os: linux | |
arch: loong64 | |
go: 1.13 | |
- os: linux | |
arch: loong64 | |
go: 1.14 | |
- os: linux | |
arch: loong64 | |
go: 1.15 | |
- os: linux | |
arch: loong64 | |
go: 1.16 | |
- os: linux | |
arch: loong64 | |
go: 1.17 | |
- os: linux | |
arch: loong64 | |
go: 1.18 | |
- os: linux | |
arch: riscv64 | |
go: 1.13 | |
- os: linux | |
arch: wasm | |
# windows excludes | |
- os: windows | |
arch: armv6 | |
- os: windows | |
arch: armv7 | |
- os: windows | |
arch: arm64 | |
- os: windows | |
arch: loong64 | |
- os: windows | |
arch: mips | |
- os: windows | |
arch: mipsle | |
- os: windows | |
arch: mips64 | |
- os: windows | |
arch: mips64le | |
- os: windows | |
arch: ppc64 | |
- os: windows | |
arch: ppc64le | |
- os: windows | |
arch: riscv64 | |
- os: windows | |
arch: s390x | |
- os: windows | |
arch: wasm | |
# freebsd excludes | |
- os: freebsd | |
arch: armv6 | |
- os: freebsd | |
arch: armv7 | |
- os: freebsd | |
arch: arm64 | |
- os: freebsd | |
arch: loong64 | |
- os: freebsd | |
arch: mips | |
- os: freebsd | |
arch: mipsle | |
- os: freebsd | |
arch: mips64 | |
- os: freebsd | |
arch: mips64le | |
- os: freebsd | |
arch: ppc64 | |
- os: freebsd | |
arch: ppc64le | |
- os: freebsd | |
arch: riscv64 | |
- os: freebsd | |
arch: s390x | |
- os: freebsd | |
arch: wasm | |
# js excludes | |
- os: js | |
arch: 386 | |
- os: js | |
arch: amd64 | |
- os: js | |
arch: armv6 | |
- os: js | |
arch: armv7 | |
- os: js | |
arch: arm64 | |
- os: js | |
arch: loong64 | |
- os: js | |
arch: mips | |
- os: js | |
arch: mipsle | |
- os: js | |
arch: mips64 | |
- os: js | |
arch: mips64le | |
- os: js | |
arch: ppc64 | |
- os: js | |
arch: ppc64le | |
- os: js | |
arch: riscv64 | |
- os: js | |
arch: s390x | |
include: | |
# combine runs on | |
- os: darwin | |
runs-on: macos-latest | |
- os: linux | |
runs-on: ubuntu-latest | |
- os: windows | |
runs-on: windows-latest | |
- os: freebsd | |
runs-on: ubuntu-latest | |
- os: js | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout scm | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go }} | |
# darwin | |
- name: 'Test on [darwin] arch [amd64]' | |
if: ${{ matrix.os == 'darwin' && contains(fromJson('["amd64"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... | |
# linux | |
- name: 'Test on [linux] arch [386]' | |
if: ${{ matrix.os == 'linux' && contains(fromJson('["386"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... | |
- name: 'Test on [linux] arch [amd64]' | |
if: ${{ matrix.os == 'linux' && contains(fromJson('["amd64"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... | |
- name: 'Setup qemu-user-static on [linux] arch [armv6, armv7, arm64, mips, mipsle, mips64, mips64le, ppc64, ppc64le, riscv64, s390x]' | |
if: ${{ matrix.os == 'linux' && contains(fromJson('["armv6", "armv7", "arm64", "mips", "mipsle", "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x"]'), matrix.arch) }} | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install qemu-user-static | |
- name: 'Test on [linux] arch [armv6]' | |
if: ${{ matrix.os == 'linux' && contains(fromJson('["armv6"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: arm | |
GOARM: 6 | |
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... | |
- name: 'Test on [linux] arch [armv7]' | |
if: ${{ matrix.os == 'linux' && contains(fromJson('["armv7"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: arm | |
GOARM: 7 | |
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... | |
- name: 'Test on [linux] arch [mips, mipsle]' | |
if: ${{ matrix.os == 'linux' && contains(fromJson('["mips", "mipsle"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
GOMIPS: softfloat | |
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... | |
- name: 'Test on [linux] arch [arm64, mips64, mips64le, ppc64, ppc64le, riscv64, s390x]' | |
if: ${{ matrix.os == 'linux' && contains(fromJson('["arm64", "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... | |
- name: 'Setup qemu-loongarch64-static on [linux] arch [loong64]' | |
if: ${{ matrix.os == 'linux' && contains(fromJson('["loong64"]'), matrix.arch) }} | |
run: | | |
sudo wget -O /usr/bin/qemu-loongarch64-static https://github.com/loongson/build-tools/releases/download/2022.09.06/qemu-loongarch64 | |
sudo chmod +x /usr/bin/qemu-loongarch64-static | |
sudo mkdir -p /usr/libexec/qemu-binfmt | |
sudo ln -s /usr/bin/qemu-loongarch64-static /usr/libexec/qemu-binfmt/loongarch64-binfmt-P | |
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' | |
- name: 'Test on [linux] arch [loong64]' | |
if: ${{ matrix.os == 'linux' && contains(fromJson('["loong64"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... | |
# windows | |
- name: 'Test on [windows] arch [386]' | |
if: ${{ matrix.os == 'windows' && contains(fromJson('["386"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... | |
- name: 'Test on [windows] arch [amd64]' | |
if: ${{ matrix.os == 'windows' && contains(fromJson('["amd64"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... | |
# freebsd | |
- name: 'Build for [freebsd] arch [386, amd64]' | |
if: ${{ matrix.os == 'freebsd' && contains(fromJson('["386", "amd64"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: go test -v -c -covermode=atomic | |
- name: 'Test on [freebsd] arch [386, amd64]' | |
if: ${{ matrix.os == 'freebsd' && contains(fromJson('["386", "amd64"]'), matrix.arch) }} | |
uses: vmactions/freebsd-vm@v1 | |
with: | |
run: ./gohack.test -test.v -test.coverprofile="coverage.txt" | |
# js | |
- name: 'Setup Node.js on [js] arch [wasm]' | |
if: ${{ matrix.os == 'js' && contains(fromJson('["wasm"]'), matrix.arch) }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: 'Test on [js] arch [wasm]' | |
if: ${{ matrix.os == 'js' && contains(fromJson('["wasm"]'), matrix.arch) }} | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: | | |
eval "$(go env | grep GOROOT)" | |
PATH=$PATH:"${GOROOT}/misc/wasm" | |
go test -v -coverprofile="coverage.txt" -covermode=atomic ./... | |
- name: Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
name: Codecov on ${{ matrix.os }}/${{ matrix.arch }} go${{ matrix.go }} | |
fail_ci_if_error: false |