-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rust template files * Added badges * Added Python support for test folder * Set explicit ubuntu version, use a requirements.txt file for Python packages, explicit versions * Add cargo-husky hooks
- Loading branch information
Showing
10 changed files
with
240 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
# | ||
# This hook was set by cargo-husky v1.5.0: https://github.com/rhysd/cargo-husky#readme | ||
# Generated by script /home/amsmith/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-husky-1.5.0/build.rs | ||
# Output at /home/amsmith/git/arrow/svc-template-rust/target/debug/build/cargo-husky-849ff88dd598a11b/out | ||
# | ||
|
||
echo "pre-commit" # should be visible in the console when doing a git commit | ||
|
||
set -e | ||
|
||
# RUST | ||
echo '+cargo test --all' | ||
cargo test --all | ||
echo '+cargo clippy --all -- -D warnings' | ||
cargo clippy --all -- -D warnings | ||
echo '+cargo fmt --all -- --check' | ||
cargo fmt --all -- --check | ||
|
||
# PYTHON 3 | ||
echo '+yapf -r -i -vv . style google' | ||
yapf -r -i -vv . style google | ||
echo 'flake8 .' | ||
flake8 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# https://doc.rust-lang.org/cargo/reference/config.html | ||
|
||
[build] | ||
rustflags = [ | ||
"-Wmissing_docs", | ||
"-Wmissing_debug_implementations", | ||
"-Wmissing_copy_implementations", | ||
"-Wtrivial_casts", | ||
"-Wtrivial_numeric_casts", | ||
"-Wunsafe_code", | ||
"-Wunstable_features", | ||
"-Wunused_import_braces", | ||
"-Wunused_qualifications" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Check file validity at: https://rhysd.github.io/actionlint/ | ||
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
name: Python Checks | ||
|
||
# env: | ||
# 2022/07/12: Can't use env.VALUE in "runs-on" field yet | ||
# UBUNTU_VERSION: ubuntu-20.04 | ||
|
||
jobs: | ||
formatting-check: | ||
name: Formatting Check | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: YAPF for proper formatting | ||
run: | | ||
python3 -m pip install -r requirements.txt | ||
yapf -r -i -vv . style google | ||
flake8-lint: | ||
runs-on: ubuntu-20.04 | ||
name: Lint | ||
steps: | ||
- name: Check out source repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Python environment | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.10" | ||
- name: flake8 Lint | ||
uses: py-actions/flake8@v2 | ||
with: | ||
# ignore: "F401" | ||
exclude: "src/ignoreme.py" | ||
max-line-length: "100" | ||
path: "src" | ||
plugins: "flake8-bugbear==22.1.11 flake8-black" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Check file validity at: https://rhysd.github.io/actionlint/ | ||
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
name: Rust Checks | ||
|
||
env: | ||
RUST_VERSION: 1.62.0 | ||
# 2022/07/12: Can't use env.VALUE in "runs-on" field yet | ||
# UBUNTU_VERSION: ubuntu-20.04 | ||
|
||
jobs: | ||
check: | ||
name: Checks | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: ${{ env.RUST_VERSION }} | ||
override: true | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: check | ||
|
||
build_and_test_debug: | ||
name: Build & Test | ||
runs-on: ubuntu-20.04 | ||
env: | ||
RUSTC_BOOTSTRAP: 1 | ||
CARGO_INCREMENTAL: 0 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: ${{ env.RUST_VERSION }} | ||
override: true | ||
|
||
- name: Build | ||
run: cargo rustc -- -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort | ||
|
||
- name: Test | ||
run: cargo test | ||
|
||
# Coming soon: grcov + push results to website or service (coveralls, etc.) | ||
|
||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: ${{ env.RUST_VERSION }} | ||
override: true | ||
- run: rustup component add rustfmt | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
|
||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: ${{ env.RUST_VERSION }} | ||
override: true | ||
- run: rustup component add clippy | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: -- -D warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "svc-template-rust" | ||
version = "0.1.0" | ||
edition = "2021" # Allowed values are 2015, 2018, 2021 | ||
# Rust Editions: https://doc.rust-lang.org/edition-guide/index.html | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
cargo-husky = "1" | ||
|
||
[dev-dependencies.cargo-husky] | ||
version = "1" | ||
default-features = false # Disable features which are enabled by default | ||
features = ["user-hooks"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# svc-template-rust | ||
Arrow Service repository template for Rust services | ||
![Arrow Banner](https://github.com/Arrow-air/.github/raw/main/profile/assets/arrow_v2_twitter-banner_neu.png) | ||
|
||
# MODULE_NAME Service | ||
*Replace the repository name for each:* | ||
|
||
![Rust | ||
Checks](https://github.com/arrow-air/svc-template-rust/actions/workflows/rust_ci.yml/badge.svg?branch=main) | ||
![Python Flake8](https://github.com/arrow-air/svc-template-rust/actions/workflows/python_ci.yml/badge.svg?branch=main) | ||
![Arrow DAO Discord](https://img.shields.io/discord/853833144037277726?style=plastic) | ||
|
||
## :telescope: Overview | ||
*This is a high level description of this module.* | ||
|
||
## :scroll: Documentation | ||
The following documents are relevant to this service: | ||
- [Concept of Operations](FIXME) | ||
- [Requirements & User Stories](FIXME) | ||
- [SDD](./docs/sdd.md) | ||
|
||
## :busts_in_silhouette: Arrow DAO | ||
Learn more about us: | ||
- [Website](https://www.arrowair.com/) | ||
- [Arrow Docs](https://www.arrowair.com/docs/intro) | ||
- [Discord](https://discord.com/invite/arrow) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
yapf==0.32.0 | ||
flake8==4.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//! Hello world example for Rust | ||
//! This is a crate description, needed or else missing_docs warning will occur | ||
|
||
/// Prints "Hello, world!" | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `name` - A string slice that holds the name of a person or entity | ||
/// | ||
fn hello(name: &str) { | ||
println!("Hello, {name}!"); | ||
} | ||
|
||
fn main() { | ||
hello("Arrow Contributor"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Do not edit this file. |