Skip to content

Build & Test

Build & Test #1751

Workflow file for this run

name: Build & Test
on:
schedule:
- cron: "0 10 * * *"
push:
branches:
- master
- main
tags:
- "v*.*.*"
pull_request:
branches:
- master
- main
release:
types: [published]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Rust Build
run: cargo build --verbose
- name: Rust tests
run: TEST_DATABASE_URL=postgres://postgres:postgres@localhost cargo test --verbose
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/duyet/glossary
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker build and push
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name == 'release' || github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max