Skip to content

Fix Events API

Fix Events API #210

Workflow file for this run

name: Rust
on:
push:
branches: [ "main" ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
DATABASE_URL: postgres://postgres@localhost/food_calc_testing
BIN_NAME: "backend"
jobs:
test:
runs-on: ubuntu-latest
environment: ssh
services:
postgres:
image: postgres:alpine
env:
POSTGRES_DB: food_calc_testing
POSTGRES_HOST_AUTH_METHOD: trust
LANG: de_DE.utf8
POSTGRES_INITDB_ARGS: "--locale-provider=icu --icu-locale=de-DE"
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Show Locale
run: psql -p 5432 -h 127.0.0.1 -U postgres --no-password food_calc_testing --command "SHOW lc_monetary;"
- name: Apply Database Migrations
run: |
for migration in $(find ./foodlib/migrations/ -type f | sort)
do
psql -p 5432 -h 127.0.0.1 -U postgres --no-password -f $migration food_calc_testing
done
- name: Install NPM Dependencies
run: cd backend && npm install && cd ..
- name: Install Tectonic Dependencies
run: sudo apt install libgraphite2-dev
- name: Run tests
run: cargo test --all
deploy:
runs-on: ubuntu-latest
environment: ssh
needs: test
steps:
- uses: actions/checkout@v3
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
REMOTE_USER: ${{ secrets.DEPLOY_USER }}
REMOTE_HOST: ${{ secrets.DEPLOY_HOST }}
REMOTE_PORT: ${{ secrets.DEPLOY_PORT }}
SOURCE: ./
TARGET: /srv/foodcalc/build
SCRIPT_AFTER: |
echo $RSYNC_STDOUT
cd /srv/foodcalc/build/backend && npm install
cd /srv/foodcalc/build/
cargo build --release --bin ${{ env.BIN_NAME }} --features tectonic
sudo /bin/systemctl stop foodcalc
cp /srv/foodcalc/build/target/release/${{ env.BIN_NAME }} /srv/foodcalc/${{ env.BIN_NAME }}
sudo /bin/systemctl start foodcalc