Update `Makefile` and `CI`al-update-winterfell
@ -0,0 +1,3 @@ |
|||||
|
[profile.default] |
||||
|
failure-output = "immediate-final" |
||||
|
fail-fast = false |
@ -0,0 +1,25 @@ |
|||||
|
# Runs build related jobs. |
||||
|
|
||||
|
name: build |
||||
|
|
||||
|
on: |
||||
|
push: |
||||
|
branches: [main, next] |
||||
|
pull_request: |
||||
|
types: [opened, reopened, synchronize] |
||||
|
|
||||
|
jobs: |
||||
|
no-std: |
||||
|
name: Build for no-std |
||||
|
runs-on: ubuntu-latest |
||||
|
strategy: |
||||
|
fail-fast: false |
||||
|
matrix: |
||||
|
toolchain: [stable, nightly] |
||||
|
steps: |
||||
|
- uses: actions/checkout@main |
||||
|
- name: Build for no-std |
||||
|
run: | |
||||
|
rustup update --no-self-update ${{ matrix.toolchain }} |
||||
|
rustup target add wasm32-unknown-unknown |
||||
|
make build-no-std |
@ -0,0 +1,23 @@ |
|||||
|
# Runs changelog related jobs. |
||||
|
# CI job heavily inspired by: https://github.com/tarides/changelog-check-action |
||||
|
|
||||
|
name: changelog |
||||
|
|
||||
|
on: |
||||
|
pull_request: |
||||
|
types: [opened, reopened, synchronize, labeled, unlabeled] |
||||
|
|
||||
|
jobs: |
||||
|
changelog: |
||||
|
runs-on: ubuntu-latest |
||||
|
steps: |
||||
|
- name: Checkout code |
||||
|
uses: actions/checkout@main |
||||
|
with: |
||||
|
fetch-depth: 0 |
||||
|
- name: Check for changes in changelog |
||||
|
env: |
||||
|
BASE_REF: ${{ github.event.pull_request.base.ref }} |
||||
|
NO_CHANGELOG_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'no changelog') }} |
||||
|
run: ./scripts/check-changelog.sh "${{ inputs.changelog }}" |
||||
|
shell: bash |
@ -1,31 +0,0 @@ |
|||||
# Runs documentation related jobs. |
|
||||
|
|
||||
name: doc |
|
||||
|
|
||||
on: |
|
||||
push: |
|
||||
branches: |
|
||||
- main |
|
||||
pull_request: |
|
||||
types: [opened, reopened, synchronize] |
|
||||
|
|
||||
jobs: |
|
||||
docs: |
|
||||
name: Verify the docs on ${{matrix.toolchain}} |
|
||||
runs-on: ubuntu-latest |
|
||||
strategy: |
|
||||
fail-fast: false |
|
||||
matrix: |
|
||||
toolchain: [stable] |
|
||||
steps: |
|
||||
- uses: actions/checkout@v4 |
|
||||
with: |
|
||||
submodules: recursive |
|
||||
- name: Install rust |
|
||||
uses: actions-rs/toolchain@v1 |
|
||||
with: |
|
||||
toolchain: ${{matrix.toolchain}} |
|
||||
override: true |
|
||||
- uses: davidB/rust-cargo-make@v1 |
|
||||
- name: cargo make - doc |
|
||||
run: cargo make doc |
|
@ -1,32 +0,0 @@ |
|||||
# Runs no-std related jobs. |
|
||||
|
|
||||
name: no-std |
|
||||
|
|
||||
on: |
|
||||
push: |
|
||||
branches: |
|
||||
- main |
|
||||
pull_request: |
|
||||
types: [opened, reopened, synchronize] |
|
||||
|
|
||||
jobs: |
|
||||
no-std: |
|
||||
name: build ${{matrix.toolchain}} no-std for wasm32-unknown-unknown |
|
||||
runs-on: ubuntu-latest |
|
||||
strategy: |
|
||||
fail-fast: false |
|
||||
matrix: |
|
||||
toolchain: [stable, nightly] |
|
||||
steps: |
|
||||
- uses: actions/checkout@v4 |
|
||||
with: |
|
||||
submodules: recursive |
|
||||
- name: Install rust |
|
||||
uses: actions-rs/toolchain@v1 |
|
||||
with: |
|
||||
toolchain: ${{matrix.toolchain}} |
|
||||
override: true |
|
||||
- run: rustup target add wasm32-unknown-unknown |
|
||||
- uses: davidB/rust-cargo-make@v1 |
|
||||
- name: cargo make - build-no-std |
|
||||
run: cargo make build-no-std |
|
@ -1,34 +1,28 @@ |
|||||
# Runs testing related jobs |
|
||||
|
# Runs test related jobs. |
||||
|
|
||||
name: test |
name: test |
||||
|
|
||||
on: |
on: |
||||
push: |
push: |
||||
branches: |
|
||||
- main |
|
||||
|
branches: [main, next] |
||||
pull_request: |
pull_request: |
||||
types: [opened, reopened, synchronize] |
types: [opened, reopened, synchronize] |
||||
|
|
||||
jobs: |
jobs: |
||||
test: |
test: |
||||
name: test ${{matrix.toolchain}} on ${{matrix.os}} with ${{matrix.features}} |
|
||||
|
name: test ${{matrix.toolchain}} on ${{matrix.os}} with ${{matrix.args}} |
||||
runs-on: ${{matrix.os}}-latest |
runs-on: ${{matrix.os}}-latest |
||||
strategy: |
strategy: |
||||
fail-fast: false |
fail-fast: false |
||||
matrix: |
matrix: |
||||
toolchain: [stable, nightly] |
toolchain: [stable, nightly] |
||||
os: [ubuntu] |
os: [ubuntu] |
||||
features: ["test", "test-no-default-features"] |
|
||||
|
args: [default, no-std] |
||||
timeout-minutes: 30 |
timeout-minutes: 30 |
||||
steps: |
steps: |
||||
- uses: actions/checkout@v4 |
|
||||
with: |
|
||||
submodules: recursive |
|
||||
- name: Install rust |
|
||||
uses: actions-rs/toolchain@v1 |
|
||||
with: |
|
||||
toolchain: ${{matrix.toolchain}} |
|
||||
override: true |
|
||||
- uses: davidB/rust-cargo-make@v1 |
|
||||
- name: cargo make - test |
|
||||
run: cargo make ${{matrix.features}} |
|
||||
|
- uses: actions/checkout@main |
||||
|
- uses: taiki-e/install-action@nextest |
||||
|
- name: Perform tests |
||||
|
run: | |
||||
|
rustup update --no-self-update ${{matrix.toolchain}} |
||||
|
make test-${{matrix.args}} |
@ -1,43 +1,34 @@ |
|||||
# See https://pre-commit.com for more information |
# See https://pre-commit.com for more information |
||||
# See https://pre-commit.com/hooks.html for more hooks |
# See https://pre-commit.com/hooks.html for more hooks |
||||
repos: |
repos: |
||||
- repo: https://github.com/pre-commit/pre-commit-hooks |
|
||||
rev: v3.2.0 |
|
||||
hooks: |
|
||||
- id: trailing-whitespace |
|
||||
- id: end-of-file-fixer |
|
||||
- id: check-yaml |
|
||||
- id: check-json |
|
||||
- id: check-toml |
|
||||
- id: pretty-format-json |
|
||||
- id: check-added-large-files |
|
||||
- id: check-case-conflict |
|
||||
- id: check-executables-have-shebangs |
|
||||
- id: check-merge-conflict |
|
||||
- id: detect-private-key |
|
||||
- repo: https://github.com/hackaugusto/pre-commit-cargo |
|
||||
rev: v1.0.0 |
|
||||
hooks: |
|
||||
# Allows cargo fmt to modify the source code prior to the commit |
|
||||
- id: cargo |
|
||||
name: Cargo fmt |
|
||||
args: ["+stable", "fmt", "--all"] |
|
||||
stages: [commit] |
|
||||
# Requires code to be properly formatted prior to pushing upstream |
|
||||
- id: cargo |
|
||||
name: Cargo fmt --check |
|
||||
args: ["+stable", "fmt", "--all", "--check"] |
|
||||
stages: [push, manual] |
|
||||
- id: cargo |
|
||||
name: Cargo check --all-targets |
|
||||
args: ["+stable", "check", "--all-targets"] |
|
||||
- id: cargo |
|
||||
name: Cargo check --all-targets --no-default-features |
|
||||
args: ["+stable", "check", "--all-targets", "--no-default-features"] |
|
||||
- id: cargo |
|
||||
name: Cargo check --all-targets --features default,std,serde |
|
||||
args: ["+stable", "check", "--all-targets", "--features", "default,std,serde"] |
|
||||
# Unlike fmt, clippy will not be automatically applied |
|
||||
- id: cargo |
|
||||
name: Cargo clippy |
|
||||
args: ["+nightly", "clippy", "--workspace", "--", "--deny", "clippy::all", "--deny", "warnings"] |
|
||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks |
||||
|
rev: v4.6.0 |
||||
|
hooks: |
||||
|
- id: trailing-whitespace |
||||
|
- id: end-of-file-fixer |
||||
|
- id: check-yaml |
||||
|
- id: check-json |
||||
|
- id: check-toml |
||||
|
- id: pretty-format-json |
||||
|
- id: check-added-large-files |
||||
|
- id: check-case-conflict |
||||
|
- id: check-executables-have-shebangs |
||||
|
- id: check-merge-conflict |
||||
|
- id: detect-private-key |
||||
|
- repo: local |
||||
|
hooks: |
||||
|
- id: lint |
||||
|
name: Make lint |
||||
|
stages: [commit] |
||||
|
language: rust |
||||
|
entry: make lint |
||||
|
- id: doc |
||||
|
name: Make doc |
||||
|
stages: [commit] |
||||
|
language: rust |
||||
|
entry: make doc |
||||
|
- id: check |
||||
|
name: Make check |
||||
|
stages: [commit] |
||||
|
language: rust |
||||
|
entry: make check |
@ -0,0 +1,86 @@ |
|||||
|
.DEFAULT_GOAL := help |
||||
|
|
||||
|
.PHONY: help |
||||
|
help: |
||||
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
||||
|
|
||||
|
# -- variables --------------------------------------------------------------------------------------
|
||||
|
|
||||
|
WARNINGS=RUSTDOCFLAGS="-D warnings" |
||||
|
DEBUG_OVERFLOW_INFO=RUSTFLAGS="-C debug-assertions -C overflow-checks -C debuginfo=2" |
||||
|
|
||||
|
# -- linting --------------------------------------------------------------------------------------
|
||||
|
|
||||
|
.PHONY: clippy |
||||
|
clippy: ## Run Clippy with configs
|
||||
|
$(WARNINGS) cargo +nightly clippy --workspace --all-targets --all-features |
||||
|
|
||||
|
|
||||
|
.PHONY: fix |
||||
|
fix: ## Run Fix with configs
|
||||
|
cargo +nightly fix --allow-staged --allow-dirty --all-targets --all-features |
||||
|
|
||||
|
|
||||
|
.PHONY: format |
||||
|
format: ## Run Format using nightly toolchain
|
||||
|
cargo +nightly fmt --all |
||||
|
|
||||
|
|
||||
|
.PHONY: format-check |
||||
|
format-check: ## Run Format using nightly toolchain but only in check mode
|
||||
|
cargo +nightly fmt --all --check |
||||
|
|
||||
|
|
||||
|
.PHONY: lint |
||||
|
lint: format fix clippy ## Run all linting tasks at once (Clippy, fixing, formatting)
|
||||
|
|
||||
|
# --- docs ----------------------------------------------------------------------------------------
|
||||
|
|
||||
|
.PHONY: doc |
||||
|
doc: ## Generate and check documentation
|
||||
|
$(WARNINGS) cargo doc --all-features --keep-going --release |
||||
|
|
||||
|
# --- testing -------------------------------------------------------------------------------------
|
||||
|
|
||||
|
.PHONY: test-default |
||||
|
test-default: ## Run tests with default features
|
||||
|
$(DEBUG_OVERFLOW_INFO) cargo nextest run --profile default --release --all-features |
||||
|
|
||||
|
|
||||
|
.PHONY: test-no-std |
||||
|
test-no-std: ## Run tests with `no-default-features` (std)
|
||||
|
$(DEBUG_OVERFLOW_INFO) cargo nextest run --profile default --release --no-default-features |
||||
|
|
||||
|
|
||||
|
.PHONY: test |
||||
|
test: test-default test-no-std ## Run all tests
|
||||
|
|
||||
|
# --- checking ------------------------------------------------------------------------------------
|
||||
|
|
||||
|
.PHONY: check |
||||
|
check: ## Check all targets and features for errors without code generation
|
||||
|
cargo check --all-targets --all-features |
||||
|
|
||||
|
# --- building ------------------------------------------------------------------------------------
|
||||
|
|
||||
|
.PHONY: build |
||||
|
build: ## Build with default features enabled
|
||||
|
cargo build --release |
||||
|
|
||||
|
.PHONY: build-no-std |
||||
|
build-no-std: ## Build without the standard library
|
||||
|
cargo build --release --no-default-features --target wasm32-unknown-unknown |
||||
|
|
||||
|
.PHONY: build-avx2 |
||||
|
build-avx2: ## Build with avx2 support
|
||||
|
RUSTFLAGS="-C target-feature=+avx2" cargo build --release |
||||
|
|
||||
|
.PHONY: build-sve |
||||
|
build-sve: ## Build with sve support
|
||||
|
RUSTFLAGS="-C target-feature=+sve" cargo build --release |
||||
|
|
||||
|
# --- benchmarking --------------------------------------------------------------------------------
|
||||
|
|
||||
|
.PHONY: bench-tx |
||||
|
bench-tx: ## Run crypto benchmarks
|
||||
|
cargo bench |
@ -1,86 +0,0 @@ |
|||||
# Cargo Makefile
|
|
||||
|
|
||||
# -- linting --------------------------------------------------------------------------------------
|
|
||||
[tasks.format] |
|
||||
toolchain = "nightly" |
|
||||
command = "cargo" |
|
||||
args = ["fmt", "--all"] |
|
||||
|
|
||||
[tasks.format-check] |
|
||||
toolchain = "nightly" |
|
||||
command = "cargo" |
|
||||
args = ["fmt", "--all", "--", "--check"] |
|
||||
|
|
||||
[tasks.clippy-default] |
|
||||
command = "cargo" |
|
||||
args = ["clippy","--workspace", "--all-targets", "--", "-D", "clippy::all", "-D", "warnings"] |
|
||||
|
|
||||
[tasks.clippy-all-features] |
|
||||
command = "cargo" |
|
||||
args = ["clippy","--workspace", "--all-targets", "--all-features", "--", "-D", "clippy::all", "-D", "warnings"] |
|
||||
|
|
||||
[tasks.clippy] |
|
||||
dependencies = [ |
|
||||
"clippy-default", |
|
||||
"clippy-all-features" |
|
||||
] |
|
||||
|
|
||||
[tasks.fix] |
|
||||
description = "Runs Fix" |
|
||||
command = "cargo" |
|
||||
toolchain = "nightly" |
|
||||
args = ["fix", "--allow-staged", "--allow-dirty", "--all-targets", "--all-features"] |
|
||||
|
|
||||
[tasks.lint] |
|
||||
description = "Runs all linting tasks (Clippy, fixing, formatting)" |
|
||||
run_task = { name = ["format", "format-check", "clippy", "docs"] } |
|
||||
|
|
||||
# --- docs ----------------------------------------------------------------------------------------
|
|
||||
[tasks.doc] |
|
||||
env = { "RUSTDOCFLAGS" = "-D warnings" } |
|
||||
command = "cargo" |
|
||||
args = ["doc", "--all-features", "--keep-going", "--release"] |
|
||||
|
|
||||
# --- testing -------------------------------------------------------------------------------------
|
|
||||
[tasks.test] |
|
||||
description = "Run tests with default features" |
|
||||
env = { "RUSTFLAGS" = "-C debug-assertions -C overflow-checks -C debuginfo=2" } |
|
||||
workspace = false |
|
||||
command = "cargo" |
|
||||
args = ["test", "--release"] |
|
||||
|
|
||||
[tasks.test-no-default-features] |
|
||||
description = "Run tests with no-default-features" |
|
||||
env = { "RUSTFLAGS" = "-C debug-assertions -C overflow-checks -C debuginfo=2" } |
|
||||
workspace = false |
|
||||
command = "cargo" |
|
||||
args = ["test", "--release", "--no-default-features"] |
|
||||
|
|
||||
[tasks.test-all] |
|
||||
description = "Run all tests" |
|
||||
workspace = false |
|
||||
run_task = { name = ["test", "test-no-default-features"], parallel = true } |
|
||||
|
|
||||
# --- building ------------------------------------------------------------------------------------
|
|
||||
[tasks.build] |
|
||||
description = "Build in release mode" |
|
||||
command = "cargo" |
|
||||
args = ["build", "--release"] |
|
||||
|
|
||||
[tasks.build-no-std] |
|
||||
description = "Build using no-std" |
|
||||
command = "cargo" |
|
||||
args = ["build", "--release", "--no-default-features", "--target", "wasm32-unknown-unknown"] |
|
||||
|
|
||||
[tasks.build-avx2] |
|
||||
description = "Build using AVX2 acceleration" |
|
||||
env = { "RUSTFLAGS" = "-C target-feature=+avx2" } |
|
||||
command = "cargo" |
|
||||
args = ["build", "--release"] |
|
||||
|
|
||||
[tasks.build-sve] |
|
||||
description = "Build with SVE acceleration" |
|
||||
env = { "RUSTFLAGS" = "-C target-feature=+sve" } |
|
||||
command = "cargo" |
|
||||
args = ["build", "--release"] |
|
||||
|
|
@ -1 +0,0 @@ |
|||||
1.80 |
|
@ -0,0 +1,5 @@ |
|||||
|
[toolchain] |
||||
|
channel = "1.80" |
||||
|
components = ["rustfmt", "rust-src", "clippy"] |
||||
|
targets = ["wasm32-unknown-unknown"] |
||||
|
profile = "minimal" |
@ -0,0 +1,21 @@ |
|||||
|
#!/bin/bash |
||||
|
set -uo pipefail |
||||
|
|
||||
|
CHANGELOG_FILE="${1:-CHANGELOG.md}" |
||||
|
|
||||
|
if [ "${NO_CHANGELOG_LABEL}" = "true" ]; then |
||||
|
# 'no changelog' set, so finish successfully |
||||
|
echo "\"no changelog\" label has been set" |
||||
|
exit 0 |
||||
|
else |
||||
|
# a changelog check is required |
||||
|
# fail if the diff is empty |
||||
|
if git diff --exit-code "origin/${BASE_REF}" -- "${CHANGELOG_FILE}"; then |
||||
|
>&2 echo "Changes should come with an entry in the \"CHANGELOG.md\" file. This behavior |
||||
|
can be overridden by using the \"no changelog\" label, which is used for changes |
||||
|
that are trivial / explicitely stated not to require a changelog entry." |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo "The \"CHANGELOG.md\" file has been updated." |
||||
|
fi |