Auto discover and run all issues & examples CI (#903)

* Auto discover and run all [issues] CI

* Auto discover and run all examples CI

* Fixup

* Testing

* Test [issues]
This commit is contained in:
Billy Chan 2022-07-21 13:46:12 +08:00 committed by GitHub
parent 1385b749cb
commit 41116499e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,7 +64,7 @@ jobs:
init:
name: Init
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
run-sqlite: ${{ contains(steps.git-log.outputs.message, '[sqlite]') }}
run-mysql: ${{ contains(steps.git-log.outputs.message, '[mysql]') }}
@ -89,7 +89,7 @@ jobs:
clippy:
name: Clippy
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -144,8 +144,9 @@ jobs:
needs.init.outputs.run-partial == 'false' ||
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-sqlite == 'true')
}}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
runtime: [async-std]
tls: [native-tls, rustls]
@ -183,8 +184,9 @@ jobs:
needs.init.outputs.run-partial == 'false' ||
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-mysql == 'true')
}}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
runtime: [actix]
tls: [native-tls, rustls]
@ -222,8 +224,9 @@ jobs:
needs.init.outputs.run-partial == 'false' ||
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-postgres == 'true')
}}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
runtime: [tokio]
tls: [native-tls, rustls]
@ -255,7 +258,7 @@ jobs:
test:
name: Unit Test
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -287,10 +290,7 @@ jobs:
name: CLI
needs: init
if: ${{ (needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-cli == 'true') }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -307,14 +307,26 @@ jobs:
--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: ${{ matrix.os }}
runs-on: ubuntu-latest
needs: examples-matrix
strategy:
fail-fast: false
max-parallel: 12
matrix:
os: [ubuntu-latest]
path: [basic, actix_example, actix3_example, axum_example, graphql_example, rocket_example, poem_example, jsonrpsee_example, tonic_example]
path: ${{ fromJson(needs.examples-matrix.outputs.path_matrix) }}
steps:
- uses: actions/checkout@v2
@ -328,51 +340,58 @@ jobs:
with:
command: build
args: >
--manifest-path examples/${{ matrix.path }}/Cargo.toml
- name: Check existence of migration directory
id: migration_dir_exists
uses: andstor/file-existence-action@v1
with:
files: examples/${{ matrix.path }}/migration/Cargo.toml
- uses: actions-rs/cargo@v1
if: steps.migration_dir_exists.outputs.files_exists == 'true'
with:
command: build
args: >
--manifest-path examples/${{ matrix.path }}/migration/Cargo.toml
issues:
name: Issues
needs: init
if: ${{ (needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-issues == 'true') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
path: [86, 249, 262, 319, 324, 352, 356, 471, 630, 693]
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 issues/${{ matrix.path }}/Cargo.toml
--manifest-path ${{ matrix.path }}
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--manifest-path issues/${{ matrix.path }}/Cargo.toml
--manifest-path ${{ matrix.path }}
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
@ -384,7 +403,7 @@ jobs:
needs.init.outputs.run-partial == 'false' ||
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-sqlite == 'true')
}}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
DATABASE_URL: "sqlite::memory:"
strategy:
@ -435,7 +454,7 @@ jobs:
needs.init.outputs.run-partial == 'false' ||
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-mysql == 'true')
}}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
DATABASE_URL: "mysql://root:@localhost"
strategy:
@ -504,7 +523,7 @@ jobs:
needs.init.outputs.run-partial == 'false' ||
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-mysql == 'true')
}}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
DATABASE_URL: "mysql://root:@localhost"
strategy:
@ -565,7 +584,7 @@ jobs:
needs.init.outputs.run-partial == 'false' ||
(needs.init.outputs.run-partial == 'true' && needs.init.outputs.run-postgres == 'true')
}}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
DATABASE_URL: "postgres://root:root@localhost"
strategy: