Skip to content

docker in ci/cd

docker in ci/cd #312

Workflow file for this run

name: CI # Continuous Integration
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Test Suite (${{ matrix.os-name }})
runs-on: ${{ matrix.os }}
env:
CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_RUSTFLAGS: -C target-feature=+sse2
strategy:
matrix:
include:
- os: macos-latest
os-name: mac
features: default
- os: ubuntu-latest
os-name: ubuntu
features: default
- os: windows-latest
os-name: windows
features: default
- os: ubuntu-latest
os-name: android
target: aarch64-linux-android
features: termux --no-default-features
- os: ubuntu-latest
os-name: ish
target: i686-unknown-linux-musl
features: default
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Run tests (cross)
if: ${{ matrix.target != null }}
uses: houseabsolute/actions-rust-cross@v0
with:
command: test
target: ${{ matrix.target }}
args: "--features ${{ matrix.features }} --workspace"
cross-version: 7b79041c9278769eca57fae10c74741f5aa5c14b
- name: Run tests (default)
if: ${{ matrix.target == null }}
run: cargo test --features ${{ matrix.features }} --workspace
docker:
name: Test Docker
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker CLI
uses: docker/setup-buildx-action@v3
- name: build docker image
uses: docker/build-push-action@v5
with:
context: .
tags: rainfrog_test
outputs: type=docker
cache-from: type=gha
cache-to: type=gha,mode=max
- name: init db for docker test
run: |
make db-up
sleep 5 # wait for db container
- name: docker run
run: |
docker run -dit --name rainfrog_test \
-e username="root" \
-e password="password" \
-e hostname="host.docker.internal" \
-e db_port="5499" \
-e db_name="rainfrog" rainfrog_test
sleep 5 # wait for container
- name: check container status
run: |
docker ps
docker logs -t rainfrog_test
container_status=$(docker ps -f name=rainfrog_test --format "{{.Status}}")
echo "$container_status"
if [[ "$container_status" == "Up"* ]]; then
echo "container started"
else
echo "container did not start"
exit 1
fi
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
env:
CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_RUSTFLAGS: -C target-feature=+sse2
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all --check
clippy:
name: Clippy
runs-on: ubuntu-latest
env:
CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_RUSTFLAGS: -C target-feature=+sse2
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Clippy check
run: cargo clippy --all-targets --all-features --workspace -- -D warnings