Improve CI and lint code

This commit is contained in:
AB from home.homenet
2025-10-24 19:34:56 +03:00
parent 7e8831b89e
commit c05d2f6223
28 changed files with 125 additions and 339 deletions

View File

@@ -6,11 +6,27 @@ on:
- 'RUST'
jobs:
docker:
test-build:
runs-on: ubuntu-latest
outputs:
rust-version: ${{ steps.vars.outputs.rust_version }}
sha-short: ${{ steps.vars.outputs.sha_short }}
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Extract version from Cargo.toml
id: extract_version
run: |
@@ -19,22 +35,49 @@ jobs:
echo "Extracted version: $VERSION"
- name: Set outputs
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "rust_version=rs-${{ steps.extract_version.outputs.cargo_version }}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test build (linux/amd64 only)
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: false
cache-from: |
type=registry,ref=ultradesu/outfleet:deps-cache
type=registry,ref=ultradesu/outfleet:builder-cache
build-args: |
GIT_COMMIT=${{ github.sha }}
GIT_COMMIT_SHORT=${{ steps.vars.outputs.sha_short }}
BUILD_DATE=$(date -u +'%Y-%m-%d %H:%M:%S UTC')
BRANCH_NAME=${GITHUB_REF#refs/heads/}
CARGO_VERSION=${{ steps.extract_version.outputs.cargo_version }}
docker:
runs-on: ubuntu-latest
needs: test-build
steps:
- uses: actions/checkout@v4
- name: Set build variables
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "sha_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "build_date=$(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "rust_version=rs-${{ steps.extract_version.outputs.cargo_version }}" >> $GITHUB_OUTPUT
- name: Check outputs
- name: Extract version from Cargo.toml
id: extract_version
run: |
echo "Short SHA: ${{ steps.vars.outputs.sha_short }}"
echo "Full SHA: ${{ steps.vars.outputs.sha_full }}"
echo "Build Date: ${{ steps.vars.outputs.build_date }}"
echo "Branch: ${{ steps.vars.outputs.branch_name }}"
echo "Cargo Version: ${{ steps.extract_version.outputs.cargo_version }}"
echo "Rust Version Tag: ${{ steps.vars.outputs.rust_version }}"
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "cargo_version=$VERSION" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@@ -54,8 +97,14 @@ jobs:
context: .
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=registry,ref=ultradesu/outfleet:rust-buildcache
cache-to: type=registry,ref=ultradesu/outfleet:rust-buildcache,mode=max
cache-from: |
type=registry,ref=ultradesu/outfleet:deps-cache
type=registry,ref=ultradesu/outfleet:builder-cache
type=registry,ref=ultradesu/outfleet:rust-buildcache
cache-to: |
type=registry,ref=ultradesu/outfleet:deps-cache,mode=max
type=registry,ref=ultradesu/outfleet:builder-cache,mode=max
type=registry,ref=ultradesu/outfleet:rust-buildcache,mode=max
build-args: |
GIT_COMMIT=${{ steps.vars.outputs.sha_full }}
GIT_COMMIT_SHORT=${{ steps.vars.outputs.sha_short }}
@@ -63,6 +112,6 @@ jobs:
BRANCH_NAME=${{ steps.vars.outputs.branch_name }}
CARGO_VERSION=${{ steps.extract_version.outputs.cargo_version }}
tags: |
ultradesu/outfleet:${{ steps.vars.outputs.rust_version }}
ultradesu/outfleet:${{ steps.vars.outputs.rust_version }}-${{ steps.vars.outputs.sha_short }}
ultradesu/outfleet:rs-${{ steps.extract_version.outputs.cargo_version }}
ultradesu/outfleet:rs-${{ steps.extract_version.outputs.cargo_version }}-${{ steps.vars.outputs.sha_short }}
ultradesu/outfleet:rust-latest