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

Github actions #1

Merged
merged 2 commits into from
Nov 30, 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
100 changes: 100 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Master Branch CI

on:
push:
branches: [ "main", "master" ]
paths-ignore:
- '**.md'
- 'docs/**'
- '.gitignore'

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"

jobs:
test-and-lint:
name: Test and Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
cache-directories: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev

- name: Run tests
run: cargo test

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

- name: Run clippy
run: cargo clippy --all-targets

build:
name: Build Release (${{ matrix.target }})
runs-on: ubuntu-latest
needs: test-and-lint
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
artifact_name: ghost-resend-mailer-x86_64-linux
- target: aarch64-unknown-linux-gnu
artifact_name: ghost-resend-mailer-aarch64-linux

steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.78.0
targets: ${{ matrix.target }}

- name: Install cross-compilation dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu
fi

- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
cache-directories: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target

- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross

- name: Build release
run: cross build --release --target ${{ matrix.target }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: target/${{ matrix.target }}/release/ghost-resend-mailer
retention-days: 7
102 changes: 102 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Pull Request Checks

on:
pull_request:
branches: [ "main", "master" ]
paths-ignore:
- '**.md'
- 'docs/**'
- '.gitignore'

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"

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

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.78.0

- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
cache-directories: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev

- name: Run cargo check
run: cargo check --all-targets

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

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.78.0

- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
cache-directories: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev

- name: Run cargo test
run: cargo test

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
cache-directories: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev

- name: Run cargo fmt
run: cargo fmt --all -- --check

- name: Run cargo clippy
run: cargo clippy --all-targets
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/target
**/*.rs.bk
Cargo.lock
.env
target/*
.env.*
.DS_Store
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ impl Config {
.map_err(|_| anyhow::anyhow!("GHOST_URL environment variable not found"))?,
ghost_admin_id: std::env::var("GHOST_ADMIN_ID")
.map_err(|_| anyhow::anyhow!("GHOST_ADMIN_ID environment variable not found"))?,
ghost_admin_secret: std::env::var("GHOST_ADMIN_SECRET")
.map_err(|_| anyhow::anyhow!("GHOST_ADMIN_SECRET environment variable not found"))?,
ghost_admin_secret: std::env::var("GHOST_ADMIN_SECRET").map_err(|_| {
anyhow::anyhow!("GHOST_ADMIN_SECRET environment variable not found")
})?,
webhook_secret: std::env::var("WEBHOOK_SECRET")
.map_err(|_| anyhow::anyhow!("WEBHOOK_SECRET environment variable not found"))?,
resend_api_key: std::env::var("RESEND_API_KEY")
Expand All @@ -35,4 +36,3 @@ impl Config {
})
}
}