Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Mar 1, 2024
0 parents commit d931838
Show file tree
Hide file tree
Showing 17 changed files with 904 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/deny.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Runs `cargo-deny` when modifying `Cargo.lock`.

name: deny

on:
push:
branches: [main]
paths: [Cargo.lock]
pull_request:
branches: [main]
paths: [Cargo.lock]
merge_group:

env:
CARGO_TERM_COLOR: always

concurrency: deny-${{ github.head_ref || github.run_id }}

jobs:
deny:
name: deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check all
61 changes: 61 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Runs `cargo update` periodically.

name: Update Dependencies

on:
schedule:
# Run weekly
- cron: "0 0 * * SUN"
workflow_dispatch:
# Needed so we can run it manually

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: cargo-update
TITLE: "chore(deps): weekly `cargo update`"
BODY: |
Automation to keep dependencies in `Cargo.lock` current.
<details><summary><strong>cargo update log</strong></summary>
<p>
```log
$cargo_update_log
```
</p>
</details>
jobs:
update:
name: Update
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly

- name: cargo update
# Remove first line that always just says "Updating crates.io index"
run: cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log

- name: craft commit message and PR body
id: msg
run: |
export cargo_update_log="$(cat cargo_update.log)"
echo "commit_message<<EOF" >> $GITHUB_OUTPUT
printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$BODY" | envsubst >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
add-paths: ./Cargo.lock
commit-message: ${{ steps.msg.outputs.commit_message }}
title: ${{ env.TITLE }}
body: ${{ steps.msg.outputs.body }}
branch: ${{ env.BRANCH }}
51 changes: 51 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Runs integration tests.

name: integration

on:
pull_request:
merge_group:
push:
branches: [main]

env:
CARGO_TERM_COLOR: always

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
name: test / (${{ matrix.partition }}/2)
runs-on:
group: Alphanet
env:
RUST_BACKTRACE: 1
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Run tests
run: |
cargo nextest run \
--locked \
--workspace \
--partition hash:${{ matrix.partition }}/2 \
-E 'kind(test)'
integration-success:
name: integration success
runs-on: ubuntu-latest
if: always()
needs: [test]
timeout-minutes: 30
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
109 changes: 109 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: lint

on:
pull_request:
merge_group:
push:
branches: [main]

env:
CARGO_TERM_COLOR: always

jobs:
clippy-binaries:
name: clippy / ${{ matrix.network }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run:
cargo clippy --bin alphanet --workspace --features "asm-keccak jemalloc jemalloc-prof min-error-logs min-warn-logs min-info-logs min-debug-logs min-trace-logs"
env:
RUSTFLAGS: -D warnings

clippy:
name: clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo clippy --workspace --lib --examples --tests --benches --all-features
env:
RUSTFLAGS: -D warnings

crate-checks:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo hack check

msrv:
name: MSRV / ${{ matrix.network }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.75" # MSRV
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo build --bin alphanet --workspace
env:
RUSTFLAGS: -D warnings

docs:
name: docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo docs --document-private-items
env:
# Keep in sync with ./book.yml:jobs.build
# This should only add `-D warnings`
RUSTDOCFLAGS:
--cfg docsrs --show-type-layout --generate-link-to-definition --enable-index-page
-Zunstable-options -D warnings

fmt:
name: fmt
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all --check

lint-success:
name: lint success
runs-on: ubuntu-latest
if: always()
needs: [clippy-binaries, clippy, crate-checks, docs, fmt]
timeout-minutes: 30
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
67 changes: 67 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Runs unit tests.

name: unit

on:
pull_request:
merge_group:
push:
branches: [main]

env:
CARGO_TERM_COLOR: always

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
name: test / ${{ matrix.network }} (${{ matrix.partition }}/2)
runs-on:
group: Alphanet
env:
RUST_BACKTRACE: 1
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- uses: taiki-e/install-action@nextest
- name: Run tests
run: |
cargo nextest run \
--locked \
--workspace \
--partition hash:${{ matrix.partition }}/2 \
-E "kind(lib) | kind(bin) | kind(proc-macro)"
doc:
name: doc tests (${{ matrix.network }})
runs-on:
group: Alphanet
env:
RUST_BACKTRACE: 1
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Run doctests
run: cargo test --doc --workspace

unit-success:
name: unit success
runs-on: ubuntu-latest
if: always()
needs: [test, state, doc]
timeout-minutes: 30
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Generated by Intellij-based IDEs.
.idea

# Generated by MacOS
.DS_Store

# Proptest data
proptest-regressions/

# Release artifacts
dist/

# VSCode
.vscode

# Coverage report
lcov.info

# Rust bug report
rustc-ice-*
Loading

0 comments on commit d931838

Please sign in to comment.