2026-08-23 00:01:30 -07:00
|
|
|
name: Build and Push
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: [main]
|
|
|
|
|
pull_request:
|
|
|
|
|
branches: [main]
|
|
|
|
|
|
|
|
|
|
env:
|
|
|
|
|
REGISTRY: forgejo.riotpiao.com
|
2026-08-23 16:05:18 -07:00
|
|
|
IMAGE: forgejo.riotpiao.com/rock/poimen-memory
|
2026-08-23 00:01:30 -07:00
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
test:
|
|
|
|
|
name: Test
|
2026-09-05 14:07:11 -07:00
|
|
|
runs-on: docker
|
|
|
|
|
container:
|
|
|
|
|
image: rust:1.81-bookworm
|
2026-08-23 00:01:30 -07:00
|
|
|
steps:
|
2026-09-05 14:07:11 -07:00
|
|
|
- name: Checkout
|
|
|
|
|
uses: actions/checkout@v4
|
2026-08-28 15:46:27 -07:00
|
|
|
|
2026-09-05 14:07:11 -07:00
|
|
|
- name: Cache cargo registry
|
2026-08-28 15:46:27 -07:00
|
|
|
uses: actions/cache@v4
|
|
|
|
|
with:
|
2026-09-05 14:07:11 -07:00
|
|
|
path: ~/.cargo/registry
|
|
|
|
|
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
2026-08-28 15:46:27 -07:00
|
|
|
restore-keys: |
|
2026-09-05 14:07:11 -07:00
|
|
|
cargo-registry-
|
|
|
|
|
|
|
|
|
|
- name: Cache cargo index
|
|
|
|
|
uses: actions/cache@v4
|
|
|
|
|
with:
|
|
|
|
|
path: ~/.cargo/git
|
|
|
|
|
key: cargo-git-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
|
restore-keys: |
|
|
|
|
|
cargo-git-
|
|
|
|
|
|
|
|
|
|
- name: Cache build target
|
|
|
|
|
uses: actions/cache@v4
|
|
|
|
|
with:
|
|
|
|
|
path: target
|
|
|
|
|
key: cargo-target-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
|
restore-keys: |
|
|
|
|
|
cargo-target-
|
2026-08-23 17:35:45 -07:00
|
|
|
|
2026-08-23 16:05:18 -07:00
|
|
|
- name: Run tests
|
2026-09-05 14:07:11 -07:00
|
|
|
run: cargo test --all --verbose
|
|
|
|
|
|
|
|
|
|
- name: Check formatting
|
|
|
|
|
run: cargo fmt --all -- --check
|
|
|
|
|
|
|
|
|
|
- name: Run clippy
|
|
|
|
|
run: cargo clippy --all -- -D warnings
|
2026-08-23 00:01:30 -07:00
|
|
|
|
2026-08-23 16:05:18 -07:00
|
|
|
build:
|
2026-09-05 14:07:11 -07:00
|
|
|
name: Build and Push Image
|
|
|
|
|
runs-on: docker
|
2026-08-23 00:01:30 -07:00
|
|
|
needs: test
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
steps:
|
2026-09-05 14:07:11 -07:00
|
|
|
- name: Checkout
|
|
|
|
|
uses: actions/checkout@v4
|
2026-08-23 16:05:18 -07:00
|
|
|
|
|
|
|
|
- name: Get short SHA
|
|
|
|
|
id: sha
|
|
|
|
|
run: |
|
|
|
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
|
|
|
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
2026-09-05 14:07:11 -07:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
2026-08-23 16:05:18 -07:00
|
|
|
- name: Registry login
|
2026-09-05 14:07:11 -07:00
|
|
|
uses: docker/login-action@v3
|
|
|
|
|
with:
|
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
|
username: rock
|
|
|
|
|
password: ${{ secrets.REGISTRY_PAT }}
|
2026-08-23 16:05:18 -07:00
|
|
|
|
2026-09-05 14:07:11 -07:00
|
|
|
- name: Build and push
|
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
|
with:
|
|
|
|
|
context: .
|
|
|
|
|
push: true
|
|
|
|
|
tags: |
|
|
|
|
|
${{ env.IMAGE }}:${{ steps.sha.outputs.short_sha }}
|
|
|
|
|
${{ env.IMAGE }}:latest
|
|
|
|
|
cache-from: type=gha
|
|
|
|
|
cache-to: type=gha,mode=max
|