Skip to content

Commit

Permalink
first try with reusable workflow #68
Browse files Browse the repository at this point in the history
  • Loading branch information
mdpadberg committed Nov 20, 2023
1 parent b6e10fb commit 7a02089
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 117 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Security audit
name: ci-cargo-audit
on:
schedule:
- cron: '0 0 * * 1'
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: ci-pr

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
call-workflow-rust-cache:
name: run rust-cache action
uses: mdpadberg/multi-cf/.github/workflows/rust-cache.yml@main
call-workflow-clippy:
name: run clippy github action
needs: [call-workflow-rust-cache]
uses: mdpadberg/multi-cf/.github/workflows/clippy.yml@main
secrets: inherit
call-workflow-unit-tests:
name: run unit tests
needs: [call-workflow-rust-cache]
uses: mdpadberg/multi-cf/.github/workflows/unit-tests.yml@main
call-workflow-integration-tests:
name: run integration tests
needs: [call-workflow-rust-cache]
uses: mdpadberg/multi-cf/.github/workflows/integration-tests@main
65 changes: 18 additions & 47 deletions .github/workflows/tags.yml → .github/workflows/ci-tags.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,27 @@
name: tags
name: ci-tags

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"

jobs:
unit-tests:
call-workflow-rust-cache:
name: run rust-cache action
uses: mdpadberg/multi-cf/.github/workflows/rust-cache.yml@main
call-workflow-clippy:
name: run clippy github action
needs: [call-workflow-rust-cache]
uses: mdpadberg/multi-cf/.github/workflows/clippy.yml@main
secrets: inherit
call-workflow-unit-tests:
name: run unit tests
strategy:
matrix:
include:
- os: macos-latest
rust-target: x86_64-apple-darwin
- os: ubuntu-latest
rust-target: x86_64-unknown-linux-gnu
- os: windows-latest
rust-target: x86_64-pc-windows-gnu
runs-on: ${{ matrix.os }}
steps:
- name: Set autocrlf
shell: bash
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
git config --global core.autocrlf false
fi
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust with cargo
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.rust-target }}
- name: Restore cargo cache
uses: Swatinem/rust-cache@v2
- name: Run unit tests
run: cargo test --verbose
integration-tests:
needs: [call-workflow-rust-cache]
uses: mdpadberg/multi-cf/.github/workflows/unit-tests.yml@main
call-workflow-integration-tests:
name: run integration tests
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust with cargo
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
- name: Restore cargo cache
uses: Swatinem/rust-cache@v2
- name: check out the source code
run: docker-compose up --exit-code-from mcf --build
needs: [call-workflow-rust-cache]
uses: mdpadberg/multi-cf/.github/workflows/integration-tests@main
create_release:
name: Create release
runs-on: ubuntu-latest
Expand All @@ -71,7 +40,7 @@ jobs:
prerelease: false
build_release:
name: Build release
needs: [create_release]
needs: [call-workflow-rust-cache, create_release]
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -103,6 +72,8 @@ jobs:
target: ${{ matrix.rust-target }}
- name: Restore cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.os }}-${{ matrix.rust-target }}
- name: Version bump
shell: bash
run: |
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: run clippy github action

on:
workflow_call:
secrets:
token:
required: true

jobs:
clippy:
name: run clippy github action
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust with cargo
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Restore cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ubuntu-latest-x86_64-unknown-linux-gnu
- uses: giraffate/clippy-action@v1
with:
reporter: 'github-pr-review'
github_token: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: run integration tests

on:
workflow_call:

jobs:
integration-tests:
name: run integration tests
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust with cargo
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
- name: Restore cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ubuntu-latest-x86_64-unknown-linux-gnu
- name: Run integration tests
run: docker-compose up --exit-code-from mcf --build
69 changes: 0 additions & 69 deletions .github/workflows/pr.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/rust-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: run rust-cache action

on:
workflow_call:

jobs:
rust-cache:
name: run rust-cache action
strategy:
matrix:
include:
- os: macos-latest
rust-target: x86_64-apple-darwin
- os: ubuntu-latest
rust-target: x86_64-unknown-linux-gnu
- os: windows-latest
rust-target: x86_64-pc-windows-gnu
runs-on: ${{ matrix.os }}
steps:
- name: Install Rust with cargo
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Restore cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.os }}-${{ matrix.rust-target }}
38 changes: 38 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: run unit tests

on:
workflow_call:

jobs:
unit-tests:
name: run unit tests
strategy:
matrix:
include:
- os: macos-latest
rust-target: x86_64-apple-darwin
- os: ubuntu-latest
rust-target: x86_64-unknown-linux-gnu
- os: windows-latest
rust-target: x86_64-pc-windows-gnu
runs-on: ${{ matrix.os }}
steps:
- name: Set autocrlf
shell: bash
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
git config --global core.autocrlf false
fi
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust with cargo
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.rust-target }}
- name: Restore cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.os }}-${{ matrix.rust-target }}
- name: Run unit tests
run: cargo test --verbose

0 comments on commit 7a02089

Please sign in to comment.