feat(ci): switch to Docker Buildx for improved security and simplicity
This commit is contained in:
parent
1e3a424dd6
commit
618151075b
1 changed files with 27 additions and 92 deletions
|
|
@ -2,106 +2,41 @@ name: Lint and Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: [main]
|
||||||
pull_request:
|
|
||||||
branches: [ "main" ]
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_TERM_COLOR: always
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: docker
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: rust:latest
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install Node.js
|
- uses: actions/checkout@v4
|
||||||
run: |
|
- name: Install Rust toolchain
|
||||||
apt-get update && apt-get install -y curl
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
- name: Run Clippy
|
||||||
apt-get install -y nodejs
|
run: cargo clippy --all-targets --all-features
|
||||||
|
|
||||||
- uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
apt-get update && apt-get install -y pkg-config libssl-dev
|
|
||||||
|
|
||||||
- name: Install Rust components
|
|
||||||
run: |
|
|
||||||
rustup component add rustfmt clippy
|
|
||||||
|
|
||||||
- name: Run rustfmt (auto-fix)
|
|
||||||
working-directory: ./backend
|
|
||||||
run: cargo fmt --all
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Check formatting
|
|
||||||
working-directory: ./backend
|
|
||||||
run: cargo fmt --all -- --check
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Run clippy
|
|
||||||
working-directory: ./backend
|
|
||||||
run: cargo clippy --all-targets --all-features -- -W warnings
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: rust:latest
|
|
||||||
needs: lint
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install Node.js
|
- uses: actions/checkout@v4
|
||||||
run: |
|
- name: Install Rust toolchain
|
||||||
apt-get update && apt-get install -y curl
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
- name: Build Rust project
|
||||||
apt-get install -y nodejs
|
run: cargo build --release
|
||||||
|
|
||||||
- uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
apt-get update && apt-get install -y pkg-config libssl-dev
|
|
||||||
|
|
||||||
- name: Build backend
|
|
||||||
working-directory: ./backend
|
|
||||||
run: cargo build --verbose
|
|
||||||
|
|
||||||
- name: Temporarily exclude integration tests
|
|
||||||
working-directory: ./backend
|
|
||||||
run: mv tests tests.disabled
|
|
||||||
|
|
||||||
- name: Run unit tests
|
|
||||||
working-directory: ./backend
|
|
||||||
run: cargo test --verbose
|
|
||||||
|
|
||||||
- name: Restore integration tests
|
|
||||||
working-directory: ./backend
|
|
||||||
run: mv tests.disabled tests
|
|
||||||
|
|
||||||
docker-build:
|
docker-build:
|
||||||
runs-on: docker
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: docker:cli
|
|
||||||
env:
|
|
||||||
DOCKER_HOST: tcp://docker-in-dinner:2375
|
|
||||||
DOCKER_TLS_CERTDIR: ""
|
|
||||||
needs: build
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Verify Docker connection
|
- name: Checkout
|
||||||
run: |
|
uses: actions/checkout@v4
|
||||||
echo "DOCKER_HOST: $DOCKER_HOST"
|
|
||||||
docker --version
|
- name: Set up Docker Buildx
|
||||||
docker info
|
uses: docker/setup-buildx-action@v3
|
||||||
docker ps
|
|
||||||
|
|
||||||
- uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
working-directory: ./backend
|
uses: docker/build-push-action@v5
|
||||||
run: |
|
with:
|
||||||
docker build -t normogen-backend:test .
|
context: ./backend
|
||||||
docker images | grep normogen-backend
|
push: false
|
||||||
|
tags: normogen-backend:latest
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue