Skip to content

Commit 5d867ef

Browse files
authored
Merge pull request #1 from metorial/setup
Setup project
2 parents 9ddc7fe + 5823a20 commit 5d867ef

File tree

8 files changed

+3297
-0
lines changed

8 files changed

+3297
-0
lines changed

.github/workflows/ci.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
release:
9+
types: [ created ]
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
test:
17+
name: Test
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Rust
24+
uses: actions-rust-lang/setup-rust-toolchain@v1
25+
with:
26+
toolchain: stable
27+
components: rustfmt, clippy
28+
29+
- name: Cache cargo registry
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.cargo/registry
33+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-cargo-registry-
36+
37+
- name: Cache cargo index
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.cargo/git
41+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-cargo-git-
44+
45+
- name: Cache target directory
46+
uses: actions/cache@v4
47+
with:
48+
path: target
49+
key: ${{ runner.os }}-target-${{ hashFiles('**/Cargo.lock') }}
50+
restore-keys: |
51+
${{ runner.os }}-target-
52+
53+
- name: Run clippy
54+
run: cargo clippy -- -D warnings
55+
56+
- name: Run tests
57+
run: cargo test --verbose
58+
59+
- name: Run tests with coverage
60+
run: cargo test --verbose --all-features
61+
62+
build:
63+
name: Build Docker Image
64+
runs-on: ubuntu-latest
65+
needs: test
66+
permissions:
67+
contents: read
68+
packages: write
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: Set up Docker Buildx
74+
uses: docker/setup-buildx-action@v3
75+
76+
- name: Log in to GitHub Container Registry
77+
if: github.event_name != 'pull_request'
78+
uses: docker/login-action@v3
79+
with:
80+
registry: ${{ env.REGISTRY }}
81+
username: ${{ github.actor }}
82+
password: ${{ secrets.GITHUB_TOKEN }}
83+
84+
- name: Extract metadata (tags, labels)
85+
id: meta
86+
uses: docker/metadata-action@v5
87+
with:
88+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
89+
tags: |
90+
type=ref,event=branch
91+
type=ref,event=pr
92+
type=semver,pattern={{version}}
93+
type=semver,pattern={{major}}.{{minor}}
94+
type=semver,pattern={{major}}
95+
type=sha,prefix=sha-
96+
type=raw,value=latest,enable={{is_default_branch}}
97+
98+
- name: Build and push Docker image
99+
uses: docker/build-push-action@v5
100+
with:
101+
context: .
102+
push: ${{ github.event_name != 'pull_request' }}
103+
tags: ${{ steps.meta.outputs.tags }}
104+
labels: ${{ steps.meta.outputs.labels }}
105+
cache-from: type=gha
106+
cache-to: type=gha,mode=max
107+
platforms: linux/amd64,linux/arm64
108+
109+
security:
110+
name: Security Audit
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: Checkout code
114+
uses: actions/checkout@v4
115+
116+
- name: Setup Rust
117+
uses: actions-rust-lang/setup-rust-toolchain@v1
118+
with:
119+
toolchain: stable
120+
121+
- name: Run cargo audit
122+
uses: actions-rs/audit-check@v1
123+
with:
124+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/legal.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Check Legal Boilerplate
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
jobs:
8+
legal:
9+
permissions:
10+
pull-requests: write
11+
contents: read
12+
uses: metorial/.github/.github/workflows/legal-boilerplate.yml@main

0 commit comments

Comments
 (0)