summaryrefslogtreecommitdiff
path: root/.github/workflows/rust.yml
blob: e2d6cbbce57428aae4a768512666ecfb90f63e4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: JustEnoughVCS

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-D warnings"
  CARGO_BUILD_TARGET: x86_64-unknown-linux-musl

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install Rust
      uses: actions-rust-lang/setup-rust-toolchain@v1
      with:
        toolchain: stable
        components: clippy, rustfmt
    - name: Run clippy
      run: cargo clippy --workspace --all-targets -- -D warnings
    - name: Check formatting
      run: cargo fmt --check

  test:
    runs-on: ubuntu-latest
    needs: lint
    steps:
    - uses: actions/checkout@v4
    
    - name: Cache cargo registry
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
        restore-keys: |
          ${{ runner.os }}-cargo-
    
    - name: Install musl target
      run: rustup target add x86_64-unknown-linux-musl
      
    - name: Build
      run: cargo build --workspace --verbose --target x86_64-unknown-linux-musl
      
    - name: Run tests
      run: cargo test --workspace --verbose --target x86_64-unknown-linux-musl
      
    - name: Check binary compatibility
      run: |
        cargo build --workspace --release --target x86_64-unknown-linux-musl
        find target/x86_64-unknown-linux-musl/release -maxdepth 1 -executable -type f | head -5 | xargs -I {} file {}
        echo "Built binaries are statically linked:"
        find target/x86_64-unknown-linux-musl/release -maxdepth 1 -executable -type f | head -5 | xargs -I {} ldd {} 2>&1 | grep -q "not a dynamic executable" && echo "✓ All binaries are static"

  release:
    runs-on: ubuntu-latest
    needs: test
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    
    steps:
    - uses: actions/checkout@v4
    
    - name: Install musl target
      run: rustup target add x86_64-unknown-linux-musl
      
    - name: Build release binaries
      run: cargo build --workspace --release --target x86_64-unknown-linux-musl
      
    - name: Upload artifacts
      uses: actions/upload-artifact@v3
      with:
        name: release-binaries
        path: target/x86_64-unknown-linux-musl/release/