name: Compatibility Test Linux-X64|ARM

on: pull_request

jobs:
  build:
    strategy:
      matrix:
        go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x]
        os: [ubuntu-latest, ubuntu-24.04-arm]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Clear repository
        run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE

      - uses: actions/checkout@v2

      - name: Set up Go
        uses: actions/setup-go@v6
        with:
          go-version: ${{ matrix.go-version }}

      - uses: actions/cache@v4
        with:
          path: ~/go/pkg/mod
          key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-

      - name: main
        run: go test -race -gcflags="all=-l" ./

      - name: decoder
        run: go test -race -gcflags="all=-l" ./decoder

      - name: encoder
        run: go test -race -gcflags="all=-l" ./encoder

      - name: ast
        run: go test -race -gcflags="all=-l" ./ast
