Skip to content

testing only the build stage #154

testing only the build stage

testing only the build stage #154

Workflow file for this run

name: Build, Test and Deploy to Prod
on:
push:
branches:
- main
env:
SQLX_OFFLINE: true
DATABASE_URL: ${{secrets.DATABASE_TEST_URI}}
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15.3-alpine
ports:
- 5432:5432
env:
POSTGRES_USER: ${{secrets.POSTGRES_USER}}
POSTGRES_PASSWORD: ${{secrets.POSTGRES_PASSWORD}}
POSTGRES_DB: ${{secrets.POSTGRES_DB}}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Install SQLx CLI
run: cargo install sqlx-cli --no-default-features --features native-tls,postgres
- name: Run SQLx Database Migrations
run: sqlx migrate run
- name: Generate SQLX Prepared Queries
run: cargo sqlx prepare
- name: Build and test code
run: |
cargo build --verbose
cargo test --verbose
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
- name: Build and push Docker images
uses: docker/[email protected]
with:
push: true
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max