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
176 changes: 176 additions & 0 deletions .github/workflows/rust-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Rust Services CI

on:
push:
branches: [main, develop]
paths:
- 'rust-services/**'
- '.github/workflows/rust-services.yml'
pull_request:
branches: [main, develop]
paths:
- 'rust-services/**'
- '.github/workflows/rust-services.yml'

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-action@stable
with:
components: clippy, rustfmt

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
rust-services/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('rust-services/**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Check formatting
working-directory: rust-services
run: cargo fmt --all -- --check

- name: Clippy
working-directory: rust-services
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Check
working-directory: rust-services
run: cargo check --all-targets

test:
name: Test
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4

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

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
rust-services/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('rust-services/**/Cargo.lock') }}

- name: Run tests
working-directory: rust-services
run: cargo test --all-features --verbose

benchmark:
name: Benchmark
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4

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

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
rust-services/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('rust-services/**/Cargo.lock') }}

- name: Run benchmarks
working-directory: rust-services
run: cargo bench --package benchmarks -- --noplot

- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: rust-services/target/criterion/

build:
name: Build
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
service: [shape-validator, realtime-sync, render-service]
steps:
- uses: actions/checkout@v4

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

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
rust-services/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('rust-services/**/Cargo.lock') }}

- name: Build release
working-directory: rust-services
run: cargo build --release --package ${{ matrix.service }}

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.service }}-linux-amd64
path: rust-services/target/release/${{ matrix.service }}

docker:
name: Docker Build
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
strategy:
matrix:
service: [shape-validator, realtime-sync, render-service]
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: rust-services
file: rust-services/${{ matrix.service }}/Dockerfile
push: true
tags: |
devstroop/penpot-${{ matrix.service }}:latest
devstroop/penpot-${{ matrix.service }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
Loading
Loading