mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
87 lines
2.0 KiB
YAML
87 lines
2.0 KiB
YAML
name: Backend
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:12
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: password
|
|
POSTGRES_DB: postgres
|
|
ports:
|
|
- 5432:5432
|
|
env:
|
|
SQLX_VERSION: 0.5.7
|
|
SQLX_FEATURES: postgres
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Cache dependencies
|
|
id: cache-dependencies
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Cache sqlx-cli
|
|
uses: actions/cache@v2
|
|
id: cache-sqlx
|
|
with:
|
|
path: |
|
|
~/.cargo/bin/sqlx
|
|
~/.cargo/bin/cargo-sqlx
|
|
key: ${{ runner.os }}-sqlx-${{ env.SQLX_VERSION }}-${{ env.SQLX_FEATURES }}
|
|
|
|
- name: Install sqlx-cli
|
|
uses: actions-rs/cargo@v1
|
|
if: steps.cache-sqlx.outputs.cache-hit == false
|
|
with:
|
|
command: install
|
|
args: >
|
|
sqlx-cli
|
|
--force
|
|
--version=${{ env.SQLX_VERSION }}
|
|
--features=${{ env.SQLX_FEATURES }}
|
|
--no-default-features
|
|
--locked
|
|
|
|
- name: Migrate database
|
|
working-directory: backend/
|
|
run: |
|
|
sudo apt-get install libpq-dev -y
|
|
SKIP_DOCKER=true ./backend/scripts/init_database.sh
|
|
|
|
- name: Check sqlx-data.json is up-to-date
|
|
working-directory: backend/
|
|
run: |
|
|
cargo sqlx prepare --check -- --bin backend
|
|
|
|
- name: Run cargo test
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
path: "backend/"
|
|
command: test
|
|
|
|
|