ci
This commit is contained in:
25
.gitea/workflows/deploy.yml
Normal file
25
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
workflow_run:
|
||||
workflows: ["CI"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Deploy to Dokku
|
||||
uses: dokku/github-action@master
|
||||
with:
|
||||
git_remote_url: 'ssh://dokku@staging.discours.io:22/quoter'
|
||||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
@@ -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 }}
|
||||
59
.gitea/workflows/release.yml
Normal file
59
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- 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 release
|
||||
run: cargo build --release --verbose
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --release --verbose --tests
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Upload Release Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./target/release/quoter
|
||||
asset_name: quoter-linux-x86_64
|
||||
asset_content_type: application/octet-stream
|
||||
Reference in New Issue
Block a user