Merge pull request #16 from xushiwei/xgo #57
This file contains hidden or 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
| name: Go CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| permissions: | |
| contents: read | |
| jobs: | |
| fmt: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22.x' | |
| cache: true | |
| - name: Go fmt check | |
| run: | | |
| unformatted="$(gofmt -l .)" | |
| if [ -n "$unformatted" ]; then | |
| echo "The following files need gofmt:" | |
| echo "$unformatted" | |
| exit 1 | |
| fi | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install LLVM 19 | |
| run: | | |
| echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm-snapshot.asc >/dev/null | |
| sudo apt-get update | |
| sudo apt-get install -y llvm-19-dev clang-19 libclang-19-dev lld-19 libunwind-19-dev libc++-19-dev | |
| echo "PATH=/usr/lib/llvm-19/bin:$PATH" >> $GITHUB_ENV | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.26.x' | |
| cache: true | |
| - name: Go build | |
| run: go build ./... | |
| - name: Go build (cmd/plan9asm) | |
| run: go build ./... | |
| working-directory: cmd/plan9asm | |
| - name: Go build (cmd/plan9asmll) | |
| run: go build ./... | |
| working-directory: cmd/plan9asmll | |
| stdlib-corpus: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| go-version: | |
| - '1.21.x' | |
| - '1.22.x' | |
| - '1.23.x' | |
| - '1.24.x' | |
| - '1.25.x' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install LLVM 19 (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm-snapshot.asc >/dev/null | |
| sudo apt-get update | |
| sudo apt-get install -y llvm-19-dev clang-19 libclang-19-dev lld-19 libunwind-19-dev libc++-19-dev | |
| echo "PATH=/usr/lib/llvm-19/bin:$PATH" >> $GITHUB_ENV | |
| - name: Install LLVM 19 (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install llvm@19 | |
| echo "PATH=$(brew --prefix llvm@19)/bin:$PATH" >> $GITHUB_ENV | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache: true | |
| - name: Stdlib asm corpus gate | |
| run: | | |
| chmod +x scripts/check-stdlib-corpus.sh | |
| scripts/check-stdlib-corpus.sh | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| # Keep both matrix variants visible even if one fails. | |
| fail-fast: false | |
| matrix: | |
| go-version: | |
| - '1.21.x' | |
| - '1.22.x' | |
| - '1.23.x' | |
| - '1.24.x' | |
| - '1.25.x' | |
| - '1.26.x' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache: true | |
| - name: Install LLVM 19 | |
| run: | | |
| echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm-snapshot.asc >/dev/null | |
| sudo apt-get update | |
| sudo apt-get install -y llvm-19-dev clang-19 libclang-19-dev lld-19 libunwind-19-dev libc++-19-dev | |
| echo "PATH=/usr/lib/llvm-19/bin:$PATH" >> $GITHUB_ENV | |
| - name: LLVM tools info | |
| run: | | |
| which llc | |
| llc --version | |
| which clang | |
| clang --version | |
| - name: Go test | |
| run: go test ./... | |
| - name: Go test (cmd/plan9asm) | |
| run: go test ./... | |
| working-directory: cmd/plan9asm | |
| - name: Go test (cmd/plan9asmll) | |
| run: go test ./... | |
| working-directory: cmd/plan9asmll | |
| arm-scan: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| goos: | |
| - android | |
| - freebsd | |
| - linux | |
| - netbsd | |
| - openbsd | |
| - plan9 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install LLVM 19 | |
| run: | | |
| echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm-snapshot.asc >/dev/null | |
| for attempt in 1 2 3; do | |
| sudo apt-get update && sudo apt-get install -y llvm-19-dev clang-19 libclang-19-dev lld-19 libunwind-19-dev libc++-19-dev && break | |
| if [ "$attempt" -eq 3 ]; then | |
| exit 1 | |
| fi | |
| sleep 5 | |
| done | |
| echo "PATH=/usr/lib/llvm-19/bin:$PATH" >> $GITHUB_ENV | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.26.1' | |
| cache: true | |
| - name: ARM scan gate | |
| env: | |
| TARGET_GOOS: ${{ matrix.goos }} | |
| run: | | |
| go run ./cmd/plan9asmscan -goos="$TARGET_GOOS" -goarch=arm -repo-root . -format json -out scan.json | |
| python3 - "$PWD/scan.json" "$TARGET_GOOS/arm" <<'PY' | |
| import json | |
| import sys | |
| path, target = sys.argv[1], sys.argv[2] | |
| with open(path, "r", encoding="utf-8") as f: | |
| data = json.load(f) | |
| unsupported = data.get("unsupported", []) | |
| parse_errs = data.get("parse_errs") or [] | |
| print(f"scan {target}: packages={data['std_pkgs_with_sfile']} files={data['asm_files']} unsupported={len(unsupported)} parse_errs={len(parse_errs)}") | |
| if unsupported: | |
| top = ", ".join(f"{item['op']}({item['count']})" for item in unsupported[:12]) | |
| raise SystemExit(f"{target}: unsupported ops remain: {top}") | |
| if parse_errs: | |
| top = ", ".join(f"{item['File']}: {item['Err']}" for item in parse_errs[:8]) | |
| raise SystemExit(f"{target}: parse errors remain: {top}") | |
| PY | |
| race: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22.x' | |
| cache: true | |
| - name: Install LLVM 19 | |
| run: | | |
| echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm-snapshot.asc >/dev/null | |
| sudo apt-get update | |
| sudo apt-get install -y llvm-19-dev clang-19 libclang-19-dev lld-19 libunwind-19-dev libc++-19-dev | |
| echo "PATH=/usr/lib/llvm-19/bin:$PATH" >> $GITHUB_ENV | |
| - name: Go test (race) | |
| run: go test -race ./... | |
| coverage: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25.x' | |
| cache: true | |
| - name: Install LLVM 19 | |
| run: | | |
| echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm-snapshot.asc >/dev/null | |
| sudo apt-get update | |
| sudo apt-get install -y llvm-19-dev clang-19 libclang-19-dev lld-19 libunwind-19-dev libc++-19-dev | |
| echo "PATH=/usr/lib/llvm-19/bin:$PATH" >> $GITHUB_ENV | |
| - name: Go test with coverage | |
| run: | | |
| go test ./... -coverprofile=coverage-root.out | |
| go tool cover -func=coverage-root.out | tail -n 1 | |
| - name: Go test with coverage (cmd/plan9asm) | |
| run: | | |
| go test ./... -coverprofile=coverage-plan9asm.out | |
| go tool cover -func=coverage-plan9asm.out | tail -n 1 | |
| working-directory: cmd/plan9asm | |
| - name: Go test with coverage (cmd/plan9asmll) | |
| run: | | |
| go test ./... -coverprofile=coverage-plan9asmll.out | |
| go tool cover -func=coverage-plan9asmll.out | tail -n 1 | |
| working-directory: cmd/plan9asmll | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| use_oidc: true | |
| files: ./coverage-root.out | |
| flags: unittests | |
| name: ubuntu-go1.25 | |
| fail_ci_if_error: false | |
| verbose: true |