* introduce rustfmt * Cargofmt on all sea-orm crates & examples * Revert testing script * cargo fmt --manifest-path sea-orm-rocket/Cargo.toml --all * add a script for formatting * add nightly component for formatting * set timeout and manual nightly install in github action * add flag for manifest-path Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
705 lines
18 KiB
YAML
705 lines
18 KiB
YAML
# GitHub Actions with Conditional Job Running Based on Commit Message
|
|
#
|
|
# --------------------------------------------------------------------------------
|
|
#
|
|
# Following jobs will always run
|
|
#
|
|
# - `clippy`
|
|
# - `test`
|
|
# - `examples`
|
|
#
|
|
# Following jobs will be run when no keywords were found in commit message)
|
|
#
|
|
# - `compile-sqlite`
|
|
# - `sqlite`
|
|
# - `compile-mysql`
|
|
# - `mysql`
|
|
# - `mariadb`
|
|
# - `compile-postgres`
|
|
# - `postgres`
|
|
#
|
|
# Following jobs will be run if keywords `[issues]` were found in commit message
|
|
#
|
|
# - Jobs that will always run
|
|
# - `issues`
|
|
#
|
|
# Following jobs will be run if keywords `[cli]` were found in commit message
|
|
#
|
|
# - Jobs that will always run
|
|
# - `cli`
|
|
#
|
|
# Following jobs will be run if keywords `[sqlite]` were found in commit message
|
|
#
|
|
# - Jobs that will always run
|
|
# - `compile-sqlite`
|
|
# - `sqlite`
|
|
#
|
|
# Following jobs will be run if keywords `[mysql]` were found in commit message
|
|
#
|
|
# - Jobs that will always run
|
|
# - `compile-mysql`
|
|
# - `mysql`
|
|
# - `mariadb`
|
|
#
|
|
# Following jobs will be run if keywords `[postgres]` were found in commit message
|
|
#
|
|
# - Jobs that will always run
|
|
# - `compile-postgres`
|
|
# - `postgres`
|
|
|
|
|
|
name: tests
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- master
|
|
- 0.2.x
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
|
|
init:
|
|
name: Init
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
run-sqlite: ${{ contains(steps.git-log.outputs.message, '[sqlite]') }}
|
|
run-mysql: ${{ contains(steps.git-log.outputs.message, '[mysql]') }}
|
|
run-postgres: ${{ contains(steps.git-log.outputs.message, '[postgres]') }}
|
|
run-cli: ${{ contains(steps.git-log.outputs.message, '[cli]') }}
|
|
run-issues: ${{ contains(steps.git-log.outputs.message, '[issues]') }}
|
|
run-partial: >-
|
|
${{
|
|
contains(steps.git-log.outputs.message, '[sqlite]') ||
|
|
contains(steps.git-log.outputs.message, '[mysql]') ||
|
|
contains(steps.git-log.outputs.message, '[postgres]') ||
|
|
contains(steps.git-log.outputs.message, '[cli]') ||
|
|
contains(steps.git-log.outputs.message, '[issues]')
|
|
}}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- id: git-log
|
|
run: echo "::set-output name=message::$(git log --no-merges -1 --oneline)"
|
|
|
|
clippy:
|
|
name: Clippy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
components: clippy
|
|
override: true
|
|
|
|
- name: Run clippy on `sea-orm` workspace
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: clippy
|
|
args: >
|
|
--all
|
|
--
|
|
-D warnings
|
|
|
|
- name: Run clippy on `sea-orm-cli`
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: clippy
|
|
args: >
|
|
--manifest-path sea-orm-cli/Cargo.toml
|
|
--
|
|
-D warnings
|
|
|
|
- name: Run clippy on `sea-orm-migration`
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: clippy
|
|
args: >
|
|
--manifest-path sea-orm-migration/Cargo.toml
|
|
--
|
|
-D warnings
|
|
|
|
- name: Run clippy on `sea-orm-rocket`
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: clippy
|
|
args: >
|
|
--manifest-path sea-orm-rocket/Cargo.toml
|
|
--
|
|
-D warnings
|
|
|
|
rustfmt:
|
|
name: Rustfmt
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: nightly
|
|
components: rustfmt
|
|
override: true
|
|
|
|
- name: Run rustfmt on `sea-orm` workspace
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: fmt
|
|
args: >
|
|
--all
|
|
--
|
|
--check
|
|
|
|
- name: Run rustfmt on `sea-orm-cli`
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: fmt
|
|
args: >
|
|
--manifest-path sea-orm-cli/Cargo.toml
|
|
--all
|
|
--
|
|
--check
|
|
|
|
- name: Run rustfmt on `sea-orm-migration`
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: fmt
|
|
args: >
|
|
--manifest-path sea-orm-migration/Cargo.toml
|
|
--all
|
|
--
|
|
--check
|
|
|
|
- name: Run rustfmt on `sea-orm-rocket`
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: fmt
|
|
args: >
|
|
--manifest-path sea-orm-rocket/Cargo.toml
|
|
--all
|
|
--
|
|
--check
|
|
|
|
compile-sqlite:
|
|
name: Compile SQLite
|
|
needs: init
|
|
if: >-
|
|
${{
|
|
needs.init.outputs.run-partial == 'false' ||
|
|
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-sqlite == 'true')
|
|
}}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
runtime: [async-std]
|
|
tls: [native-tls, rustls]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
Cargo.lock
|
|
target
|
|
key: ${{ github.sha }}-${{ github.run_id }}-${{ runner.os }}-sqlite-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--test '*'
|
|
--features default,sqlx-sqlite,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
--no-run
|
|
|
|
compile-mysql:
|
|
name: Compile MySQL
|
|
needs: init
|
|
if: >-
|
|
${{
|
|
needs.init.outputs.run-partial == 'false' ||
|
|
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-mysql == 'true')
|
|
}}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
runtime: [actix]
|
|
tls: [native-tls, rustls]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
Cargo.lock
|
|
target
|
|
key: ${{ github.sha }}-${{ github.run_id }}-${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--test '*'
|
|
--features default,sqlx-mysql,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
--no-run
|
|
|
|
compile-postgres:
|
|
name: Compile PostgreSQL
|
|
needs: init
|
|
if: >-
|
|
${{
|
|
needs.init.outputs.run-partial == 'false' ||
|
|
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-postgres == 'true')
|
|
}}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
runtime: [tokio]
|
|
tls: [native-tls, rustls]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
Cargo.lock
|
|
target
|
|
key: ${{ github.sha }}-${{ github.run_id }}-${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--test '*'
|
|
--features default,sqlx-postgres,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
--no-run
|
|
|
|
test:
|
|
name: Unit Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--workspace
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--manifest-path sea-orm-rocket/Cargo.toml
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--manifest-path sea-orm-cli/Cargo.toml
|
|
|
|
cli:
|
|
name: CLI
|
|
needs: init
|
|
if: ${{ (needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-cli == 'true') }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: install
|
|
args: >
|
|
--path sea-orm-cli
|
|
--debug
|
|
|
|
examples-matrix:
|
|
name: Examples Matrix
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- id: set-matrix
|
|
run: echo "::set-output name=path_matrix::$(find examples -type f -name 'Cargo.toml' -printf '%P\0' | jq -Rc '[ split("\u0000") | .[] | "examples/\(.)" ]')"
|
|
outputs:
|
|
path_matrix: ${{ steps.set-matrix.outputs.path_matrix }}
|
|
|
|
examples:
|
|
name: Examples
|
|
runs-on: ubuntu-latest
|
|
needs: examples-matrix
|
|
timeout-minutes: 15
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 12
|
|
matrix:
|
|
path: ${{ fromJson(needs.examples-matrix.outputs.path_matrix) }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: >
|
|
--manifest-path ${{ matrix.path }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--manifest-path ${{ matrix.path }}
|
|
|
|
- name: check rustfmt
|
|
run: |
|
|
rustup override set nightly
|
|
rustup component add rustfmt
|
|
cargo +nightly fmt --manifest-path ${{ matrix.path }} --all -- --check
|
|
|
|
issues-matrix:
|
|
name: Issues Matrix
|
|
needs: init
|
|
if: ${{ (needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-issues == 'true') }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- id: set-matrix
|
|
run: echo "::set-output name=path_matrix::$(find issues -type f -name 'Cargo.toml' -printf '%P\0' | jq -Rc '[ split("\u0000") | .[] | "issues/\(.)" ]')"
|
|
outputs:
|
|
path_matrix: ${{ steps.set-matrix.outputs.path_matrix }}
|
|
|
|
issues:
|
|
name: Issues
|
|
needs:
|
|
- init
|
|
- issues-matrix
|
|
if: ${{ (needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-issues == 'true') }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
path: ${{ fromJson(needs.issues-matrix.outputs.path_matrix) }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: >
|
|
--manifest-path ${{ matrix.path }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--manifest-path ${{ matrix.path }}
|
|
|
|
sqlite:
|
|
name: SQLite
|
|
needs:
|
|
- init
|
|
- compile-sqlite
|
|
if: >-
|
|
${{
|
|
needs.init.outputs.run-partial == 'false' ||
|
|
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-sqlite == 'true')
|
|
}}
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DATABASE_URL: "sqlite::memory:"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
runtime: [async-std]
|
|
tls: [native-tls, rustls]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
Cargo.lock
|
|
target
|
|
key: ${{ github.sha }}-${{ github.run_id }}-${{ runner.os }}-sqlite-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--test '*'
|
|
--features default,sqlx-sqlite,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--manifest-path sea-orm-migration/Cargo.toml
|
|
--test '*'
|
|
--features sqlx-sqlite,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
mysql:
|
|
name: MySQL
|
|
needs:
|
|
- init
|
|
- compile-mysql
|
|
if: >-
|
|
${{
|
|
needs.init.outputs.run-partial == 'false' ||
|
|
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-mysql == 'true')
|
|
}}
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DATABASE_URL: "mysql://root:@localhost"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
version: [8.0, 5.7]
|
|
runtime: [actix]
|
|
tls: [native-tls]
|
|
services:
|
|
mysql:
|
|
image: mysql:${{ matrix.version }}
|
|
env:
|
|
MYSQL_HOST: 127.0.0.1
|
|
MYSQL_DB: mysql
|
|
MYSQL_USER: sea
|
|
MYSQL_PASSWORD: sea
|
|
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
|
MYSQL_ROOT_PASSWORD:
|
|
ports:
|
|
- "3306:3306"
|
|
options: >-
|
|
--health-cmd="mysqladmin ping"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=3
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
Cargo.lock
|
|
target
|
|
key: ${{ github.sha }}-${{ github.run_id }}-${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--test '*'
|
|
--features default,sqlx-mysql,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--manifest-path sea-orm-migration/Cargo.toml
|
|
--test '*'
|
|
--features sqlx-mysql,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
mariadb:
|
|
name: MariaDB
|
|
needs:
|
|
- init
|
|
- compile-mysql
|
|
if: >-
|
|
${{
|
|
needs.init.outputs.run-partial == 'false' ||
|
|
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-mysql == 'true')
|
|
}}
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DATABASE_URL: "mysql://root:@localhost"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
version: [10.6]
|
|
runtime: [actix]
|
|
tls: [native-tls]
|
|
services:
|
|
mysql:
|
|
image: mariadb:${{ matrix.version }}
|
|
env:
|
|
MYSQL_HOST: 127.0.0.1
|
|
MYSQL_DB: mysql
|
|
MYSQL_USER: sea
|
|
MYSQL_PASSWORD: sea
|
|
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
|
MYSQL_ROOT_PASSWORD:
|
|
ports:
|
|
- "3306:3306"
|
|
options: >-
|
|
--health-cmd="mysqladmin ping"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=3
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
Cargo.lock
|
|
target
|
|
key: ${{ github.sha }}-${{ github.run_id }}-${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--test '*'
|
|
--features default,sqlx-mysql,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
postgres:
|
|
name: Postgres
|
|
needs:
|
|
- init
|
|
- compile-postgres
|
|
if: >-
|
|
${{
|
|
needs.init.outputs.run-partial == 'false' ||
|
|
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-postgres == 'true')
|
|
}}
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DATABASE_URL: "postgres://root:root@localhost"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
version: [14.4]
|
|
runtime: [tokio]
|
|
tls: [native-tls]
|
|
services:
|
|
postgres:
|
|
image: postgres:${{ matrix.version }}
|
|
env:
|
|
POSTGRES_HOST: 127.0.0.1
|
|
POSTGRES_USER: root
|
|
POSTGRES_PASSWORD: root
|
|
ports:
|
|
- "5432:5432"
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
Cargo.lock
|
|
target
|
|
key: ${{ github.sha }}-${{ github.run_id }}-${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--test '*'
|
|
--features default,sqlx-postgres,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: >
|
|
--manifest-path sea-orm-migration/Cargo.toml
|
|
--test '*'
|
|
--features sqlx-postgres,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
|