Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflows #3

Merged
merged 1 commit into from
Aug 22, 2024
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
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 }}
78 changes: 78 additions & 0 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
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: Install diesel cli
run: cargo install diesel_cli --no-default-features --features postgres
- name: Run migrations
working-directory: ./zns-daemon
run: /home/runner/.cargo/bin/diesel migration run
- 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
Loading
Loading