-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ouyangkang
committed
Mar 8, 2024
1 parent
7060da0
commit 8807367
Showing
3 changed files
with
49 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,44 @@ | ||
name: CI | ||
name: YUM Backend Rust Server | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
pull_request: | ||
|
||
env: | ||
RUST_TOOLCHAIN: stable | ||
TOOLCHAIN_PROFILE: minimal | ||
branches: [ "main" ] | ||
# tags: | ||
# - v* | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
rustfmt: | ||
name: Check Style | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
components: rustfmt | ||
- name: Run cargo fmt | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
|
||
clippy: | ||
name: Run Clippy | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
- name: Setup Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Run cargo clippy | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery -W rust-2018-idioms | ||
|
||
test: | ||
name: Run Tests | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
services: | ||
redis: | ||
image: redis | ||
options: >- | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- "6379:6379" | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_DB: postgress_test | ||
POSTGRES_USER: postgress | ||
POSTGRES_PASSWORD: postgress | ||
ports: | ||
- "5432:5432" | ||
# Set health checks to wait until postgres has started | ||
options: --health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
- name: Setup Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Run cargo test | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --all-features --all | ||
env: | ||
REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} | ||
DATABASE_URL: postgres://postgress:postgress@localhost:5432/postgress_test | ||
- name: Checkout Project | ||
uses: actions/checkout@v3 | ||
|
||
- 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: setup versioning | ||
id: vars | ||
run: | | ||
commit_short_hash="$(git rev-parse --short HEAD)" | ||
echo "commit_short_hash=$commit_short_hash" >> $GITHUB_OUTPUT | ||
echo "build_version=${{ github.ref_name }}" >> $GITHUB_OUTPUT | ||
- name: Build and push YUM Backend | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./ | ||
file: ./Dockerfile | ||
push: true | ||
tags: | | ||
ghcr.io/bmrlab/muse-credits:latest | ||
ghcr.io/bmrlab/muse-credits:${{ steps.vars.outputs.commit_short_hash }} | ||
ghcr.io/bmrlab/muse-credits:${{ steps.vars.outputs.build_version }} | ||
platforms: linux/amd64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM rust:1.74-slim as github-credits | ||
|
||
|
||
ENV task_params=" " start_params=" " | ||
COPY --from=github-credits /usr/src/config /usr/app/config | ||
COPY --from=github-credits /usr/src/target/release/credits-cli /usr/app/credits-cli | ||
EXPOSE 8080 | ||
CMD ["sh", "-c", "cd /usr/app && ./credits-cli task ${task_params} && ${start_params} ./credits-cli start"] | ||
|
||
|