Skip to content

fix: add content type header to nanopub server request (fix error whe… #210

fix: add content type header to nanopub server request (fix error whe…

fix: add content type header to nanopub server request (fix error whe… #210

Workflow file for this run

name: Tests
on:
workflow_dispatch:
workflow_call:
push:
branches: [ main ]
pull_request:
jobs:
clippy:
name: 📎 fmt and clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update && rustup component add clippy rustfmt
- run: cargo fmt -- --check
- run: cargo clippy --all --all-targets --all-features
test:
name: 🧪 Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update && cargo install cargo-tarpaulin
- run: cargo build --all-features
- run: cargo test
env:
RUST_BACKTRACE: 1
test-js:
name: 🟨 Tests JavaScript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: npm
cache-dependency-path: "./js/package.json"
- run: rustup update && cargo install wasm-pack
- name: Run tests
run: ./scripts/test-js.sh
test-python:
name: 🐍 Tests Python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- run: rustup update
- name: Run tests
run: ./scripts/test-python.sh
cov:
name: ☂️ Coverage
runs-on: ubuntu-latest
container:
image: xd009642/tarpaulin:develop-nightly
options: --security-opt seccomp=unconfined
steps:
- uses: actions/checkout@v4
- name: Generate code coverage
run: cargo tarpaulin -p nanopub --out xml --exclude-files lib/src/error.rs --verbose --timeout 120
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{secrets.CODECOV_TOKEN}}
publish-docs:
name: 📚 Update docs website
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: pip install -r lib/docs/requirements.txt
- name: Deploy mkdocs on GitHub Pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mkdocs build -f lib/docs/mkdocs.yml -d dist
# mkdocs gh-deploy dont support new pages
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './lib/docs/dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
compare:
name: ⏱️ Compare speed with java and python implementations
runs-on: ubuntu-latest
env:
HYPERFINE_VERSION: '1.12.0'
STABLE_PYTHON_VERSION: '3.12'
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.STABLE_PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.STABLE_PYTHON_VERSION }}
- uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'
- name: Install hyperfine
run: |
wget https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/hyperfine_${HYPERFINE_VERSION}_amd64.deb
sudo dpkg -i hyperfine_${HYPERFINE_VERSION}_amd64.deb
- name: Install java and python tools
run: |
pip install --upgrade nanopub
wget -O nanopub.jar https://github.com/Nanopublication/nanopub-java/releases/download/nanopub-1.55/nanopub-1.55-jar-with-dependencies.jar
- name: Build ourself
run: cargo build --release
- name: Benchmark
run: |
hyperfine -m 100 --warmup 10 --export-markdown benchmark.md \
'java -jar nanopub.jar sign lib/tests/resources/simple1-rsa.trig -k lib/tests/resources/id_rsa' \
'np sign lib/tests/resources/simple1-rsa.trig -k lib/tests/resources/id_rsa' \
'target/release/nanopub-cli sign lib/tests/resources/simple1-rsa.trig -k lib/tests/resources/id_rsa'
- name: Upload benchmark markdown
uses: actions/upload-artifact@v4
with:
name: benchmark.md
path: ./benchmark.md