Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion .github/scripts/make_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ StartLimitBurst=3

[Service]
Type=simple
ExecStart=/opt/multi_buy_service/bin/multi_buy_service -c /opt/multi_buy_service/etc/settings.toml
ExecStart=/opt/multi_buy_service/bin/multi_buy_service -c /opt/multi_buy_service/etc/settings.toml server
User=helium
PIDFile=/var/run/multi_buy_service
Restart=always
Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/build.yaml

This file was deleted.

162 changes: 162 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: CI

on:
pull_request:
branches: ["main"]
push:
branches: ["main"]
tags: ["*"]
workflow_dispatch:

permissions:
contents: read
packages: write

jobs:
compute-base-build-tag:
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.out.outputs.tag }}
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Create Tag
id: out
run: echo "tag=${{ hashFiles('Dockerfile','rust-toolchain.toml') }}" >> "$GITHUB_OUTPUT"

build-base:
needs: compute-base-build-tag
runs-on: ubuntu-latest
env:
CACHE_HIT: false
IMAGE: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }}
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Log in to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull Cached base Image
run: |
if docker manifest inspect "$IMAGE" > /dev/null 2>&1; then
echo "CACHE_HIT=true" >> $GITHUB_ENV
else
echo "CACHE_HIT=false" >> $GITHUB_ENV
fi
- name: Set up Docker Buildx
if: env.CACHE_HIT == 'false'
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Build and Push base Image (if not cached)
if: env.CACHE_HIT == 'false'
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
context: .
file: Dockerfile
target: base
push: true
tags: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }}

fmt:
needs: [compute-base-build-tag, build-base]
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-fmt
cancel-in-progress: true
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Check formatting
run: cargo fmt -- --check

clippy:
needs: [compute-base-build-tag, build-base]
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-clippy
cancel-in-progress: true
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Cache Cargo Target Directory
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: target
key: clippy-base-${{ needs.compute-base-build-tag.outputs.image_tag }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
clippy-base-${{ needs.compute-base-build-tag.outputs.image_tag }}-
- name: Clippy
run: cargo clippy --all-targets -- -Dclippy::all -D warnings

tests:
needs: [compute-base-build-tag, build-base]
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-tests
cancel-in-progress: true
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Cache Cargo Target Directory
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: target
key: tests-base-${{ needs.compute-base-build-tag.outputs.image_tag }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
tests-base-${{ needs.compute-base-build-tag.outputs.image_tag }}-
- name: Install nextest
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Run tests
run: cargo nextest run

build-package:
if: startsWith(github.ref, 'refs/tags/')
needs: [fmt, clippy, tests]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-build-package
cancel-in-progress: true
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Debian packaging
env:
PACKAGECLOUD_API_KEY: ${{ secrets.PACKAGECLOUD_API_KEY }}
run: |
chmod +x ./.github/scripts/make_debian.sh
./.github/scripts/make_debian.sh

build-image:
if: startsWith(github.ref, 'refs/tags/')
needs: [fmt, clippy, tests]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-build-image
cancel-in-progress: true
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Log in to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Build and Push base Image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
context: .
file: Dockerfile
target: runner
push: true
tags: ghcr.io/${{ github.repository }}/multi_buy_service:${{ github.ref_name }}
20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
/target
target/

# VS Code
.vscode/

# Mac
.DS_Store

# Logs
*.log

# Environment files
.env
.env.*

CLAUDE.md
.claude/

settings.toml
Loading