ci
This commit is contained in:
@@ -6,6 +6,9 @@ on:
|
||||
pull_request:
|
||||
branches: [ main, dev ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -25,7 +28,21 @@ jobs:
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Install cargo-llvm-cov manually
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-
|
||||
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
|
||||
- name: Install cargo-llvm-cov
|
||||
run: |
|
||||
mkdir -p $HOME/.cargo/bin
|
||||
curl -LO https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz
|
||||
@@ -35,6 +52,9 @@ jobs:
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
rm cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --verbose --tests
|
||||
|
||||
- name: Generate code coverage
|
||||
run: |
|
||||
cargo llvm-cov --lcov --output-path lcov.info
|
||||
@@ -45,16 +65,14 @@ jobs:
|
||||
run: |
|
||||
COVERAGE=$(cargo llvm-cov --summary | grep -oP 'coverage: \K[0-9.]+%' || echo "0%")
|
||||
echo "total_coverage=$COVERAGE" >> $GITHUB_OUTPUT
|
||||
echo "Coverage: $COVERAGE"
|
||||
|
||||
- name: Create Coverage Badge
|
||||
uses: schneegans/dynamic-badges-action@v1.6.0
|
||||
with:
|
||||
auth: ${{ secrets.GIST_SECRET }}
|
||||
gistID: your_gist_id_here
|
||||
filename: coverage.json
|
||||
label: coverage
|
||||
message: ${{ steps.coverage.outputs.total_coverage }}
|
||||
color: green
|
||||
run: |
|
||||
COVERAGE=$(cargo llvm-cov --summary | grep -oP 'coverage: \K[0-9.]+' || echo "0")
|
||||
echo "" > coverage-badge.md
|
||||
echo "Coverage badge created: ${COVERAGE}%"
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload coverage HTML
|
||||
uses: actions/upload-artifact@v3
|
||||
@@ -68,6 +86,12 @@ jobs:
|
||||
name: lcov-report
|
||||
path: lcov.info
|
||||
|
||||
- name: Upload Coverage Badge
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage-badge
|
||||
path: coverage-badge.md
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -80,19 +104,20 @@ jobs:
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-
|
||||
|
||||
- name: Check formatting
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
- name: Clippy
|
||||
run: cargo clippy -- -D warnings
|
||||
|
||||
deploy:
|
||||
needs: [test, lint]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Deploy to Dokku
|
||||
uses: dokku/github-action@master
|
||||
with:
|
||||
git_remote_url: 'ssh://dokku@staging.discours.io:22/inbox'
|
||||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
Reference in New Issue
Block a user