Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
workflow_dispatch:

permissions:
Expand Down Expand Up @@ -53,22 +56,20 @@ jobs:
with:
targets: ${{ matrix.target }}

- run: sudo apt -y install musl-dev musl-tools
- name: Install Linux Dependencies
run: sudo apt -y install musl-dev musl-tools
if: matrix.build == 'linux'

- run: choco install openssl
if: matrix.build == 'windows'

- run: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath
$env:GITHUB_ENV -Append
- name: Install Windows Dependencies
run: |
choco install openssl
if: matrix.build == 'windows'

- name: Build Linux
- name: Set OpenSSL Directory on Windows
run: |
cargo build --release --locked --target ${{ matrix.target }} --features "openssl/vendored"
if: matrix.build == 'linux'
echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath $env:GITHUB_ENV -Append
if: matrix.build == 'windows'

- name: Build
run: |
cargo build --release --locked --target ${{ matrix.target }}
if: matrix.build != 'linux'
run: |-
cargo build --release --locked --target ${{ matrix.target }} ${{ matrix.build == 'linux' && '--features "openssl/vendored"' || '' }}
34 changes: 23 additions & 11 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ jobs:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Run tests
- name: Run tests with coverage flags
run: cargo test --verbose -- --nocapture
env:
RUST_BACKTRACE: full
Expand All @@ -27,19 +30,28 @@ jobs:
RUSTDOCFLAGS: -Cinstrument-coverage -Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off

- name: Install grcov
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
run: |
if [[ ! -x "$(command -v grcov)" ]]; then
cargo install grcov
fi

- name: Run grcov
run: grcov . --binary-path target/debug/ -s . -t lcov --branch --ignore-not-existing
--ignore '../**' --ignore '/*' -o coverage.lcov
- name: Generate coverage report
run: |
grcov . --binary-path target/debug/ \
-s . -t lcov --branch \
--ignore-not-existing \
--ignore '../**' --ignore '/*' \
-o coverage.lcov

- name: Upload to codecov.io
- name: Upload to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage.lcov
flags: rust
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Coveralls GitHub Action
- name: Upload to Coveralls
uses: coverallsapp/github-action@v2
with:
path-to-lcov: coverage.lcov
74 changes: 36 additions & 38 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,97 +17,95 @@ jobs:
branch: main

build:
name: Build and release
name: Build and Release
runs-on: ${{ matrix.os }}
needs: test

strategy:
matrix:
include:
- build: linux
os: ubuntu-latest
- os: ubuntu-latest
target: x86_64-unknown-linux-musl

- build: macos
os: macos-latest
- os: macos-latest
target: x86_64-apple-darwin

- build: windows
os: windows-latest
- os: windows-latest
target: x86_64-pc-windows-msvc

steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@v4

- name: Get the release version from the tag
- name: Extract release version from tag
if: startsWith(github.ref, 'refs/tags/')
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

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

- run: sudo apt -y install musl-dev musl-tools
if: matrix.build == 'linux'
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt -y install musl-dev musl-tools

- run: choco install openssl
if: matrix.build == 'windows'
- name: Install Windows dependencies
if: matrix.os == 'windows-latest'
run: choco install openssl

- run: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath
$env:GITHUB_ENV -Append
if: matrix.build == 'windows'
- name: Set OpenSSL directory on Windows
if: matrix.os == 'windows-latest'
run: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' >> $GITHUB_ENV

- name: Build
- name: Build project
run: cargo build --release --locked --target ${{ matrix.target }}

- name: Build archive
- name: Archive build output
shell: bash
run: |
binary_name="backup"

dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"

# Move binary to the directory
if [ "${{ matrix.os }}" == "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname/"
else
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname/"
fi

if [ "${{ matrix.os }}" = "windows-latest" ]; then
# Compress the directory
if [ "${{ matrix.os }}" == "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi

- name: Release
- name: Release to GitHub
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: |-
${{ env.ASSET }}
files: ${{ env.ASSET }}

publish:
name: Publish
name: Publish to Crates.io
runs-on: ubuntu-latest
needs:
- build
needs: build
steps:
- name: Checkout sources
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable

- run: cargo publish --token ${CRATES_TOKEN}
- name: Publish to Crates.io
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
run: cargo publish --token $CRATES_TOKEN

package:
name: PackageCloud
needs:
- build
name: Publish to PackageCloud
needs: build
uses: ./.github/workflows/packagecloud.yml
secrets: inherit
47 changes: 28 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,70 @@ name: Test

on:
workflow_call:
pull_request:
branches:
- '*'

jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Format
- name: Run formatter
run: cargo fmt --all -- --check

lint:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Clippy
- name: Run Clippy linter
run: cargo clippy -- -D clippy::all -D clippy::nursery -D warnings

check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Checkout code
uses: actions/checkout@v4

- name: Check
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Run cargo check
run: cargo check

test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
rust:
- stable
runs-on: ${{ matrix.os }}

needs:
- format
- lint
- check

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: test
run: cargo test
- name: Run tests
run: cargo test -- --nocapture
2 changes: 1 addition & 1 deletion .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ clippy:
coverage:
CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='coverage-%p-%m.profraw' cargo test
grcov . --binary-path ./target/debug/deps/ -s . -t html --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/html
firefox target/coverage/html/index.html
rm -rf *.profraw
firefox target/coverage/html/index.html&
Loading