Skip to content

Commit 59dff0d

Browse files
Move udev discovery handler from core Akri repo
Signed-off-by: Kate Goldenring <[email protected]>
1 parent d6d906b commit 59dff0d

32 files changed

+8745
-2
lines changed

.github/pull_request_template.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- Thank you for contributing to the Akri Udev Discovery Handler repo! Before submitting this PR, please make sure:
2+
1. Read the Contributing Guide before submitting your PR: https://docs.akri.sh/community/contributing
3+
1. If this PR closes another issue, add 'closes #<issue number>' somewhere in the PR summary. GitHub will automatically close that issue when this PR gets merged. Alternatively, adding 'refs #<issue number>' will not close the issue, but help provide the reviewer more context. -->
4+
5+
**What this PR does / why we need it**:
6+
7+
**Special notes for your reviewer**:
8+
9+
**If applicable**:
10+
- [ ] this PR has an associated PR with documentation in [akri-docs](https://github.com/project-akri/akri-docs)
11+
- [ ] this PR contains unit tests
12+
- [ ] added code adheres to standard Rust formatting (`cargo fmt`)
13+
- [ ] code builds properly (`cargo build`)
14+
- [ ] code is free of common mistakes (`cargo clippy`)
15+
- [ ] all tests succeed (`cargo test`)
16+
- [ ] inline documentation builds (`cargo doc`)
17+
- [ ] all commits pass the [DCO bot check](https://probot.github.io/apps/dco/) by being signed off -- see the failing DCO check for instructions on how to retroactively sign commits

.github/workflows/build-container.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build and Push Production Udev Discovery Handler Container
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- .github/workflows/build-rust-code.yml
8+
- build/Dockerfile.rust
9+
- '**.rs'
10+
- '**/Cargo.toml'
11+
- '**/Cargo.lock'
12+
- version.txt
13+
release:
14+
types:
15+
- published
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 50
21+
env:
22+
AKRI_COMPONENT: "udev-discovery-handler"
23+
24+
steps:
25+
- name: Checkout the head commit of the branch
26+
uses: actions/checkout@v3
27+
with:
28+
persist-credentials: false
29+
30+
- name: Get discovery handler version
31+
id: version-string
32+
run: |
33+
echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT
34+
35+
- name: Set up QEMU
36+
uses: docker/setup-qemu-action@v3
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Docker meta
41+
uses: docker/metadata-action@v5
42+
id: meta
43+
with:
44+
images: ghcr.io/project-akri/akri/${{ env.AKRI_COMPONENT }}
45+
labels: |
46+
org.opencontainers.image.title=akri-${{env.AKRI_COMPONENT}}
47+
tags: |
48+
type=ref,event=pr
49+
type=semver,pattern={{version}}
50+
type=semver,pattern={{major}}.{{minor}}
51+
type=raw,value=${{steps.version-string.outputs.version}},enable=${{github.event_name != 'release'}}
52+
53+
- name: Build and push
54+
uses: docker/build-push-action@v5
55+
with:
56+
context: .
57+
push: ${{ github.event_name != 'pull_request' }}
58+
build-args: |
59+
AKRI_COMPONENT=${{env.AKRI_COMPONENT}}
60+
EXTRA_CARGO_ARGS=--release
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
file: build/Dockerfile.rust
64+
platforms: linux/amd64,linux/arm64,linux/arm/v7

.github/workflows/check-rust.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Check Rust
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- .github/workflows/check-rust.yml
8+
- '**.rs'
9+
- '**/Cargo.toml'
10+
- '**/Cargo.lock'
11+
pull_request:
12+
branches: [ main ]
13+
paths:
14+
- .github/workflows/check-rust.yml
15+
- '**.rs'
16+
- '**/Cargo.toml'
17+
- '**/Cargo.lock'
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 30
26+
27+
steps:
28+
- name: Checkout the head commit of the branch
29+
uses: actions/checkout@v3
30+
with:
31+
persist-credentials: false
32+
33+
- name: Rust install
34+
uses: dtolnay/rust-toolchain@master
35+
with:
36+
toolchain: 1.68.1
37+
components: clippy, rustfmt
38+
- name: Install Linux requirements
39+
run: |
40+
apt_dependencies="git curl libssl-dev pkg-config libudev-dev"
41+
echo "Run apt update and apt install the following dependencies: $apt_dependencies"
42+
sudo apt update
43+
sudo apt install -y $apt_dependencies
44+
- name: Check rust format
45+
run: cargo fmt --all -- --check
46+
- name: Check clippy
47+
run: cargo clippy --all
48+
- name: Check clippy for tests
49+
run: cargo clippy --all-targets --all-features -- -D warnings -A clippy::derive_partial_eq_without_eq
50+
- name: Run check
51+
run: cargo check
52+
- name: Run tests
53+
run: cargo test --workspace
54+
- name: Run doc
55+
run: export RUSTDOCFLAGS="-Dwarnings" && cargo doc --no-deps

.github/workflows/run-tarpaulin.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Tarpaulin Code Coverage
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- .github/workflows/run-tarpaulin.yml
8+
- '**.rs'
9+
- '**/Cargo.toml'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- .github/workflows/run-tarpaulin.yml
14+
- '**.rs'
15+
- '**/Cargo.toml'
16+
17+
env:
18+
CARGO_TERM_COLOR: always
19+
CARGO_VERSION: 1.68.1
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
# There is a second, hidden timeout in this workflow. When the tarpaulin container is created,
25+
# it is created with a CMD that sleeps for 600 minutes. A more reasonable value could be selected,
26+
# but it seems easier to make it SOOOO big that timeout-minutes is likely to never be impacted by
27+
# it.
28+
#
29+
# But, if this workflow is mysteriously timing out after 600 minutes, make changes to the docker
30+
# create command in the Create tarpaulin instance step.
31+
timeout-minutes: 30
32+
33+
steps:
34+
- name: Checkout the head commit of the branch
35+
uses: actions/checkout@v3
36+
with:
37+
persist-credentials: false
38+
39+
- name: Create tarpaulin instance
40+
run: docker create --network host --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin:0.25.1 bash -c "echo 'sleep 600m; echo bye' > /tmp/keep_alive.sh; chmod 777 /tmp/keep_alive.sh; /tmp/keep_alive.sh" > container_id.txt
41+
- name: Start tarpaulin instance
42+
run: docker start $(cat container_id.txt)
43+
- name: Install linux requirement in tarpaulin instance
44+
run: docker exec $(cat container_id.txt) sh -c "echo Run apt update and apt install the following dependencies - git curl libssl-dev pkg-config libudev-dev ; apt update ; apt install -y git curl libssl-dev pkg-config libudev-dev"
45+
- name: Install desired rust version
46+
run: docker exec $(cat container_id.txt) sh -c "rustup install $CARGO_VERSION"
47+
- name: Tell cargo to use desired rust version
48+
run: docker exec $(cat container_id.txt) sh -c "rustup override set $CARGO_VERSION"
49+
- name: Install rust requirements in tarpaulin instance
50+
run: docker exec $(cat container_id.txt) sh -c "rustup component add rustfmt"
51+
- name: Run tarpaulin
52+
run: docker exec $(cat container_id.txt) sh -c "RUST_LOG=trace cargo tarpaulin -v --all-features --out Xml"
53+
54+
- name: Upload report to codecov for push
55+
if: (!(startsWith(github.event_name, 'pull_request')))
56+
uses: codecov/codecov-action@v3
57+
with:
58+
token: ${{secrets.CODECOV_TOKEN}}
59+
fail_ci_if_error: true
60+
verbose: true
61+
62+
- name: Archive code coverage results
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: code-coverage-report
66+
path: cobertura.xml

0 commit comments

Comments
 (0)