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

Move udev discovery handler from core Akri repo #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Thank you for contributing to the Akri Udev Discovery Handler repo! Before submitting this PR, please make sure:
1. Read the Contributing Guide before submitting your PR: https://docs.akri.sh/community/contributing
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. -->

**What this PR does / why we need it**:

**Special notes for your reviewer**:

**If applicable**:
- [ ] this PR has an associated PR with documentation in [akri-docs](https://github.com/project-akri/akri-docs)
- [ ] this PR contains unit tests
- [ ] added code adheres to standard Rust formatting (`cargo fmt`)
- [ ] code builds properly (`cargo build`)
- [ ] code is free of common mistakes (`cargo clippy`)
- [ ] all tests succeed (`cargo test`)
- [ ] inline documentation builds (`cargo doc`)
- [ ] 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
64 changes: 64 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and Push Production Udev Discovery Handler Container

on:
push:
branches: [ main ]
paths:
- .github/workflows/build-rust-code.yml
- build/Dockerfile.rust
- '**.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- version.txt
release:
types:
- published

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 50
env:
AKRI_COMPONENT: "udev-discovery-handler"

steps:
- name: Checkout the head commit of the branch
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Get discovery handler version
id: version-string
run: |
echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/project-akri/akri/${{ env.AKRI_COMPONENT }}
labels: |
org.opencontainers.image.title=akri-${{env.AKRI_COMPONENT}}
tags: |
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=${{steps.version-string.outputs.version}},enable=${{github.event_name != 'release'}}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
build-args: |
AKRI_COMPONENT=${{env.AKRI_COMPONENT}}
EXTRA_CARGO_ARGS=--release
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: build/Dockerfile.rust
platforms: linux/amd64,linux/arm64,linux/arm/v7
55 changes: 55 additions & 0 deletions .github/workflows/check-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Check Rust

on:
push:
branches: [ main ]
paths:
- .github/workflows/check-rust.yml
- '**.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
pull_request:
branches: [ main ]
paths:
- .github/workflows/check-rust.yml
- '**.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout the head commit of the branch
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Rust install
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.68.1
components: clippy, rustfmt
- name: Install Linux requirements
run: |
apt_dependencies="git curl libssl-dev pkg-config libudev-dev"
echo "Run apt update and apt install the following dependencies: $apt_dependencies"
sudo apt update
sudo apt install -y $apt_dependencies
- name: Check rust format
run: cargo fmt --all -- --check
- name: Check clippy
run: cargo clippy --all
- name: Check clippy for tests
run: cargo clippy --all-targets --all-features -- -D warnings -A clippy::derive_partial_eq_without_eq
- name: Run check
run: cargo check
- name: Run tests
run: cargo test --workspace
- name: Run doc
run: export RUSTDOCFLAGS="-Dwarnings" && cargo doc --no-deps
66 changes: 66 additions & 0 deletions .github/workflows/run-tarpaulin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Tarpaulin Code Coverage

on:
push:
branches: [ main ]
paths:
- .github/workflows/run-tarpaulin.yml
- '**.rs'
- '**/Cargo.toml'
pull_request:
branches: [ main ]
paths:
- .github/workflows/run-tarpaulin.yml
- '**.rs'
- '**/Cargo.toml'

env:
CARGO_TERM_COLOR: always
CARGO_VERSION: 1.68.1

jobs:
build:
runs-on: ubuntu-latest
# There is a second, hidden timeout in this workflow. When the tarpaulin container is created,
# it is created with a CMD that sleeps for 600 minutes. A more reasonable value could be selected,
# but it seems easier to make it SOOOO big that timeout-minutes is likely to never be impacted by
# it.
#
# But, if this workflow is mysteriously timing out after 600 minutes, make changes to the docker
# create command in the Create tarpaulin instance step.
timeout-minutes: 30

steps:
- name: Checkout the head commit of the branch
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Create tarpaulin instance
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
- name: Start tarpaulin instance
run: docker start $(cat container_id.txt)
- name: Install linux requirement in tarpaulin instance
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"
- name: Install desired rust version
run: docker exec $(cat container_id.txt) sh -c "rustup install $CARGO_VERSION"
- name: Tell cargo to use desired rust version
run: docker exec $(cat container_id.txt) sh -c "rustup override set $CARGO_VERSION"
- name: Install rust requirements in tarpaulin instance
run: docker exec $(cat container_id.txt) sh -c "rustup component add rustfmt"
- name: Run tarpaulin
run: docker exec $(cat container_id.txt) sh -c "RUST_LOG=trace cargo tarpaulin -v --all-features --out Xml"

- name: Upload report to codecov for push
if: (!(startsWith(github.event_name, 'pull_request')))
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
fail_ci_if_error: true
verbose: true

- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: cobertura.xml
Loading
Loading