docker in ci/cd #306
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: build docker image | |
run: | | |
docker build . -t rainfrog_test \ | |
--cache-to type=gha \ | |
--cache-from type=gha | |
- name: init db for docker test | |
run: make db-up | |
- name: docker run | |
run: | | |
docker run -dit --rm --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: | | |
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 |