gitbutler/.github/workflows/push.yaml
2024-04-04 12:09:12 +02:00

213 lines
5.6 KiB
YAML

name: "Test"
on:
push:
branches:
- master
pull_request:
env:
RUST_BACKTRACE: full
jobs:
changes:
runs-on: ubuntu-latest
outputs:
node: ${{ steps.filter.outputs.node }}
rust: ${{ steps.filter.outputs.rust }}
gitbutler-core: ${{ steps.filter.outputs.gitbutler-core }}
gitbutler-tauri: ${{ steps.filter.outputs.gitbutler-tauri }}
gitbutler-changeset: ${{ steps.filter.outputs.gitbutler-changeset }}
gitbutler-git: ${{ steps.filter.outputs.gitbutler-git }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
node:
- 'app/**'
- 'package.json'
- 'pnpm-lock.yaml'
common-rust: &rust
- 'Cargo.lock'
- 'Cargo.toml'
- 'rust-toolchain.toml'
rust: &any-rust
- *rust
- 'crates/**'
gitbutler-tauri:
- *any-rust
gitbutler-core:
- *rust
- 'crates/gitbutler-core/**'
gitbutler-changeset:
- *rust
- 'crates/gitbutler-changeset/**'
gitbutler-git:
- *rust
- 'crates/gitbutler-git/**'
lint-node:
needs: changes
if: ${{ needs.changes.outputs.node == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/init-env-node
- run: pnpm lint
check-node:
needs: changes
if: ${{ needs.changes.outputs.node == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/init-env-node
- run: pnpm check
unittest-node:
needs: changes
if: ${{ needs.changes.outputs.node == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/init-env-node
- run: pnpm test
rust-init:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/init-env-rust
- run: cargo fmt --check --all
- run: cargo build --locked --all-targets --tests
rust-docs:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/init-env-rust
# TODO(qix-): we have to exclude the app here for now because for some
# TODO(qix-): reason it doesn't build with the docs feature enabled.
- run: cargo doc --no-deps --all-features --document-private-items -p gitbutler-changeset -p gitbutler-git
env:
RUSTDOCFLAGS: -Dwarnings
check-gitbutler-tauri:
needs: [changes, rust-init]
if: ${{ needs.changes.outputs.gitbutler-tauri == 'true' }}
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
strategy:
matrix:
action:
- test
- check
- check-tests
features:
- ''
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/check-crate
with:
crate: gitbutler-tauri
features: ${{ toJson(matrix.features) }}
action: ${{ matrix.action }}
check-gitbutler-changeset:
needs: [changes, rust-init]
if: ${{ needs.changes.outputs.gitbutler-changeset == 'true' }}
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
strategy:
matrix:
action:
- test
- check
- check-tests
features:
- ''
- '*'
- []
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/check-crate
with:
crate: gitbutler-changeset
features: ${{ toJson(matrix.features) }}
action: ${{ matrix.action }}
check-gitbutler-git:
needs: [changes, rust-init]
if: ${{ needs.changes.outputs.gitbutler-git == 'true' }}
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
strategy:
matrix:
action:
- test
- check
features:
- ''
- '*'
- []
- [tokio]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/check-crate
with:
crate: gitbutler-git
features: ${{ toJson(matrix.features) }}
action: ${{ matrix.action }}
check-gitbutler-core:
needs: [changes, rust-init]
if: ${{ needs.changes.outputs.gitbutler-core == 'true' }}
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
strategy:
matrix:
action:
- test
- check
features:
- ''
- '*'
- []
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/check-crate
with:
crate: gitbutler-git
features: ${{ toJson(matrix.features) }}
action: ${{ matrix.action }}
check-rust:
if: always()
needs:
- changes
- check-gitbutler-tauri
- check-gitbutler-core
- check-gitbutler-changeset
- check-gitbutler-git
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
allowed-skips: ${{ toJSON(needs) }}
jobs: ${{ toJSON(needs) }}