AppFlowy/.github/workflows/backend_general.yml

157 lines
3.9 KiB
YAML
Raw Normal View History

2021-12-01 03:22:32 +00:00
name: Backend
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
2021-12-01 08:44:58 +00:00
test:
name: Test
2021-12-01 03:22:32 +00:00
runs-on: ubuntu-latest
2021-12-01 08:44:58 +00:00
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
2021-12-02 14:22:46 +00:00
- 5433:5432
2021-12-01 08:44:58 +00:00
env:
SQLX_VERSION: 0.5.7
SQLX_FEATURES: postgres
2021-12-01 03:22:32 +00:00
steps:
2021-12-01 08:44:58 +00:00
- 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
2021-12-01 08:47:15 +00:00
- name: Migrate database
working-directory: backend/
run: |
sudo apt-get install libpq-dev -y
2021-12-02 14:40:24 +00:00
SKIP_DOCKER=true POSTGRES_PORT=5433 ./scripts/init_database.sh
2021-12-01 08:44:58 +00:00
2021-12-01 08:47:15 +00:00
- name: Check sqlx-data.json is up-to-date
working-directory: backend/
run: |
cargo sqlx prepare --check -- --bin backend
2021-12-01 08:44:58 +00:00
2021-12-01 08:47:15 +00:00
- name: Run cargo test
2021-12-01 09:54:14 +00:00
working-directory: backend/
run: cargo test
2021-12-01 12:51:17 +00:00
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- run: rustup component add rustfmt
working-directory: backend/
- run: cargo fmt --all -- --check
working-directory: backend/
clippy:
name: Clippy
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
2021-12-02 14:22:46 +00:00
- 5433:5432
2021-12-01 12:51:17 +00:00
env:
SQLX_VERSION: 0.5.7
SQLX_FEATURES: postgres
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- name: Cache sqlx-cli
uses: actions/cache@v2
id: cache-sqlx
with:
path: |
~/.cargo/bin/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
2021-12-02 08:40:49 +00:00
working-directory: backend/
2021-12-01 12:51:17 +00:00
run: |
sudo apt-get install libpq-dev -y
2021-12-02 14:40:24 +00:00
SKIP_DOCKER=true POSTGRES_PORT=5433 ./scripts/init_database.sh
2021-12-01 12:51:17 +00:00
- run: rustup component add clippy
working-directory: backend/
- run: cargo clippy -- -D warnings
working-directory: backend/
2021-12-01 09:54:14 +00:00
2021-12-01 03:22:32 +00:00