ci: define the test dataset inline instead of fetching it from the re… #285
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 | |
| on: | |
| push: | |
| branches: ['trunk'] | |
| pull_request: | |
| branches: ['trunk'] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build and test ${{matrix.os}} go${{matrix.go-version}} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| go-version: ['1.25', '1.26'] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Vet | |
| run: go vet -v ./... | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v8 | |
| with: | |
| version: v2.12 | |
| - name: Build | |
| run: go build -v ./... | |
| # The Spice runtime cannot be installed or run natively on Windows, so the | |
| # Windows job runs the runtime-free unit tests natively and defers the | |
| # runtime install + integration tests to WSL (see the WSL steps below). | |
| - name: Unit tests (Windows native) | |
| if: matrix.os == 'windows-latest' | |
| run: go test -v -run 'TestUserAgent|TestPrependedUserAgent|TestInferArrowType|TestAppendValueToBuilder|TestComprehensiveArrowTypes|TestParamType|TestTypedParamInference|TestExtendedArrowTypes|TestSearch|TestNsql|TestListActiveQueries|TestCancelActiveQuery|TestActiveQueryStartedAt' ./... | |
| - name: Install Spice (https://install.spiceai.org) (Linux) | |
| if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Retry helper for flaky network installs. | |
| retry() { | |
| local n | |
| for n in 1 2 3; do | |
| if "$@"; then return 0; fi | |
| echo "::warning::attempt ${n}/3 failed: $*" | |
| sleep 5 | |
| done | |
| return 1 | |
| } | |
| retry bash -c 'curl -sSL https://install.spiceai.org | /bin/bash' | |
| echo "$HOME/.spice/bin" >> $GITHUB_PATH | |
| retry "$HOME/.spice/bin/spice" install | |
| - name: Init and start spice app (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| # Retry helper for flaky network installs. | |
| retry() { | |
| local n | |
| for n in 1 2 3; do | |
| if "$@"; then return 0; fi | |
| echo "::warning::attempt ${n}/3 failed: $*" | |
| sleep 5 | |
| done | |
| return 1 | |
| } | |
| spice init spice_qs | |
| cd spice_qs | |
| # Define the dataset inline instead of `spice add spiceai/quickstart`. | |
| # Fetching it from the Spicepod registry makes every PR depend on a | |
| # remote service; when that service began returning a non-zip body, | |
| # every run failed at "Failed to extract Spicepod archive: Could not | |
| # find EOCD". This is the dataset spiceai/quickstart defines. | |
| cat >> spicepod.yaml <<'YAML' | |
| datasets: | |
| - from: s3://spiceai-demo-datasets/taxi_trips/2024/ | |
| name: taxi_trips | |
| description: taxi trips in s3 | |
| params: | |
| file_format: parquet | |
| acceleration: | |
| enabled: true | |
| YAML | |
| spice run &> spice.log & | |
| # Wait for Spice to be ready | |
| echo "Waiting for Spice to be ready..." | |
| for i in {1..60}; do | |
| # -f fails on non-2xx; /v1/ready returns 200 only once datasets are | |
| # loaded. (A substring `grep "ready"` also matches "not ready".) | |
| if curl -fs http://localhost:8090/v1/ready >/dev/null 2>&1; then | |
| echo "Spice is ready!" | |
| break | |
| fi | |
| echo "Waiting... ($i/60)" | |
| sleep 1 | |
| done | |
| - name: Test | |
| if: matrix.os != 'windows-latest' | |
| env: | |
| SPICE_API_KEY: ${{ secrets.SPICE_CLOUD_API_KEY }} | |
| run: go test -v ./... | |
| # Native Windows local runtime is unsupported ("Open WSL and run the Linux | |
| # Spice CLI there instead"), so the integration tests run inside WSL against | |
| # a Linux Spice runtime. | |
| - name: Set up WSL (Windows) | |
| if: matrix.os == 'windows-latest' | |
| uses: Vampire/setup-wsl@v7 | |
| with: | |
| # Ubuntu 24.04 (glibc 2.39) — the Spice binary requires glibc >= 2.38. | |
| distribution: Ubuntu-24.04 | |
| additional-packages: curl ca-certificates git | |
| # Forward the workspace path and API key into every wsl-bash step. | |
| - name: Configure WSLENV (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: bash | |
| run: echo "WSLENV=GITHUB_WORKSPACE:SPICE_API_KEY" >> "$GITHUB_ENV" | |
| - name: Install Spice and run integration tests in WSL (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: wsl-bash {0} | |
| env: | |
| SPICE_API_KEY: ${{ secrets.SPICE_CLOUD_API_KEY }} | |
| run: | | |
| # Retry helper for flaky network installs. | |
| retry() { | |
| local n | |
| for n in 1 2 3; do | |
| if "$@"; then return 0; fi | |
| echo "::warning::attempt ${n}/3 failed: $*" | |
| sleep 5 | |
| done | |
| return 1 | |
| } | |
| # Install a current Go toolchain inside the WSL distribution. | |
| GO_VER="$(curl -fsSL --retry 3 'https://go.dev/VERSION?m=text' | head -1)" | |
| echo "Installing ${GO_VER} in WSL" | |
| curl -fsSL --retry 3 "https://go.dev/dl/${GO_VER}.linux-amd64.tar.gz" -o /tmp/go.tgz | |
| rm -rf /usr/local/go && tar -C /usr/local -xzf /tmp/go.tgz | |
| export PATH="/usr/local/go/bin:${HOME}/.spice/bin:${PATH}" | |
| go version | |
| # Enter the checked-out repo (Windows workspace, mounted under /mnt). | |
| cd "$(wslpath -u "${GITHUB_WORKSPACE}")" | |
| # Install the Spice CLI and runtime (downloads can be flaky, so retry). | |
| retry bash -c 'curl -sSL https://install.spiceai.org | /bin/bash' | |
| retry spice install | |
| # Start a quickstart runtime. | |
| spice init spice_qs | |
| cd spice_qs | |
| # Define the dataset inline instead of `spice add spiceai/quickstart`. | |
| # Fetching it from the Spicepod registry makes every PR depend on a | |
| # remote service; when that service began returning a non-zip body, | |
| # every run failed at "Failed to extract Spicepod archive: Could not | |
| # find EOCD". This is the dataset spiceai/quickstart defines. | |
| cat >> spicepod.yaml <<'YAML' | |
| datasets: | |
| - from: s3://spiceai-demo-datasets/taxi_trips/2024/ | |
| name: taxi_trips | |
| description: taxi trips in s3 | |
| params: | |
| file_format: parquet | |
| acceleration: | |
| enabled: true | |
| YAML | |
| nohup spice run > spice.log 2>&1 & | |
| cd .. | |
| echo "Waiting for Spice to be ready..." | |
| for i in $(seq 1 90); do | |
| if curl -fs http://localhost:8090/v1/ready >/dev/null 2>&1; then | |
| echo "Spice is ready!" | |
| break | |
| fi | |
| echo "Waiting... ($i/90)" | |
| sleep 2 | |
| done | |
| go test -v ./... | |
| - name: Print Spice logs (Unix) | |
| if: always() && matrix.os != 'windows-latest' | |
| run: | | |
| echo "=== Spice Runtime Logs ===" | |
| cat spice_qs/spice.log || echo "No log file found" | |
| - name: Print Spice logs (WSL) (Windows) | |
| if: always() && matrix.os == 'windows-latest' | |
| shell: wsl-bash {0} | |
| run: | | |
| cd "$(wslpath -u "${GITHUB_WORKSPACE:-}" 2>/dev/null)" 2>/dev/null || true | |
| echo "=== Spice Runtime Logs (WSL) ===" | |
| cat spice_qs/spice.log 2>/dev/null || echo "No log file found" |