Skip to content

[Fix Docker Builds #334] changed the dockerfile path in docker.yaml w… #104

[Fix Docker Builds #334] changed the dockerfile path in docker.yaml w…

[Fix Docker Builds #334] changed the dockerfile path in docker.yaml w… #104

---
name: CI Build
on:
push:
branches:
- "*"
pull_request:
branches:
- main
concurrency:
group: "${{ github.ref }}"
cancel-in-progress: true
jobs:
cargo-build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4 # Marketplace - https://github.com/marketplace/actions/checkout
# Installs the most recent stable rust toolchain as of the specified time
# offset, which may be written in years, months, weeks, or days.
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Start PostgreSQL
run: |
sudo systemctl enable postgresql.service
sudo systemctl start postgresql.service
# Create the aardwolf database
- name: Create database
run: |
cd ~postgres/
sudo -u postgres psql -c 'CREATE DATABASE aardwolf_testing;'
# Create the aardwolf database user
- name: Create database user
run: |
cd ~postgres/
sudo sudo netstat -plunt |grep postgres
sudo -u postgres psql -c "CREATE USER aardwolf_user WITH PASSWORD 'changeme';"
sudo -u postgres psql -c "grant all privileges on database aardwolf_testing to aardwolf_user;"
# Set up environment variables for database URLs
- name: Set up environment variables
run: |
echo "DATABASE_URL=postgresql://aardwolf_user:changeme@127.0.0.1:5432/aardwolf_testing" > "$GITHUB_ENV"
echo "TEST_DATABASE_URL=postgresql://aardwolf_user:changeme@127.0.0.1:5432/aardwolf_testing" >> "$GITHUB_ENV"
# Install diesel CLI if not already installed
- name: Check Diesel installation
run: if which diesel; then echo "diesel already installed"; else cargo install diesel_cli --no-default-features --features=postgres; fi
# Push the aardwolf-models directory, and run migrations
- run: |
pushd aardwolf-models
diesel migration run
popd
# Run cargo build
- name: Cargo build Aardwolf
run: cargo build