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

Add initial version of validator #476

Merged
merged 5 commits into from
Apr 13, 2022
Merged
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
54 changes: 21 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ jobs:
command: fmt
args: --all -- --check

clippy:
name: Clippy Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Toolchain
uses: oxidecomputer/actions-rs_toolchain@oxide/master
# see https://github.com/actions-rs/toolchain/pull/209
# uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
target: ${{ matrix.target }}
- run: rustup component add clippy
- uses: Swatinem/rust-cache@1232abb8968faf344409165de17cbf9e7f340fd8
- uses: actions-rs/clippy-check@9d09632661e31982c0be8af59aeb96b680641bc4
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features

test:
name: Test
strategy:
Expand Down Expand Up @@ -71,36 +91,4 @@ jobs:
- uses: actions-rs/cargo@4ff6ec2846f6e7217c1a9b0b503506665f134c4b
with:
command: run
args: -- --model cuboid --export cuboid.3mf
- uses: actions-rs/cargo@4ff6ec2846f6e7217c1a9b0b503506665f134c4b
with:
command: run
args: -- --model group --export group.3mf
- uses: actions-rs/cargo@4ff6ec2846f6e7217c1a9b0b503506665f134c4b
with:
command: run
args: -- --model spacer --export spacer.3mf
- uses: actions-rs/cargo@4ff6ec2846f6e7217c1a9b0b503506665f134c4b
with:
command: run
args: -- --model star --export star.3mf

clippy:
name: Clippy Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Toolchain
uses: oxidecomputer/actions-rs_toolchain@oxide/master
# see https://github.com/actions-rs/toolchain/pull/209
# uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
target: ${{ matrix.target }}
- run: rustup component add clippy
- uses: Swatinem/rust-cache@1232abb8968faf344409165de17cbf9e7f340fd8
- uses: actions-rs/clippy-check@9d09632661e31982c0be8af59aeb96b680641bc4
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
args: --package validator
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"models/star",

"tools/release-operator",
"tools/validator",
]
default-members = [
"crates/fj-app",
Expand Down
1 change: 1 addition & 0 deletions tools/release-operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "release-operator"
version = "0.3.1"
edition = "2021"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
8 changes: 8 additions & 0 deletions tools/validator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "validator"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
anyhow = "1.0.56"
3 changes: 3 additions & 0 deletions tools/validator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Validator

Used by the CI build to export (and in the future, validate) 3MF files.
27 changes: 27 additions & 0 deletions tools/validator/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use std::{fs, process::Command};

use anyhow::{anyhow, bail};

fn main() -> anyhow::Result<()> {
for model in fs::read_dir("models")? {
let model = model?;
let model = model.file_name().into_string().map_err(|err| {
anyhow!("Failed to convert directory name to `String`: {:?}", err)
})?;

let export_file = format!("{model}.3mf");

let exit_status = Command::new("cargo")
.arg("run")
.arg("--")
.args(["--model", &model])
.args(["--export", &export_file])
.status()?;

if !exit_status.success() {
bail!("Exporting model failed with error status: {}", exit_status);
}
}

Ok(())
}