name: CI on: push: branches: [ main, dev ] pull_request: branches: [ main, dev ] jobs: test: runs-on: ubuntu-latest services: redis: image: redis ports: - 6379:6379 steps: - uses: actions/checkout@v2 - name: Install Rust uses: actions-rs/toolchain@v1 with: toolchain: stable override: true components: rustfmt, clippy - name: Install cargo-llvm-cov manually 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 tar xf cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz chmod +x cargo-llvm-cov mv cargo-llvm-cov $HOME/.cargo/bin/ echo "$HOME/.cargo/bin" >> $GITHUB_PATH rm cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz - name: Generate code coverage run: | cargo llvm-cov --lcov --output-path lcov.info cargo llvm-cov --html - name: Extract Coverage Percentage id: coverage run: | COVERAGE=$(cargo llvm-cov --summary | grep -oP 'coverage: \K[0-9.]+%' || echo "0%") echo "total_coverage=$COVERAGE" >> $GITHUB_OUTPUT - 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 - name: Upload coverage HTML uses: actions/upload-artifact@v3 with: name: code-coverage path: target/llvm-cov/html - name: Upload LCOV report uses: actions/upload-artifact@v3 with: name: lcov-report path: lcov.info lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install Rust uses: actions-rs/toolchain@v1 with: toolchain: stable override: true components: rustfmt, clippy - 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 }}