Skip to content

[NO-ISSUE] refactor: adapt for musl docker #168

[NO-ISSUE] refactor: adapt for musl docker

[NO-ISSUE] refactor: adapt for musl docker #168

Workflow file for this run

name: Server test
on:
pull_request:
push:
branches:
- master
jobs:
test:
name: test
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-22.04]
services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: nettuscheduler
ports:
- 5432:5432
env:
PORT: 5000
DATABASE_URL: postgresql://postgres:postgres@localhost/nettuscheduler
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: rustfmt
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
scheduler/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install Nextest
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Run migrations
run: |
cd scheduler
# run the migrations first
cargo install sqlx-cli --no-default-features --features postgres || true
(cd crates/infra && sqlx migrate run)
- name: Formatting
run: |
cd scheduler
cargo +nightly fmt --all -- --check
- name: Clippy
run: |
cd scheduler
cargo clippy --all
# To re-enable
# cargo clippy --all -- --deny "warnings"
# Commented out for now as it's pretty slow in the CI
# TODO: find a solution (e.g. by using caching) or re-enable only on master
# - name: Unused dependencies
# run: |
# cd scheduler
# cargo install cargo-udeps --locked
# cargo +nightly udeps --all-targets
# - name: Outdated dependencies
# run: |
# cd scheduler
# # cargo outdated --exit-code 1 --workspace
# cargo outdated --workspace
- name: Run server tests
run: |
cd scheduler
cargo nextest run --workspace
docker-release:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: nettuscheduler
ports:
- 5432:5432
env:
DATABASE_URL: postgresql://postgres:postgres@localhost/nettuscheduler
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set version env
run: |
# v1.0.0 --> 1.0.0
VERSION=${GITHUB_REF#refs/*/}
echo "VERSION=${VERSION:1}" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
scheduler/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run migrations
run: |
cd scheduler
cargo install sqlx-cli --no-default-features --features postgres || true
(cd crates/infra && sqlx migrate run)
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./scheduler
push: true
file: "./scheduler/musl.Dockerfile"
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}