Skip to content

Commit

Permalink
Merge pull request #8 from oiwn/dev
Browse files Browse the repository at this point in the history
better CI/CD, remove amc config file to be recursively included
  • Loading branch information
oiwn authored Jan 25, 2025
2 parents 1e2b072 + c22948f commit 1695e72
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 4 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/additional-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# .github/workflows/additional-checks.yml
name: additional checks

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
security-audit:
name: security audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install cargo-audit
run: cargo install cargo-audit
- name: run security audit
run: cargo audit

docs:
name: documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: check documentation
env:
rustdocflags: "-d warnings"
run: cargo doc --no-deps --all-features --workspace
44 changes: 44 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# .github/workflows/code-quality.yml
name: Code Quality

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Clippy check
run: cargo clippy --all-features --workspace -- -D warnings
64 changes: 64 additions & 0 deletions .github/workflows/platform-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Platform & Coverage

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
cross-platform:
name: Cross-platform tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Run unit tests only
run: cargo test --workspace --no-default-features

coverage:
name: Code coverage
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate code coverage
run: cargo llvm-cov --workspace --lcov --output-path lcov.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true
verbose: true
File renamed without changes.
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# .github/workflows/test.yml
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Cargo check
run: cargo check --all-features

- name: Run unit tests
run: cargo test --all-features

# - name: Run integration tests
# run: cargo test --test '*' --all-features --workspace
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "all-my-circuits"
version = "0.1.6"
version = "0.1.7"
edition = "2021"

authors = ["oiwn <[email protected]>"]
Expand Down Expand Up @@ -37,7 +37,7 @@ toml = "0.8"
walkdir = "2.5"

[dev-dependencies]
tempfile = "3.13"
tempfile = "3"

[[bin]]
name = "amc"
Expand Down
10 changes: 9 additions & 1 deletion notes.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#+title: Notes

* Features
- [X] if .toml file included into .amc.toml file explode .amc.toml itself
- [ ] detect if project is Rust project
- [ ] Parse just signatures and structure for Rust files
- [ ] Parse signatures and structures for Rust files

* Priorities and Tokens
- [ ] figure out how to handle rage projects
- [ ] split with priorities
- [ ] control the size

* Figure out if it's possible to quickly build map of tags
27 changes: 26 additions & 1 deletion src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use ignore::WalkBuilder;
use log::{debug, info};
use std::path::{Path, PathBuf};

const EXCLUDED_FILES: &[&str] = &[".amc.toml"];

pub struct FileWalker {
extensions: Vec<String>,
}
Expand Down Expand Up @@ -58,7 +60,7 @@ impl FileWalker {
let files: Vec<FileEntry> = builder
.build()
.filter_map(|entry| entry.ok())
.filter(|entry| entry.file_type().map_or(false, |ft| ft.is_file()))
.filter(|entry| entry.file_type().is_some_and(|ft| ft.is_file()))
.filter(|entry| {
let is_valid = self.is_valid_extension(entry.path());
debug!(
Expand All @@ -85,6 +87,11 @@ impl FileWalker {
}

fn is_valid_extension(&self, path: &Path) -> bool {
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
if EXCLUDED_FILES.contains(&file_name) {
return false;
}
}
path.extension()
.and_then(|ext| ext.to_str())
.map(|ext| self.extensions.iter().any(|allowed_ext| allowed_ext == ext))
Expand Down Expand Up @@ -197,4 +204,22 @@ mod tests {

Ok(())
}

#[test]
fn test_exclude_config_file() -> Result<()> {
let temp_dir = setup_test_directory()?;
fs::write(temp_dir.path().join(".amc.toml"), "content")?;

let walker = FileWalker::new(vec!["toml".to_string()]);
let files = walker.walk(temp_dir.path())?;

for file in &files {
assert_ne!(
file.relative_path.file_name().unwrap().to_str().unwrap(),
".amc.toml"
);
}

Ok(())
}
}

0 comments on commit 1695e72

Please sign in to comment.