From 374a10f3400d5953888d846459f350c17275e33e Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Fri, 16 Aug 2024 15:32:03 -0700 Subject: [PATCH] Updated ci + added scripts --- .github/workflows/build.yml | 25 +++++++++++ .github/workflows/changelog.yml | 23 ++++++++++ .github/workflows/doc.yml | 31 ------------- .github/workflows/lint.yml | 79 ++++++++++++++------------------- .github/workflows/no-std.yml | 32 ------------- .github/workflows/test.yml | 26 +++++------ README.md | 5 ++- scripts/check-changelog.sh | 21 +++++++++ 8 files changed, 115 insertions(+), 127 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/changelog.yml delete mode 100644 .github/workflows/doc.yml delete mode 100644 .github/workflows/no-std.yml create mode 100755 scripts/check-changelog.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e757b42 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..c890c4c --- /dev/null +++ b/.github/workflows/changelog.yml @@ -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 diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml deleted file mode 100644 index a192a01..0000000 --- a/.github/workflows/doc.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 97c32fd..b06425c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,63 +4,50 @@ name: lint on: push: - branches: - - main + branches: [main, next] pull_request: types: [opened, reopened, synchronize] jobs: - version: - name: check rust version consistency + clippy: + name: clippy nightly on ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - profile: minimal - override: true - - name: check rust versions - run: ./scripts/check-rust-version.sh + - uses: actions/checkout@main + - name: Clippy + run: | + rustup update --no-self-update nightly + rustup +nightly component add clippy + make clippy rustfmt: - name: rustfmt ${{matrix.toolchain}} on ${{matrix.os}} - runs-on: ${{matrix.os}}-latest - strategy: - fail-fast: false - matrix: - toolchain: [nightly] - os: [ubuntu] + name: rustfmt check nightly on ubuntu-latest + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Install minimal Rust with rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{matrix.toolchain}} - components: rustfmt - override: true - - uses: davidB/rust-cargo-make@v1 - - name: cargo make - format-check - run: cargo make format-check + - uses: actions/checkout@main + - name: Rustfmt + run: | + rustup update --no-self-update nightly + rustup +nightly component add rustfmt + make format-check - clippy: - name: clippy ${{matrix.toolchain}} on ${{matrix.os}} - runs-on: ${{matrix.os}}-latest - strategy: - fail-fast: false - matrix: - toolchain: [stable] - os: [ubuntu] + doc: + name: doc stable on ubuntu-latest + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Install minimal Rust with clippy - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@main + - name: Build docs + run: | + rustup update --no-self-update + make doc + + version: + name: check rust version consistency + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main with: profile: minimal - toolchain: ${{matrix.toolchain}} - components: clippy override: true - - uses: davidB/rust-cargo-make@v1 - - name: cargo make - clippy - run: cargo make clippy + - name: check rust versions + run: ./scripts/check-rust-version.sh diff --git a/.github/workflows/no-std.yml b/.github/workflows/no-std.yml deleted file mode 100644 index 7a243d6..0000000 --- a/.github/workflows/no-std.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fb6252..490a13e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,34 +1,28 @@ -# Runs testing related jobs +# Runs test related jobs. name: test on: push: - branches: - - main + branches: [main, next] pull_request: types: [opened, reopened, synchronize] jobs: 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 strategy: fail-fast: false matrix: toolchain: [stable, nightly] os: [ubuntu] - features: ["test", "test-no-default-features"] + args: [default, no-default] timeout-minutes: 30 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}} diff --git a/README.md b/README.md index 8982aed..80ce4d2 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,9 @@ [![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/0xPolygonMiden/crypto/blob/main/LICENSE) [![test](https://github.com/0xPolygonMiden/crypto/actions/workflows/test.yml/badge.svg)](https://github.com/0xPolygonMiden/crypto/actions/workflows/test.yml) -[![no-std](https://github.com/0xPolygonMiden/crypto/actions/workflows/no-std.yml/badge.svg)](https://github.com/0xPolygonMiden/crypto/actions/workflows/no-std.yml) -[![RUST_VERSION](https://img.shields.io/badge/rustc-1.80+-lightgray.svg)]() +[![build](https://github.com/0xPolygonMiden/crypto/actions/workflows/build.yml/badge.svg)](https://github.com/0xPolygonMiden/crypto/actions/workflows/build.yml) +[![RUST_VERSION](https://img.shields.io/badge/rustc-1.80+-lightgray.svg)](https://www.rust-lang.org/tools/install) +[![GitHub Release](https://img.shields.io/github/release/0xPolygonMiden/miden-crypto)](https://github.com/0xPolygonMiden/miden-crypto/releases/) [![CRATE](https://img.shields.io/crates/v/miden-crypto)](https://crates.io/crates/miden-crypto) This crate contains cryptographic primitives used in Polygon Miden. diff --git a/scripts/check-changelog.sh b/scripts/check-changelog.sh new file mode 100755 index 0000000..dbf14cd --- /dev/null +++ b/scripts/check-changelog.sh @@ -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