Skip to content

Commit

Permalink
add github wrokflows
Browse files Browse the repository at this point in the history
  • Loading branch information
robatipoor committed Nov 1, 2023
1 parent 5df6f73 commit 31cce21
Show file tree
Hide file tree
Showing 9 changed files with 414 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daly"
41 changes: 41 additions & 0 deletions .github/workflows/build-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: binary build checker
on:
push:
branches: ["main","develop"]

env:
CARGO_TERM_COLOR: always
RUST_LOG: info

jobs:
check:
name: cargo check
runs-on: ubuntu-latest
env:
SQLX_OFFLINE: true
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

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

- name: Run cargo check
run: cargo check --tests
24 changes: 24 additions & 0 deletions .github/workflows/code-formater.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: format checker
on:
push:
branches: ["main","develop"]

env:
CARGO_TERM_COLOR: always
RUST_LOG: info

jobs:
fmt:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
27 changes: 27 additions & 0 deletions .github/workflows/code-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: code linter
on:
push:
branches: ["main","develop"]

env:
CARGO_TERM_COLOR: always
RUST_LOG: info

jobs:
clippy:
name: cargo clippy
runs-on: ubuntu-latest
env:
SQLX_OFFLINE: true
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: clippy
override: true
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features

41 changes: 41 additions & 0 deletions .github/workflows/image-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: build docker image

on:
push:
branches: ["main"]

env:
CARGO_TERM_COLOR: always
RUST_LOG: info

jobs:
build:
name: build image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/rustfulapi:latest

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
14 changes: 14 additions & 0 deletions .github/workflows/security-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: security checker
on:
push:
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions .github/workflows/spell-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: spell checker
on: [pull_request]

env:
CARGO_TERM_COLOR: always
RUST_LOG: info

jobs:
typos:
name: typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3

- name: Check spelling
uses: crate-ci/typos@master
108 changes: 108 additions & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: test coverage

on:
push:
branches: ["main"]

jobs:
test:
name: coverage
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: postgres_pass
POSTGRES_DB: postgres_db
ports:
- 5432:5432
redis:
image: redis:latest
ports:
- 6379:6379
mailhog:
image: mailhog/mailhog:latest
ports:
- 1025:1025
- 8025:8025
mockserver:
image: mockserver/mockserver:latest
env:
MOCKSERVER_LOG_LEVEL: DEBUG
SERVER_PORT: 8026
ports:
- 8026:8026
env:
APP_PROFILE: test
SQLX_VERSION: 0.7.1
SQLX_FEATURES: postgres
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Cache sqlx-cli
uses: actions/cache@v3
id: cache-sqlx
with:
path: |
~/.cargo/bin/sqlx
~/.cargo/bin/cargo-sqlx
key: ${{ runner.os }}-sqlx-${{ env.SQLX_VERSION }}-${{ env.SQLX_FEATURES }}

- name: Install sqlx-cli
uses: actions-rs/cargo@v1
if: steps.cache-sqlx.outputs.cache-hit == false
with:
command: install
args: >
sqlx-cli
--force
--version=${{ env.SQLX_VERSION }}
--features=native-tls,${{ env.SQLX_FEATURES }}
--no-default-features
--locked
- name: Cache tarpaulin
uses: actions/cache@v3
id: cache-tarpaulin
with:
path: |
~/.cargo/bin/cargo-tarpaulin
key: ${{ runner.os }}-sqlx-${{ env.SQLX_VERSION }}-${{ env.SQLX_FEATURES }}

- name: Install tarpaulin
uses: actions-rs/cargo@v1
if: steps.cache-sqlx.outputs.cache-hit == false
with:
command: install
args: >
cargo-tarpaulin
- name: Migrate database
run: |
sudo apt-get install -y libpq-dev
./scripts/init_postgres.sh
- name: Add mockserver expections
run: |
./scripts/init_mockserver.sh
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate code coverage
run: |
cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
#token: ${{secrets.CODECOV_TOKEN}} # not required for public repos
fail_ci_if_error: true
Loading

0 comments on commit 31cce21

Please sign in to comment.