Files
ChuBlog/.github/workflows/linux.yml
T

132 lines
3.8 KiB
YAML

# Linux CI:构建 Rust 与 Haskell,运行各组件测试。
name: tests
on:
push:
pull_request:
merge_group:
workflow_dispatch:
workflow_call:
inputs:
phase:
type: string
default: tests
permissions:
contents: read
concurrency:
group: linux-${{ inputs.phase || 'tests' }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
LD_LIBRARY_PATH: ${{ github.workspace }}/chusql-core/storage/target/release
jobs:
linux:
name: ${{ inputs.phase || 'tests' }}
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
# ---------- Rust 存储 ----------
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
chusql-core/storage/target
key: ${{ runner.os }}-cargo-${{ hashFiles('chusql-core/storage/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: cargo build (release)
working-directory: chusql-core/storage
run: cargo build --release
- name: cargo test
if: inputs.phase != 'build' && inputs.phase != 'gate'
working-directory: chusql-core/storage
run: cargo test --release
- name: cargo clippy (-D warnings)
if: inputs.phase != 'build' && inputs.phase != 'gate'
working-directory: chusql-core/storage
run: cargo clippy --all-targets -- -D warnings
# 故意不做 rustfmt 检查:仓库里没有 rustfmt.toml,历史代码也不是按当前 rustfmt 的
# 默认风格排的,直接跑会报上百处折行与 use 排序差异;格式化不是本仓的门禁,别拿它
# 当交付标准。
# ---------- Haskell ----------
- name: Haskell toolchain
uses: haskell-actions/setup@v2
with:
ghc-version: '9.10.3'
enable-stack: true
stack-version: '3.11.1'
- name: Cache stack
uses: actions/cache@v4
with:
path: |
~/.stack
chusql-core/engine/.stack-work
chusql-bootstrap/.stack-work
chusql-server/.stack-work
chusql-web/.stack-work
chusql-cli/.stack-work
benchmark/.stack-work
key: ${{ runner.os }}-stack-${{ hashFiles('**/stack.yaml', '**/stack.yaml.lock') }}
restore-keys: ${{ runner.os }}-stack-
- name: stack build (cabal 里带 -Wall)
working-directory: chusql-cli
run: stack build --fast
- name: bootstrap build
working-directory: chusql-bootstrap
run: stack build --fast
- name: benchmark4csql build
working-directory: benchmark
run: stack build benchmark4csql --fast
- name: owner-triggered gate
if: inputs.phase == 'gate'
shell: pwsh
run: ./gate-check/run-gate.ps1
- name: engine tests
if: inputs.phase != 'build' && inputs.phase != 'gate'
working-directory: chusql-core/engine
run: stack test --fast
- name: server tests
if: inputs.phase != 'build' && inputs.phase != 'gate'
working-directory: chusql-server
run: stack test --fast
- name: web tests
if: inputs.phase != 'build' && inputs.phase != 'gate'
working-directory: chusql-web
run: stack test --fast
- name: cli tests
if: inputs.phase != 'build' && inputs.phase != 'gate'
working-directory: chusql-cli
run: stack test chusql-cli --fast
- name: bootstrap tests
if: inputs.phase != 'build' && inputs.phase != 'gate'
working-directory: chusql-bootstrap
run: stack test chusql-bootstrap --fast