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

Implement validation module #7

Merged
merged 1 commit into from
Aug 1, 2024
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
31 changes: 31 additions & 0 deletions .ci/test-cover
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -e

DESTDIR="${PWD}/target/cover"

rustup component add llvm-tools
cargo install grcov

export RUSTFLAGS="-Cinstrument-coverage"
export LLVM_PROFILE_FILE="${DESTDIR}/default_%m_%p.profraw"
cargo test

grcov "${DESTDIR}" \
--ignore '**/clang-sys*/**' \
--ignore "$HOME/.cargo/**" \
--ignore-not-existing \
--ignore 'tests/**' \
--excl-start '#(\[cfg\(test\)\]|\[test\])' \
--llvm \
--binary-path "target/debug/" \
-s . \
--branch \
-o "${DESTDIR}" \
--output-types html,cobertura

xmllint --xpath "concat('Coverage: ', 100 * string(//coverage/@line-rate), '%')" "${DESTDIR}/cobertura.xml"

if [ "$(uname -o)" = "Darwin" ] && [ -z "$CI" ]; then
open "${DESTDIR}/html/index.html"
fi
10 changes: 10 additions & 0 deletions .github/workflows/test-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@ jobs:
uses: dtolnay/rust-toolchain@stable
- name: Run pre-commit
uses: pre-commit/[email protected]
- name: Install dependencies
run: sudo apt-get install -y libxml2-utils
- name: Generate Coverage
run: make cover RUST_BACKTRACE=1
- name: Publish Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: pgxn/meta
files: target/cover/cobertura.xml
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ repos:
name: Don't permit large files
exclude_types: [image]

- repo: local
hooks:
- id: cargo-doc
name: cargo doc
entry: cargo doc
language: system
pass_filenames: false

- repo: https://github.com/backplane/pre-commit-rust-hooks
rev: v1.1.0
hooks:
Expand Down
212 changes: 211 additions & 1 deletion Cargo.lock

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

12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "pgxn-meta-spec"
name = "pgxn_meta"
version = "0.1.0"
description = "The PGXN distribution metadata specification"
repository = "https://github.com/pgxn/pgxn-meta-spec"
Expand All @@ -12,10 +12,12 @@ exclude = [ ".github", ".gitattributes", "target", ".vscode", ".gitignore" ]

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

[dev-dependencies]
boon = "0.6"
serde_json = "1.0"

[dependencies]
boon = "0.6"
relative-path = "1.9.3"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
spdx = "0.10.6"
wax = "0.6.0"

[dev-dependencies]
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test # Validate the JSON schema.
.PHONY: test # Run the full test suite.
test:
@cargo test

Expand All @@ -9,3 +9,14 @@ test:
.PHONY: lint # Lint the project
lint: .pre-commit-config.yaml
@pre-commit run --show-diff-on-failure --color=always --all-files

.PHONY: cover # Run cover tests and generate & open a report.
cover:
@./.ci/test-cover

.PHONY: docs # Generate and open cargo docs.
docs: target/doc/pgxn_meta/index.html
open $<

target/doc/pgxn_meta/index.html: $(shell find . -name \*.rs)
cargo doc
Loading