Skip to content

Commit

Permalink
Add reproducible builds (#267)
Browse files Browse the repository at this point in the history
* ci: turn doc warnings into errors (#259)

* Added rust-toolchain.toml and added Cargo.lock

* Failed to add nightly

* added toolchain + cargo make

* changed ci to use cargo make on fmt

* Install cargo make in ci

* added clippy features to cargo-make + updated ci on clippy

* failed to save work

* Removed instrument workaround + pass clippy to stable

* Pin version to 1.75.0

* Change to 1.75 & remove matrix from ci

* Prevent ovveride of toolchain

* Rename file to rust-toolchain

* Remove comments

* Change to legacy format

* Remove version

* Added to contributing.md + updated ci and makefile

---------

Co-authored-by: Augusto Hack <hack.augusto@gmail.com>
  • Loading branch information
phklive and hackaugusto authored Mar 11, 2024
1 parent dfd75a2 commit 0eac45c
Show file tree
Hide file tree
Showing 16 changed files with 3,135 additions and 100 deletions.
89 changes: 29 additions & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,97 +8,66 @@ on:

jobs:
rustfmt:
name: rustfmt ${{matrix.toolchain}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
toolchain: [nightly]
os: [ubuntu]
name: rustfmt 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}}
toolchain: nightly
components: rustfmt
override: true
- name: fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Install cargo make
run: cargo install cargo-make
- name: cargo make - format
run: cargo make format

clippy:
name: clippy ${{matrix.toolchain}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
toolchain: [nightly]
os: [ubuntu]
name: clippy stable on ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install minimal Rust with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{matrix.toolchain}}
components: clippy
override: true
- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets -- -D clippy::all -D warnings
- name: Clippy all features
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets --all-features -- -D clippy::all -D warnings
- name: Install cargo make
run: cargo install cargo-make
- name: cargo make - clippy
run: cargo make clippy

docs:
name: docs ${{matrix.toolchain}} on ${{matrix.os}} with ${{matrix.args}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable]
os: [ubuntu]
args: [--all-features --release]
doc:
name: doc stable on ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{matrix.toolchain}}
profile: minimal
override: true
- name: Doc
uses: actions-rs/cargo@v1
with:
command: doc
args: ${{matrix.args}}
- name: Install cargo make
run: cargo install cargo-make
- name: cargo make - format
run: cargo make doc

test:
name: test ${{matrix.toolchain}} on ${{matrix.os}} with ${{matrix.args}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable]
os: [ubuntu]
args: [--all-features --workspace]
name: test stable on ubuntu-latest
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{matrix.toolchain}}
profile: minimal
override: true
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: ${{matrix.args}} -- --nocapture
- name: Install cargo make
run: cargo install cargo-make
- name: cargo make - format
run: cargo make test

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
14 changes: 8 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ We want to make contributing to this project as easy and transparent as possible
We are using [Github Flow](https://docs.github.com/en/get-started/quickstart/github-flow), so all code changes happen through pull requests from a [forked repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo).

### Branching
- The current active branch is `main`. Every branch with a fix/feature must be forked from `main`.
- The current active branch is `next`. Every branch with a fix/feature must be forked from `next`.

- The branch name should contain a short issue/feature description separated with hyphens [(kebab-case)](https://en.wikipedia.org/wiki/Letter_case#Kebab_case).

For example, if the issue title is `Fix functionality X in component Y` then the branch name will be something like: `fix-x-in-y`.

- New branch should be rebased from `main` before submitting a PR in case there have been changes to avoid merge commits.
- New branch should be rebased from `next` before submitting a PR in case there have been changes to avoid merge commits.
i.e. this branches state:
```
A---B---C fix-x-in-y
/
D---E---F---G main
D---E---F---G next
| |
(F, G) changes happened after `fix-x-in-y` forked
```
Expand All @@ -37,7 +37,7 @@ i.e. this branches state:
```
A'--B'--C' fix-x-in-y
/
D---E---F---G main
D---E---F---G next
```


Expand Down Expand Up @@ -72,12 +72,14 @@ For example, a new change to the `miden-node-store` crate might have the followi
// ================================================================================
```
- [Rustfmt](https://github.com/rust-lang/rustfmt), [Clippy](https://github.com/rust-lang/rust-clippy) and [Rustdoc](https://doc.rust-lang.org/rustdoc/index.html) linting is included in CI pipeline. Anyways it's preferable to run linting locally before push. Note that we use some `nightly` Rust features for Rustfmt and Clippy.
- [Rustfmt](https://github.com/rust-lang/rustfmt), [Clippy](https://github.com/rust-lang/rust-clippy) and [Rustdoc](https://doc.rust-lang.org/rustdoc/index.html) linting is included in CI pipeline. Anyways it's preferable to run linting locally before push. To simplify running these commands in a reproducible manner we use [cargo-make](https://github.com/sagiegurari/cargo-make), you can run:
```
cargo +nightly fmt --all && cargo +nightly clippy --workspace --all-targets -- -D clippy::all -D warnings && cargo test --all-features --workspace && cargo doc --all-features
cargo make lint
```
You can find more information about the `cargo make` commands in the [Makefile](Makefile.toml)
### Versioning
We use [semver](https://semver.org/) naming convention.
Expand Down
Loading

0 comments on commit 0eac45c

Please sign in to comment.