Git Product home page Git Product logo

hoijui / osh-tool Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 92.33 MB

A command line tool for Open Source Hardware (OSH) technical project linting (quality assessment).

Home Page: https://hoijui.github.io/osh-tool/

License: GNU Affero General Public License v3.0

Dockerfile 3.17% Nim 81.16% Shell 15.55% CSS 0.12%
cli hardware open-source-hardware tool oseg fchh interfacer-project-eu interfacer-project-eu-wp4-3

osh-tool's Introduction

osh-tool

License: AGPL-3.0-or-later REUSE status

In cooperation with FabCity Hamburg In cooperation with Open Source Ecology Germany

A command line tool for Open Source Hardware (OSH) technical project linting (quality assessment).

Download binaries (latest build, Linux & Windows, 64bit)

What it can do:

  • Check for (non standardized) OSH project design compliance
  • Create human-readable reports
  • Create machine-readable reports

Examples

Badges

To be used at the top of a README:

  • Meditation Bench - OSH - Openness
  • Agro Circle - OSH - Openness
  • OHLOOM - OSH - compliance
  • OHLOOM - OSH - machineReadability
  • OHLOOM - OSH - quality
  • OHLOOM - OSH - openness

Example Projects

Two sample hardware projects, using this tool to check their own Open Source'ness with the help of this tool, executed in CI. The generated report is linked to form the README in a badge (image after the title) with the text "OSH Report".

CI Type Sample Project Hosting Generated Report CI Script
GitHub Actions https://github.com/hoijui/MeditationBench Generated Report .github/workflows/check.yml
GitHub Actions 2 https://github.com/osegermany/AgroCircle Generated Report .github/workflows/check.yml
GitLab CI https://gitlab.com/OSEGermany/ohloom Generated Report .gitlab-ci.yml

Features

So far, It may only check/lint OSH projects, while later it is supposed to also initialize them with all sorts of standard files and tooling.

See src/checks for the currently supported checks, including at least:

  • Check README existence
  • Check LICENSE existence
  • Check okh.toml (Open Know-How OSH meta-data file) existence

Requires

To compile:

  • Nim and Nimble, version 0.10.0 or higher

Install

From repository

# Fetch the whole source code
git submodule update --init --recursive
# Latest released version
nimble install osh
# Latest developmental state inside git repository
nimble install osh@#head

From local sources

For example when using a local git clone.

nimble build
./osh --help

Usage

Simply run osh -h to see usage information.

For more details how to use it locally and on CI/build-bot, see the user documentation.

Community

Ask anything as an issue!

Similar Projects

We are not just standing on the shoulders of giants, but also toe on toe with them!

These are two of our big sister projects. They are similar both in spirit and in the way they are used on the command-line. They also work well in combination with this tool.

  • git - Master of history
  • reuse - Handles all things regarding licensing of a project and its sources

License

GNU Affero General Public License version 3

Funding

This project was funded by:

  • the European Union's Horizon 2020 research and innovation program, under grant agreement no. 869984, in the context of the OPEN!NEXT Project, from June 2021 (project start) until November 2021.

    Logo of the European Commission

  • the European Regional Development Fund (ERDF) in the context of the INTERFACER Project, from December 2021 until March 2023.

    Logo of the EU ERDF program

osh-tool's People

Contributors

damamitesh avatar hoijui avatar julianstirling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

osh-tool's Issues

Building OSH

In GitLab by @pieterhijma on Feb 6, 2023, 12:29

I can't build on latest Arch Linux. I don't know if that's relevant.

These are the error messages:

/home/pieter/osh-tool/src/checks.nim(11, 10) template/generic instantiation of `importAll` from here
/home/pieter/osh-tool/src/checks/clean_cad_files.nim(19, 22) template/generic instantiation of `parseInjectExtsAndMap` from here
/usr/lib/nim/pure/collections/tables.nim(301, 15) Error: cannot instantiate: 'A'
     Error: Build failed for package: osh_tool
        ... Execution failed with exit code 1
        ... Command: /usr/bin/nim c --colors:on --noNimblePath -d:NimblePkgVersion=0.2.0 --path:/home/pieter/.nimble/pkgs/csvtools-0.2.1 --path:/home/pieter/.nimble/pkgs/docopt-0.7.0 --path:/home/pieter/.nimble/pkgs/regex-0.20.1 --path:/home/pieter/.nimble/pkgs/unicodedb-0.11.2 --path:/home/pieter/.nimble/pkgs/shell-0.5.2 --path:/home/pieter/.nimble/pkgs/regex-0.20.1 --path:/home/pieter/.nimble/pkgs/unicodedb-0.11.2 --path:/home/pieter/.nimble/pkgs/result-0.3.0 -o:/home/pieter/osh-tool/build/osh /home/pieter/osh-tool/src/main.nim

Support EEV-blogs set of OSH checks

This is specifically tailored for electronics projects!

KEY

  • S = Schematic
  • P = PCB
  • F = Firmware and/or software
  • M = Mechanical CAD files
  • D = Design Documentation
  • B = Bill Of Materials
  • C = License used allows for commercial use

We might want to remake this logo using the clean OSH logo as a base.

Logo generator (for reference):
https://maciek134.github.io/oshw-logo-gen/

Original post (including link to video explanation):
https://www.eevblog.com/oshw/

Forum thread:
https://www.eevblog.com/forum/blog/eevblog-921-open-source-hardware-problems-solved!/

Allow to create an OKH LOSH TOML file

Given a project repository (local checkout),
we would generate an okh.toml manifest file,
with as much data as we manage to gather automatically.
The remaining fields may be:

  1. omitted,
  2. added with placeholder values
    (like "TODO" or "https://TODO.com/YOUR_ORG/YOUR_REPO/")
  3. same as 2., but commented out

NOTE:

How are the _Compliance_, _Openness_ and co. factors/percentages calculated?

The overall compliance is calculated by taking the average, weighted compliance factor
over all executed checks.
We see how this is done in Over all Checks.

Each checks compliance factor is calculated in two separate parts,
which are then combined into one (by multiplication):

Single Check Compliance

  1. The first part indicates the overall state of the check-result:
    1. 100% for Perfect
    2. 80% for Ok
    3. 60% for Acceptable
    4. 0% for everything else
  2. The second part tracks the issues.
    Starting with the whole 100% in case of no issue,
    and subtracting this high a percentage for each issue
    (regarding its severity level):
    1. High: 30% for the first issue, and then halving that consecutively (15% for the second, 7.5% for the third, ...)
    2. Middle: 15% for the first issue, and then halving that consecutively (7.5% for the second, 3.75% for the third, ...)
    3. Low: 7.5% for the first issue, and then halving that consecutively (3.75% for the second, 1.875% for the third, ...)

Examples:

Check X has final status Acceptable,
two High issues and one Low issue:

80% * (100 - (30+15 + 7.5))% = (0.8 * 47.5)% = 38%
CheckX_compliance_percent = 38
CheckX_compliance_factor = 0.38

The code for this can be found in procedure CheckRes.calcCompliance()
in src/checker.nim.

Over all Checks

For our example, we assume that there are only three checks,
with these names and sub-rating weights:

Check Name weight* openness_ hardware_
CheckX 1.0 0.3 0.6
CheckY 0.5 1.0 0.7
CheckZ 0.3 0.0 1.0

These are fixed values, defined in the source code.
They are not dependent on the project the test is run on.

To get the final ratings used later on,
we multiply all the sub-rating factors
(marked with _ in the table above)
with the weight, and use the weight for the overall compliance weight;
thus we get this table of weights:

Check Name compliance openness hardware
CheckX 1.0 0.3 0.6
CheckY 0.5 0.5 0.35
CheckZ 0.3 0.0 0.3
Sum 1.8 0.8 1.25

The Sum indicates the maximum Sum achievable by any project,
so this is our 100%.
We will use this table from now on.

Now we run the checks on a specific ProjectA,
and we get these compliance factors
(for this example, these are random numbers),
as described in Single Check Compliance.

Check Name Compliance factor
CheckX 0.38
CheckY 0.64
CheckZ 1.0

We multiply these values with the table we calculated before,
row by row, and get:

Check Name compliance openness hardware
CheckX 0.38 0.114 0.228
CheckY 0.32 0.32 0.224
CheckZ 0.3 0.0 0.3
Sum 1.0 0.434 0.852
Max-Sum 1.8 0.8 1.25
Factor 0.5556 0.5425 0.6816
Percentage 55.56% 54.25% 68.16%

get MIME types for source files

In GitLab by @moedn on Sep 15, 2021, 15:20

based on the discussion here

we need a CSV file with the following columns:

  • file extension
  • open/closed format?
  • binary or plain text?

→ for all (popular) CAD formats; which is everything in this list plus:

  • FreeCAD
  • openSCAD
  • QCAD
  • LibreCAD
  • CadQuery

Linux binaries appear to require specific GLIBC version

I get the following error when I try to run from the binary.

$ ./osh -h
    ./osh: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./osh)
    ./osh: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./osh)

Some debug info:

$ ldd --version
    ldd (Ubuntu GLIBC 2.31-0ubuntu9.9) 2.31
    Copyright (C) 2020 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Roland McGrath and Ulrich Drepper.

Generate list of names and description of checks

Each check should describe its self,
and then the tool collects the names and descriptions
and generates a human-readable description of all the checks.

  • Markdown
  • JSON
  • support output to file instead of (only) stdout

Essential running documentation missing

In GitLab by @julianstirling on Feb 25, 2022, 17:20

Running documentation is missing. I can run -h but there is little information on what I am expecting each sub-command to do, or even any context for what the entire program aims to do.

first OHLOOM log

In GitLab by @moedn on Dec 2, 2021, 12:48

Hey ho, just tested the tool on OHLOOM; this is the result of

./osh -C <path-to-OHLOOM-repo> check

- [ ] No space in file names
  - LIGHT - Files with spaces in their names (Please consider renaming them):
    
    * fatal: not a git repository (or any parent up to mount point /)
    * Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
    * fatal: not a git repository (or any parent up to mount point /)
    * Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
- [ ] README exists
  - MIDDLE - No README file found in the root directory.
    Please consider adding a 'README.md'.
    You might want to generate a template by issuing `osh init --readme`,
    or manually reating it.
- [ ] LICENSE exists
  - HEAVY - No LICENSE (or COPYING) file found in the root directory.
    Please consider adding a LICENSE(.md).
    You might want to choose one from a list by issuing `osh init --license`.
- [x] Might be generated
- [x] OKH file exists
DBG 2021-12-02 12:45:11.542+01:00 Skip reporting check because it is inapplicable to this project (in its current state) tid=355626 checkName="Clean electronics files"
- [x] No unwanted files
- [x] No sources in root

I very much like the output format :) However I did expect an outcome stating:

  • that the README exists
  • that a (hardware-specific) license exists
  • that export files are in the repo ← shouldn't be there

Does each Markdown tree root contain a README.md or index.md

Not sure how much sense this check would make, as each repo will likely have a REAME.md in the top, and thus this would always check as true.
Maybe we could exclude the repo root dir as counting as tree head? That would often be wrong, though.

projvar Not in Path

I downloaded the current binary for Linux so that I could do a trial run against one of my open hardware repos. When I run it I get an error about projvar not being in the path. I don't see anything about that in the readme. What am I missing?

$ /home/jwright/Downloads/osh-0708717-x86_64-linux/osh check
DEBUG Running projvar ...
DEBUG Now running 'projvar' ...
/home/runner/work/osh-tool/osh-tool/src/main.nim(268) main
/home/runner/work/osh-tool/osh-tool/src/main.nim(201) cli
/home/runner/work/osh-tool/osh-tool/src/tools.nim(239) runProjvar
Error: unhandled exception: Failed to run 'projvar'; make sure it is in your PATH: Additional info: Could not find command: 'projvar'. OS error: No such file or directory [IOError]

Include used tools versions in the report, not just the HTML

As in: gather them in the Nim code, and add them to whatever report formats output that is chosen (at least JSON and Markdown).

As of now, it is only collected in the BASH script that generates the HTML report.

This idea could be spun further, to .. in the end generate the whole HTML report - as is now generated in the BASH script - form Nim code.

More specific info about why a test was skipped

Checks can themselves decide that they are not applicable to a repo.
If they decide they are not, the user gets a generic message about that finding.
IT would be better to have a per-check specific message,
about why it was skipped.
This could technically be done similarly like the error messages.

This is especially interesting for output formats other then the default (Markdown list),
where it is only a DEUBG level log message.
In other formats, it could end up being directly in the output
(eg. a skip-message field).

Current example:

DEBUG Skip reporting check 'Clean electronics files', because it is inapplicable to this project (in its current state)

as CI/github action

In GitLab by @jcolomb on Jun 23, 2022, 12:34

hi,
I like the idea to have a check for a OSH repo, I do think it will only be used if it can be a GitHub action and/or gitlab CI.

PS: I would keep a repo creator tool outside of this one.

OSH-Tool Beschreibung

Warum
Wie
Wozu

allgemein und fuer jeden check

verlinken auf eine beschriebung fuer jeden check

unter Example projects im README: noch beschreiben wie genau man das benutzt:
"Wenn GitLab, dann datei kopieren, pushen, und dann kommt output im CI tab deines projekts, und erscheint auf deinen pages"

TOML not found

In GitLab by @moedn on Sep 15, 2021, 15:07

osh check

done on OHLOOM

returns

Check - OKH file exists? - Failed: Open Know-How meta-data file (^okh.toml$) not found. Please consider using the assistant (osh okh), or manually reating it. See <TODO-OKHv2-URL> for more information about OKH.

Mis-characterisation of SVG and image as generated

In GitLab by @julianstirling on Feb 25, 2022, 17:27

SVG is the native file format of Inkscape and is a valid source file. It should not be flagged as a generated file.

Similarly jpg files are generally photos which if they are in documentation the cannot be generated by a CI. Similarly some PNGs (for example high resolution renders) also generally takes specialist computing hardware and cannot be generated on-the-fly by a CI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.