diff options
Diffstat (limited to '.codeberg/actions.yml')
| -rw-r--r-- | .codeberg/actions.yml | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/.codeberg/actions.yml b/.codeberg/actions.yml new file mode 100644 index 0000000..85f4d2d --- /dev/null +++ b/.codeberg/actions.yml @@ -0,0 +1,96 @@ + +on: + 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 -- -D warnings + + - name: Build + run: cargo build --verbose + + - name: Run tests + run: cargo test --verbose + + 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" >> $GITHUB_ENV + if: matrix.target == 'aarch64-unknown-linux-gnu' + + - name: Build for ${{ matrix.target }} + run: cargo build --target ${{ matrix.target }} --release --verbose + +# 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 |
