Skip to content

Commit

Permalink
Add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
xerbalind committed Aug 22, 2024
1 parent 37b7606 commit a38c30d
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Audit Rust dependencies
on:
pull_request:
paths:
- .github/workflows/audit.yml
- '**/Cargo.toml'
- '**/Cargo.lock'

schedule:
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
security_audit:
runs-on: ubuntu-latest

permissions:
issues: write
checks: write

steps:
- uses: actions/checkout@v4
- uses: rustsec/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
73 changes: 73 additions & 0 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: Rust Cargo validator

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

env:
DATABASE_URL: postgresql://zns:zns@localhost/zns
ZAUTH_URL: https://zauth.zeus.gent
ZONE: users.zeus.gent

jobs:
test:

runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_DB: "zns"
POSTGRES_USER: "zns"
POSTGRES_PASSWORD: "zns"
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install system dependencies
run: sudo apt install libpq5
- name: Cache compiled dependencies
uses: actions/cache@v3
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
path: |
~/.cargo/registry
~/.cargo/git
target
- name: Run tests
run: RUST_BACKTRACE=1 cargo test --verbose

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install latest rust toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
components: rustfmt
override: true

- name: Check formatting
run: cargo fmt -- --check

clipy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install latest rust toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
components: clippy
override: true
- name: Clippy check
run: cargo clippy --locked --all-targets --all-features
30 changes: 30 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Docker main build

on:
push:
branches:
- main

concurrency:
group: docker-main
cancel-in-progress: true

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the new image
run: docker build . -t ghcr.io/zeuswpi/zns:${{ github.sha }}
- name: Tag the new image with latest
run: docker tag ghcr.io/zeuswpi/zns:${{ github.sha }} ghcr.io/zeuswpi/zns:latest
- name: Push Docker image
run: docker push --all-tags ghcr.io/zeuswpi/zns
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM docker.io/rust:latest AS builder

WORKDIR /zns

RUN cargo install diesel_cli --no-default-features --features postgres
COPY . .
RUN cargo install --locked --path zns-daemon

FROM docker.io/debian:bookworm-slim

WORKDIR /zns

COPY --from=builder /usr/local/cargo/bin/diesel /usr/local/cargo/bin/zns-daemon /usr/local/bin
COPY zns-daemon/diesel.toml .
COPY zns-daemon/migrations/ migrations/

RUN apt update && apt install libpq5 ca-certificates --yes

CMD diesel migration run && zns-daemon

0 comments on commit a38c30d

Please sign in to comment.