summaryrefslogtreecommitdiff
path: root/.woodpecker.yaml
blob: 3e4bb1ae64eac8333b35a1d6df3564faa03bbd7d (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

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

jobs:

  test-and-check:
    runs-on: ubuntu-latest 
    strategy:
      matrix:
        rust: [ "stable", "beta" ] 
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust (${{ matrix.rust }})
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rust }}
          components: rustfmt, clippy 

      - name: Cache Cargo registry and index
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Lint with clippy
        run: cargo clippy --jobs 2 -- -D warnings 

      - name: Build
        run: cargo build --verbose --release --jobs 2 

      - name: Run tests
        run: cargo test --verbose --jobs 2

  build-cross:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target: [ x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu ] 
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          targets: ${{ matrix.target }} 

      - name: Cache Cargo registry and index
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-target-${{ matrix.target }}

      - name: Install cross-compilation tools
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt update
          sudo apt install -y gcc-aarch64-linux-gnu

      - name: Set up environment for cross-compilation
        run: |
          echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $CODEBERG_ENV
        if: matrix.target == 'aarch64-unknown-linux-gnu'

      - name: Build for ${{ matrix.target }}
        run: cargo build --target ${{ matrix.target }} --release --verbose --jobs 2 

#  release:
#    runs-on: ubuntu-latest
#    needs: [test-and-check, build-cross] # Запускается только если предыдущие задания прошли успешно
#    if: startsWith(github.ref, 'refs/tags/') # Запускается только при создании тега
#    steps:
#      - name: Checkout code
#        uses: actions/checkout@v4
#      - name: Install Rust stable
#        uses: dtolnay/rust-toolchain@stable
#        with:
#          toolchain: stable
#      - name: Build release
#        run: cargo build --release --verbose