mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
115 lines
5.2 KiB
YAML
115 lines
5.2 KiB
YAML
name: Test
|
|
|
|
on:
|
|
pull_request:
|
|
# ready_for_review: a Draft runs no Go suite (below); marking it ready starts one.
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# One run per PR (or per branch for pushes). A new push to a PR cancels the
|
|
# superseded run; runs on main are never cancelled so every merge gets a result.
|
|
concurrency:
|
|
group: test-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
test:
|
|
name: go test (linux)
|
|
# The suite writes heavily to the runner disk (real files, fsync), so a
|
|
# Draft PR skips it; its author tests locally until the PR is ready.
|
|
if: github.event_name == 'push' || !github.event.pull_request.draft
|
|
# Pushes and same-repo PRs run on the team's tp04 runner (seaweed.slice,
|
|
# capped at 8 cores / 8 GiB). Fork PRs never reach it: they stay on a
|
|
# GitHub-hosted runner.
|
|
runs-on: ${{ (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && 'tp04-seaweed-block' || 'ubuntu-latest' }}
|
|
timeout-minutes: 40
|
|
env:
|
|
# Pure-Go build: no package in the default build needs cgo, and the
|
|
# hosted runner should not depend on a C toolchain being present.
|
|
CGO_ENABLED: "0"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
|
with:
|
|
persist-credentials: false
|
|
# Two commits: the PR merge commit and its base parent, so the test
|
|
# step can see which packages the PR touches.
|
|
fetch-depth: 2
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
|
|
with:
|
|
go-version-file: go.mod
|
|
# The self-hosted runner keeps GOCACHE/GOMODCACHE on its own disk;
|
|
# uploading them as an Actions cache (~4 GB) in the post step
|
|
# outlasted the job timeout after every test had passed. Only the
|
|
# GitHub-hosted (fork PR) runner uses the Actions cache.
|
|
cache: ${{ runner.environment == 'github-hosted' }}
|
|
cache-dependency-path: go.sum
|
|
|
|
- name: Go version
|
|
run: go version
|
|
|
|
- name: Build
|
|
run: go build ./...
|
|
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
- name: Test default configuration
|
|
# The runner disk is shared, so the long, disk-heavy, timing-sensitive
|
|
# packages do not run here on main or on train PRs: every train runs the
|
|
# whole suite (both configurations) on a separate test VM before it
|
|
# merges, and main moves only by those trains. A PR runs the light set
|
|
# plus every heavy package its own diff touches.
|
|
env:
|
|
EVENT: ${{ github.event_name }}
|
|
HEAD_REF: ${{ github.head_ref }}
|
|
run: |
|
|
set -euo pipefail
|
|
pkgs=$(go list ./... | grep -vE '/core/(storage|frontend/durable|host/master|authority)$')
|
|
if [ "$EVENT" != push ] && [[ "$HEAD_REF" != train/* ]]; then
|
|
mod=$(go list -m)
|
|
changed=$(git diff --name-only HEAD^1 HEAD)
|
|
for p in core/storage core/frontend/durable core/host/master core/authority; do
|
|
if printf '%s\n' "$changed" | grep -qE "^$p/[^/]+$"; then
|
|
pkgs="$pkgs $mod/$p"
|
|
fi
|
|
done
|
|
fi
|
|
# 20m per package: core/storage alone took 602 s on tp04 on main
|
|
# (2026-11-22), past the old 10m, so any PR touching it failed.
|
|
go test -p=1 -short -count=1 -timeout 20m $pkgs
|
|
|
|
- name: Test planned hand-over (real binaries)
|
|
# The documented standalone planned hand-over and its refused clean
|
|
# move without the ACK (cmd/blockvolume TestStandalone*, build tags
|
|
# subprocess and chunkstore_integration, so the default pass above is
|
|
# unchanged) run real blockmaster, blockvolume and sw-block against a
|
|
# pinned SeaweedFS release. The release archive is checked against its
|
|
# sha256 before every use, also when taken from the runner's cache; a
|
|
# mismatch fails the step. Nothing else is fetched.
|
|
env:
|
|
WEED_VERSION: "4.53"
|
|
WEED_SHA256: d1a7dec9f48d8b33895a0ea8951971defc2dc5312906dcc76fa5a5f74a6ee90d
|
|
run: |
|
|
set -euo pipefail
|
|
cache="${RUNNER_TOOL_CACHE:-$RUNNER_TEMP}/seaweedfs-weed/$WEED_VERSION"
|
|
tgz="$cache/linux_amd64.tar.gz"
|
|
mkdir -p "$cache"
|
|
if ! echo "$WEED_SHA256 $tgz" | sha256sum -c --status - 2>/dev/null; then
|
|
part="$tgz.$$.part"
|
|
curl -fsSL --retry 3 -o "$part" "https://github.com/seaweedfs/seaweedfs/releases/download/$WEED_VERSION/linux_amd64.tar.gz"
|
|
echo "$WEED_SHA256 $part" | sha256sum -c - || { rm -f "$part"; exit 1; }
|
|
mv -f "$part" "$tgz"
|
|
fi
|
|
bin="$RUNNER_TEMP/weed-$WEED_VERSION"
|
|
mkdir -p "$bin"
|
|
tar -xzf "$tgz" -C "$bin" weed
|
|
CHUNKSTORE_WEED="$bin/weed" go test -tags 'subprocess chunkstore_integration' -count=1 -timeout 10m -run '^TestStandalone(PlannedHandoffToTheSameHost|CleanMoveWithoutTheACKIsRefused)$' ./cmd/blockvolume/
|