Skip to content

Commit

Permalink
Configure base CI
Browse files Browse the repository at this point in the history
  • Loading branch information
thedodd committed Nov 10, 2021
1 parent e6bbb98 commit 264f026
Show file tree
Hide file tree
Showing 25 changed files with 392 additions and 494 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/_rust-ci-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: CI Base
on:
workflow_call:
inputs:
project:
type: string
required: true
description: 'The Rust project to target'
dir:
type: string
required: false
default: '.'
description: 'The directory to start from'

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
${{ inputs.dir }}/${{ inputs.project }}/target
key: cargo-${{ hashFiles(format('{0}/{1}/Cargo.lock', inputs.dir, inputs.project)) }}
restore-keys: |
${{ inputs.project }}-cargo-
- name: Setup | Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
components: clippy,rustfmt

- name: Build | Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --manifest-path ${{ inputs.dir }}/${{ inputs.project }}/Cargo.toml --all-targets -- -D warnings

- name: Build | Rustfmt
run: cargo fmt --manifest-path ${{ inputs.dir }}/${{ inputs.project }}/Cargo.toml -- --check

check:
name: check
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v2

- name: Setup | Cache Cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
${{ inputs.dir }}/${{ inputs.project }}/target
key: cargo-${{ hashFiles(format('{0}/{1}/Cargo.lock', inputs.dir, inputs.project)) }}
restore-keys: |
${{ inputs.project }}-cargo-
- name: Setup | Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal

- name: Build | Check
run: cargo check --all --manifest-path ${{ inputs.dir }}/${{ inputs.project }}/Cargo.toml

test:
name: test
needs: check # Ensure check is run first.
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v2

- name: Setup | Cache Cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
${{ inputs.dir }}/${{ inputs.project }}/target
key: cargo-${{ hashFiles(format('{0}/{1}/Cargo.lock', inputs.dir, inputs.project)) }}
restore-keys: |
${{ inputs.project }}-cargo-
- name: Setup | Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal

- name: Build | Test
run: cargo test --manifest-path ${{ inputs.dir }}/${{ inputs.project }}/Cargo.toml

- name: Build | Debug
run: cargo build --manifest-path ${{ inputs.dir }}/${{ inputs.project }}/Cargo.toml
16 changes: 16 additions & 0 deletions .github/workflows/ci-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI CLI
on:
push:
branches:
- "*"
paths:
- 'hadron-cli/**'
- "!**.md"
tags-ignore:
- "*"

jobs:
ci:
uses: hadron-project/hadron/.github/workflows/_rust-ci-base.yaml@99-compaction
with:
project: hadron-cli
16 changes: 16 additions & 0 deletions .github/workflows/ci-client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI Client
on:
push:
branches:
- "*"
paths:
- 'hadron-client/**'
- "!**.md"
tags-ignore:
- "*"

jobs:
ci:
uses: hadron-project/hadron/.github/workflows/_rust-ci-base.yaml@99-compaction
with:
project: hadron-client
16 changes: 16 additions & 0 deletions .github/workflows/ci-core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI Core
on:
push:
branches:
- "*"
paths:
- 'hadron-core/**'
- "!**.md"
tags-ignore:
- "*"

jobs:
ci:
uses: hadron-project/hadron/.github/workflows/_rust-ci-base.yaml@99-compaction
with:
project: hadron-core
22 changes: 22 additions & 0 deletions .github/workflows/ci-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI Core
on:
push:
branches:
- "*"
paths:
- 'examples/**'
- "!**.md"
tags-ignore:
- "*"

jobs:
pipeline-txp:
uses: hadron-project/hadron/.github/workflows/_rust-ci-base.yaml@99-compaction
with:
project: pipeline-transactional-processing
dir: examples
pipeline-txp:
uses: hadron-project/hadron/.github/workflows/_rust-ci-base.yaml@99-compaction
with:
project: stream-transactional-processing
dir: examples
22 changes: 22 additions & 0 deletions .github/workflows/ci-guide.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI Guide
on:
push:
branches:
- *
paths:
- guide/**

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v2

- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.4.6'

- name: Build
run: mdbook build guide
16 changes: 16 additions & 0 deletions .github/workflows/ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI Operator
on:
push:
branches:
- "*"
paths:
- 'hadron-operator/**'
- "!**.md"
tags-ignore:
- "*"

jobs:
ci:
uses: hadron-project/hadron/.github/workflows/_rust-ci-base.yaml@99-compaction
with:
project: hadron-operator
16 changes: 16 additions & 0 deletions .github/workflows/ci-stream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI Stream
on:
push:
branches:
- "*"
paths:
- 'hadron-stream/**'
- "!**.md"
tags-ignore:
- "*"

jobs:
ci:
uses: hadron-project/hadron/.github/workflows/_rust-ci-base.yaml@99-compaction
with:
project: hadron-stream
15 changes: 0 additions & 15 deletions .github/workflows/ci.yaml

This file was deleted.

File renamed without changes.
12 changes: 0 additions & 12 deletions .github/workflows/release.yaml

This file was deleted.

42 changes: 7 additions & 35 deletions hadron-stream/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ impl App {
let db = Database::new(config.clone()).await.context("error opening database")?;

// Initialize K8s client.
let client = kube::Client::try_default()
.await
.context("error initializing K8s client")?;
let client = kube::Client::try_default().await.context("error initializing K8s client")?;

// Spawn various core tasks.
let (tokens, tokens_map, secrets_map) = TokensWatcher::new(client.clone(), config.clone(), shutdown_tx.subscribe());
Expand Down Expand Up @@ -109,14 +107,8 @@ impl App {

async fn run(mut self) -> Result<()> {
let mut signals = StreamMap::new();
signals.insert(
"sigterm",
SignalStream::new(signal(SignalKind::terminate()).context("error building signal stream")?),
);
signals.insert(
"sigint",
SignalStream::new(signal(SignalKind::interrupt()).context("error building signal stream")?),
);
signals.insert("sigterm", SignalStream::new(signal(SignalKind::terminate()).context("error building signal stream")?));
signals.insert("sigint", SignalStream::new(signal(SignalKind::interrupt()).context("error building signal stream")?));

loop {
tokio::select! {
Expand All @@ -131,36 +123,16 @@ impl App {

// Begin shutdown routine.
tracing::debug!("Hadron is shutting down");
if let Err(err) = self
.tokens_handle
.await
.context("error joining token watcher handle")
.and_then(|res| res)
{
if let Err(err) = self.tokens_handle.await.context("error joining token watcher handle").and_then(|res| res) {
tracing::error!(error = ?err, "error shutting down tokens watcher");
}
if let Err(err) = self
.pipelines_handle
.await
.context("error joining pipelines watcher handle")
.and_then(|res| res)
{
if let Err(err) = self.pipelines_handle.await.context("error joining pipelines watcher handle").and_then(|res| res) {
tracing::error!(error = ?err, "error shutting down pipelines watcher");
}
if let Err(err) = self
.stream_handle
.await
.context("error joining stream controller handle")
.and_then(|res| res)
{
if let Err(err) = self.stream_handle.await.context("error joining stream controller handle").and_then(|res| res) {
tracing::error!(error = ?err, "error shutting down stream controller");
}
if let Err(err) = self
.stream_watcher_handle
.await
.context("error joining stream CR watcher handle")
.and_then(|res| res)
{
if let Err(err) = self.stream_watcher_handle.await.context("error joining stream CR watcher handle").and_then(|res| res) {
tracing::error!(error = ?err, "error shutting down stream CR watcher");
}
if let Err(err) = self.client_server.await {
Expand Down
Loading

0 comments on commit 264f026

Please sign in to comment.