Files
skillshare/.github/workflows/test.yaml
T
Willie 92183d5a09 test(windows): run audit, config, install, mcp and cmd tests on Windows CI
These packages were left out of the windows-test job because of failures
that came from test assumptions (POSIX paths, permission bits, HOME,
bash shims posing as git), not product behavior. Fix them and add the
packages to the list so they stay green.

Two failures were real product bugs:
- swapStagedIntoSource named its backup like the temp that
  sourcefs.MoveIn creates beside it. On a coarse clock (Windows) both
  names matched, the failed move removed the temp and with it the
  backup, and the old skill was lost.
- MetadataStore.GetByPath looked up OS-native paths in slash-form keys,
  so `update --group` missed nested skills on Windows.

The test sandbox now also sets USERPROFILE, which os.UserHomeDir reads
on Windows; tests were reading the real profile.

Refs #344
2026-10-06 10:46:37 +08:00

197 lines
6.0 KiB
YAML

name: Test
on:
push:
branches: [main]
paths-ignore:
- "website/**"
- "README.md"
- "CHANGELOG.md"
pull_request:
branches: [main]
paths-ignore:
- "website/**"
- "README.md"
- "CHANGELOG.md"
schedule:
- cron: "0 3 * * *"
workflow_dispatch:
workflow_call:
inputs:
ref:
description: Exact commit to verify for a release
type: string
default: ""
# A newer push to a pull request supersedes its running tests; other events keep their own run.
concurrency:
group: ${{ github.event_name == 'pull_request' && format('test-pr-{0}', github.event.pull_request.number) || format('test-{0}', github.run_id) }}
cancel-in-progress: true
jobs:
unit-test:
# Release Please tests a merged Release PR at its exact SHA (inputs.ref) before tagging,
# so the push run for that same commit is skipped. Release PR runs stay: they are required checks.
if: &not-release-duplicate "${{ !(github.event_name == 'push' && !inputs.ref && startsWith(github.event.head_commit.message, 'chore(main): release ')) }}"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Check AI context routes
run: python3 scripts/ai-context.py check
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
run: make build
- name: Formatting, lint and release metadata tests
run: |
make fmt-check lint
python3 -B -m unittest discover -s scripts/release -p '*_test.py'
python3 -B -m unittest discover -s scripts/design -p '*_test.py'
- name: Unit Tests
run: go test -v -race ./cmd/skillshare/... ./internal/...
integration-test:
if: *not-release-duplicate
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build Binary
run: make build
- name: Integration Tests
run: go test -v -race ./tests/integration/...
env:
SKILLSHARE_TEST_BINARY: ${{ github.workspace }}/bin/skillshare
windows-test:
# Releases publish windows_amd64 and windows_arm64 archives, and `_windows.go` files are compiled
# only on Windows, yet every job above runs on Linux or macOS: a Windows-only regression reaches
# users at release time instead of at review.
# This job starts with the packages that already pass on windows-latest, so it is green on
# arrival. #344 lists the packages that do not pass there and the failures behind them; each fix
# adds its package back to this list.
# No -race: the race detector needs a C toolchain on Windows, and ubuntu and macOS cover it.
# -count=1 so that a cached result cannot report a pass for a package that never ran.
if: *not-release-duplicate
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Unit Tests
shell: bash
run: |
go test -v -count=1 \
./cmd/skillshare \
./internal/audit \
./internal/backup \
./internal/check \
./internal/childproc \
./internal/config \
./internal/hub \
./internal/install \
./internal/instructions \
./internal/mcp \
./internal/projectdir \
./internal/resource \
./internal/search \
./internal/skill \
./internal/skillignore \
./internal/sync \
./internal/trash \
./internal/ui \
./internal/uidist \
./internal/utils \
./internal/validate \
./internal/version
docker-sandbox-offline:
if: *not-release-duplicate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Docker Sandbox Tests (Offline)
run: ./scripts/test_docker.sh
docker-sandbox-online:
runs-on: ubuntu-latest
if: "${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && !(github.event_name == 'push' && !inputs.ref && startsWith(github.event.head_commit.message, 'chore(main): release ')) }}"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Docker Sandbox Tests (Online)
run: ./scripts/test_docker_online.sh
redteam:
if: *not-release-duplicate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Red Team Test
run: make test-redteam
redteam-signal:
runs-on: ubuntu-latest
if: "${{ (github.event_name == 'push' && (inputs.ref || !startsWith(github.event.head_commit.message, 'chore(main): release '))) || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Red Team Signal (Code Mutation)
run: make test-redteam-signal
- name: Red Team Signal (Rules Disable)
run: make test-redteam-rules-signal