Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI workflows: Forbid merges in case of test failures with conditional jobs #432

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 49 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,58 @@
name: CI
---
name: "CI"

on: [push, pull_request]
on:
push:
branches:
# Do not trigger on tags
# https://stackoverflow.com/questions/68573888/how-can-i-not-execute-a-github-action-when-i-push-a-new-tag
"**"
pull_request:

jobs:
ci:
runs-on: ${{ matrix.type.os }}
name: ${{ matrix.type.target }} (${{ matrix.type.os }})
strategy:
matrix:
type:
- { os: windows-latest, target: x86_64-pc-windows-gnu }
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
analyse_changes:
if: always()
runs-on: ubuntu-latest
outputs:
robotmk_yaml_changed: ${{ steps.filter.outputs.robotmk_yaml }}
rcc_yaml_changed: ${{ steps.filter.outputs.rcc_yaml }}
steps:
- uses: actions/checkout@v4

- uses: actions-rust-lang/[email protected]
- uses: dorny/paths-filter@v2
id: filter
with:
components: rustfmt, clippy
target: ${{ matrix.type.target }}

- run: cargo fmt -- --check
working-directory: ${{ github.workspace }}/v2/robotmk/
filters: |
robotmk_yaml:
- '.github/workflows/robotmk.yaml'
rcc_yaml:
- '.github/workflows/rcc.yaml'

- run: cargo test --all-targets --target ${{ matrix.type.target }}
working-directory: ${{ github.workspace }}/v2/robotmk/
tests:
if: always()
uses: ./.github/workflows/tests.yaml

- run: cargo clippy --all-targets --target ${{ matrix.type.target }} -- --deny warnings
working-directory: ${{ github.workspace }}/v2/robotmk/
build_robotmk:
needs:
- analyse_changes
if: ${{ needs.analyse_changes.outputs.robotmk_yaml_changed == 'true' }}
uses: ./.github/workflows/robotmk_build.yaml

rcc:
needs:
- analyse_changes
if: ${{ needs.analyse_changes.outputs.rcc_yaml_changed == 'true' }}
uses: ./.github/workflows/rcc.yaml

- run: cargo build --target ${{ matrix.type.target }}
working-directory: ${{ github.workspace }}/v2/robotmk/
check_success:
if: always()
runs-on: Ubuntu-latest
needs:
- tests
- build_robotmk
- rcc
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
allowed-skips: build_robotmk, rcc
jobs: ${{ toJSON(needs) }}
6 changes: 0 additions & 6 deletions .github/workflows/rcc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
name: "RCC"

on:
push:
paths:
- .github/workflows/rcc.yaml
pull_request:
paths:
- .github/workflows/rcc.yaml
workflow_call: {}

jobs:
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
---
name: "Upload all artifacts"

on:
push:
paths:
- .github/workflows/release.yaml
- .github/workflows/rcc.yaml
- .github/workflows/robotmk.yaml
pull_request:
paths:
- .github/workflows/release.yaml
- .github/workflows/rcc.yaml
- .github/workflows/robotmk.yaml
tags:
"**"

jobs:
tests:
uses: ./.github/workflows/tests.yaml
build_rcc:
uses: ./.github/workflows/rcc.yaml
build_robotmk:
uses: ./.github/workflows/robotmk.yaml
uses: ./.github/workflows/robotmk_build.yaml
release:
runs-on: ubuntu-latest
needs: [build_rcc, build_robotmk]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
---
name: "Robotmk"
name: "Build Robotmk"

on:
push:
paths:
- .github/workflows/robotmk.yaml
pull_request:
paths:
- .github/workflows/robotmk.yaml
workflow_call: {}

jobs:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Tests"

on:
workflow_call: {}

jobs:
ci:
runs-on: ${{ matrix.type.os }}
name: ${{ matrix.type.target }} (${{ matrix.type.os }})
strategy:
matrix:
type:
- { os: windows-latest, target: x86_64-pc-windows-gnu }
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
steps:
- uses: actions/checkout@v4

- uses: actions-rust-lang/[email protected]
with:
components: rustfmt, clippy
target: ${{ matrix.type.target }}

- run: cargo fmt -- --check
working-directory: ${{ github.workspace }}/v2/robotmk/

- run: cargo test --all-targets --target ${{ matrix.type.target }}
working-directory: ${{ github.workspace }}/v2/robotmk/

- run: cargo clippy --all-targets --target ${{ matrix.type.target }} -- --deny warnings
working-directory: ${{ github.workspace }}/v2/robotmk/

- run: cargo build --target ${{ matrix.type.target }}
working-directory: ${{ github.workspace }}/v2/robotmk/
Loading