Skip to content

Commit

Permalink
feat(CI): execute for each directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbe-Haegeman committed Dec 18, 2024
1 parent d3d8d0b commit 1d80d56
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 25 deletions.
6 changes: 5 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ updates:
schedule:
interval: weekly
- package-ecosystem: cargo
directory: /
directory: /operators/kube-rs-building-cronjob
schedule:
interval: weekly
- package-ecosystem: cargo
directory: /operators/poc-secondary-resource-management
schedule:
interval: weekly
34 changes: 34 additions & 0 deletions .github/workflows/check_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This all is a workaround for the [lack of YAML anchors in Github Actions](https://github.com/actions/runner/issues/1182).
# Once those are added, this file can be merged with /reusable/check.yml
name: checks execute

permissions:
contents: read
# This configuration allows maintainers of this repo to create a branch and pull request based on
# the new branch. Restricting the push trigger to the main branch ensures that the PR only gets
# built once.
on:
push:
branches: [main]
paths:
- operators/kube-rs-building-cronjob/**
- operators/poc-secondary-resource-management/**
pull_request:
paths:
- operators/kube-rs-building-cronjob/**
- operators/poc-secondary-resource-management/**
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
use-reusable:
uses: ./.github/workflows/reusable/check.yml
with:
directories: |
operators/kube-rs-building-cronjob/**
operators/poc-secondary-resource-management/**
msrv: "1.56.1"
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 changes: 32 additions & 16 deletions .github/workflows/reusable/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,32 @@
# - msrv: check that the msrv specified in the crate is correct
permissions:
contents: read
# This configuration allows maintainers of this repo to create a branch and pull request based on
# the new branch. Restricting the push trigger to the main branch ensures that the PR only gets
# built once.

# This all is a workaround for the [lack of YAML anchors in Github Actions](https://github.com/actions/runner/issues/1182).
# Once those are added, this file can be merged with /check_config.yml
on:
push:
branches: [main]
pull_request:
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
workflow_call:
inputs:
directories:
description: "List of directories to check"
required: true
type: array
msrv:
description: "Minimum Supported Rust Version"
required: true
type: string
secrets:
GITHUB_TOKEN:
required: true

name: check
jobs:
fmt:
runs-on: ubuntu-latest
name: stable / fmt
strategy:
matrix:
directory: ${{ inputs.directories }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -45,6 +54,7 @@ jobs:
matrix:
# Get early warning of new lints which are regularly introduced in beta channels.
toolchain: [stable, beta]
directory: ${{ inputs.directories }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -62,6 +72,9 @@ jobs:
semver:
runs-on: ubuntu-latest
name: semver
strategy:
matrix:
directory: ${{ inputs.directories }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -78,6 +91,9 @@ jobs:
# API be documented as only available in some specific platforms.
runs-on: ubuntu-latest
name: nightly / doc
strategy:
matrix:
directory: ${{ inputs.directories }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -112,15 +128,15 @@ jobs:
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
matrix:
msrv: ["1.56.1"] # 2021 edition requires 1.56
name: ubuntu / ${{ matrix.msrv }}
directory: ${{ inputs.directories }}
name: ubuntu / ${{ inputs.msrv }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install ${{ matrix.msrv }}
- name: Install ${{ inputs.msrv }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.msrv }}
- name: cargo +${{ matrix.msrv }} check
toolchain: ${{ inputs.msrv }}
- name: cargo +${{ inputs.msrv }} check
run: cargo check
24 changes: 16 additions & 8 deletions .github/workflows/reusable/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@
# information about how the concurrency cancellation and workflow triggering works
permissions:
contents: read

# This all is a workaround for the [lack of YAML anchors in Github Actions](https://github.com/actions/runner/issues/1182).
# Once those are added, this file can be merged with /check_config.yml
on:
push:
branches: [main]
pull_request:
schedule:
- cron: "7 7 * * 1"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
workflow_call:
inputs:
directories:
description: "List of directories to check"
required: true
type: array

name: rolling
jobs:
# https://twitter.com/mycoliza/status/1571295690063753218
nightly:
runs-on: ubuntu-latest
name: ubuntu / nightly
strategy:
matrix:
directory: ${{ inputs.directories }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -38,6 +43,9 @@ jobs:
# to).
runs-on: ubuntu-latest
name: ubuntu / beta / updated
strategy:
matrix:
directory: ${{ inputs.directories }}
# There's no point running this if no Cargo.lock was checked in in the first place, since we'd
# just redo what happened in the regular test job. Unfortunately, hashFiles only works in if on
# steps, so we repeat it.
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/scheduled_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This all is a workaround for the [lack of YAML anchors in Github Actions](https://github.com/actions/runner/issues/1182).
# Once those are added, this file can be merged with /reusable/schedule.yml
name: scheduled execute

permissions:
contents: read

on:
push:
branches: [main]
paths:
- operators/kube-rs-building-cronjob/**
- operators/poc-secondary-resource-management/**
pull_request:
paths:
- operators/kube-rs-building-cronjob/**
- operators/poc-secondary-resource-management/**
schedule:
- cron: "7 7 * * 1"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
use-reusable:
uses: ./.github/workflows/reusable/scheduled.yml
with:
directories: |
operators/kube-rs-building-cronjob/**
operators/poc-secondary-resource-management/**

0 comments on commit 1d80d56

Please sign in to comment.