Skip to content

Commit

Permalink
chore: add CI jobs (#70)
Browse files Browse the repository at this point in the history
* chore: add CI jobs

Contributes to: #42

* chore: add editorconfig and pre-commit, fix all files

* chore: add license snip

* chore: license, code of conduct, contributing

* fix: ci working dir

* fix: remove cargo deny and add top level Cargo toml

* chore: add lint workflow

Signed-off-by: giac-mysten <[email protected]>

* fix: remove local test

Signed-off-by: giac-mysten <[email protected]>

* fix: temporarily remove job to check dependencies

Signed-off-by: giac-mysten <[email protected]>

* fix: re-add cargo deny and allowlist packages

Signed-off-by: giac-mysten <[email protected]>

---------

Signed-off-by: giac-mysten <[email protected]>
  • Loading branch information
giac-mysten authored Jun 18, 2024
1 parent 4bbed4d commit 5c3b7d5
Show file tree
Hide file tree
Showing 40 changed files with 8,113 additions and 103 deletions.
35 changes: 35 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 100
trim_trailing_whitespace = true

[*.md]
indent_size = unset
max_line_length = 150

[{*.yml,*.yaml,*.toml}]
indent_size = 2
max_line_length = 150

[crates/walrus-orchestrator/src/monitor.rs]
indent_size = unset

# Ignore paths
[{.git/**/*,**/*.lock,**/Move.toml,LICENSE,**/*.html,**/*.css,**/*.json}]
charset = unset
end_of_line = unset
indent_size = unset
indent_style = unset
insert_final_newline = unset
max_line_length = unset
trim_trailing_whitespace = unset
141 changes: 141 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Code

on:
# Run workflow on every PR.
pull_request:
# Run workflow on the main branch after every merge.
# This is important to fill the GitHub Actions cache in a way that PRs can see it.
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
CLICOLOR_FORCE: 1
# Incremental compilation is useful as part of an edit-build-test-edit cycle, as it lets the
# compiler avoid recompiling code that hasn't changed. The setting does not improve the current
# compilation but instead saves additional information to speed up future compilations (see
# https://doc.rust-lang.org/cargo/reference/profiles.html#incremental). Thus, this is only useful
# in CI if the result is cached, which we only do on the `main` branch.
CARGO_INCREMENTAL: ${{ github.ref == 'refs/heads/main' && '1' || '0' }}
# Allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). This should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
RUSTDOCFLAGS: -D warnings
SUI_TAG: testnet-v1.27.0

jobs:
diff:
runs-on: [ubuntu-ghcloud]
permissions:
contents: read
pull-requests: read
outputs:
isRust: ${{ steps.diff.outputs.isRust }}
isMove: ${{ steps.diff.outputs.isMove }}
relevantForE2eTests: ${{ steps.diff.outputs.relevantForE2eTests }}
steps:
- uses: actions/checkout@v4
- name: Detect Changes
uses: dorny/[email protected]
id: diff
with:
filters: |
isMove:
- 'move/**'
- '.github/workflows/code.yml'
isRust:
- 'site-builder/**'
- 'rust-toolchain.toml'
- '.github/workflows/code.yml'
dependencies:
name: Check dependencies
needs: diff
if: ${{ needs.diff.outputs.isRust == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/[email protected]
with:
# do not check advisories on PRs to prevent sudden failure due to new announcement
command: check bans licenses sources

lint:
name: Lint Rust code
needs: diff
if: ${{ needs.diff.outputs.isRust == 'true' }}
runs-on: ubuntu-ghcloud
steps:
- uses: actions/checkout@v4
- uses: Swatinem/[email protected]
with:
save-if: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }}
- run: >
cargo install cargo-sort --git https://github.com/DevinR528/cargo-sort
--rev 55ec89082466f6bb246d870a8d56d166a8e1f08b
- name: Check formatting with rustfmt
run: >
cargo fmt --all -- --check
--config group_imports=StdExternalCrate,imports_granularity=Crate,imports_layout=HorizontalVertical
- name: Check sorting of dependencies
run: cargo sort -w -c
- name: Lint using clippy (w/o tests)
run: cargo clippy --all-features --no-deps -- -D warnings
- name: Lint using clippy (w/ tests)
run: cargo clippy --all-features --tests --no-deps -- -D warnings
- name: Check documentation
run: cargo doc --no-deps --workspace

build:
name: Build Rust code
needs: diff
if: ${{ needs.diff.outputs.isRust == 'true' }}
runs-on: ubuntu-ghcloud
steps:
- uses: actions/checkout@v4
- uses: Swatinem/[email protected]
with:
save-if: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }}
- name: Build Rust code
run: cargo build --verbose

# TODO(mlegner): Currently running all tests on all PRs touching Rust code.
# If the running time gets too long, we may need to separate the integration and E2E tests.
test:
name: Test Rust code
needs: diff
if: ${{ needs.diff.outputs.isRust == 'true' }}
runs-on: ubuntu-ghcloud
steps:
- uses: actions/checkout@v4
- uses: Swatinem/[email protected]
with:
save-if: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }}
- name: Run tests
run: cargo test -- --include-ignored
check-all:
name: Check if all code checks succeeded
if: always()
needs:
- diff
- dependencies
- lint
- build
- test
runs-on: ubuntu-latest
steps:
- name: Decide whether all needed jobs succeeded
uses: re-actors/[email protected]
with:
allowed-skips: ${{ toJSON(needs) }}
jobs: ${{ toJSON(needs) }}
60 changes: 60 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Lint

on: [pull_request]

permissions:
contents: read

jobs:
pr-title:
runs-on: ubuntu-latest
name: Check PR title format
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check PR title
uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

editorconfig:
runs-on: ubuntu-latest
name: Check editorconfig
steps:
- uses: actions/checkout@v4
- run: pip install editorconfig-checker=="2.7.3"
- run: ec

typos:
runs-on: ubuntu-latest
name: Check spelling
steps:
- uses: actions/checkout@v4
- uses: crate-ci/[email protected]

license-headers:
runs-on: ubuntu-latest
name: Check license headers
steps:
- uses: actions/checkout@v4
- run: cargo install [email protected]
- run: licensesnip check

check-all:
name: Check if all lint jobs succeeded
if: always()
needs:
- pr-title
- editorconfig
- typos
- license-headers
runs-on: ubuntu-latest
steps:
- name: Decide whether all needed jobs succeeded
uses: re-actors/[email protected]
with:
jobs: ${{ toJSON(needs) }}
2 changes: 2 additions & 0 deletions .licensesnip
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Copyright (c) Mysten Labs, Inc.
SPDX-License-Identifier: Apache-2.0
81 changes: 81 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: check-yaml
- id: trailing-whitespace
- id: check-symlinks
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: "2.7.3"
hooks:
- id: editorconfig-checker
alias: ec
- repo: https://github.com/notken12/licensesnip
rev: 19b1186
hooks:
- id: licensesnip
args: []
pass_filenames: false
- repo: https://github.com/crate-ci/typos
rev: v1.22.7
hooks:
- id: typos
pass_filenames: false
- repo: https://github.com/EmbarkStudios/cargo-deny
rev: 0.14.24
hooks:
- id: cargo-deny
- repo: https://github.com/DevinR528/cargo-sort
rev: v1.0.9
hooks:
- id: cargo-sort
args: ["--workspace"]
- repo: local
hooks:
- id: cargo-fmt
name: cargo-fmt
entry: cargo fmt
args:
- "--"
- "--config"
- "group_imports=StdExternalCrate,imports_granularity=Crate,imports_layout=HorizontalVertical"
language: rust
types: [rust]
pass_filenames: false
- id: cargo-check
name: cargo-check
entry: cargo check
language: rust
files: ^(site-builder/|Cargo\.(toml|lock)$)
pass_filenames: false
- id: cargo-test
name: cargo-test
entry: cargo test
language: rust
files: ^(site-builder/|Cargo\.(toml|lock)$)
pass_filenames: false
- id: clippy-with-tests
name: clippy-with-tests
entry: cargo clippy
args: ["--all-features", "--tests", "--", "-D", "warnings"]
language: rust
files: ^(site-builder/|Cargo\.(toml|lock)$)
pass_filenames: false
- id: clippy
name: clippy
entry: cargo clippy
args: ["--all-features", "--", "-D", "warnings"]
language: rust
files: ^(site-builder/|Cargo\.(toml|lock)$)
pass_filenames: false
- id: cargo-doc
name: cargo-doc
entry: env RUSTDOCFLAGS="-D warnings" cargo doc
args: ["--workspace", "--no-deps"]
language: rust
files: ^(site-builder/|Cargo\.(toml|lock)$)
pass_filenames: false
28 changes: 28 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Walrus Code of Conduct

Walrus is a part of the Sui ecosystem and follows the same code of conduct.

As an open source project, we encourage free discussion rooted in respect.
We endeavor to always be mindful of others' perspectives and ask all
fellow contributors to do the same. We welcome you to the Sui platform
and ask you to help us grow it with relevant, on-point contributions.

## Our pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## More information

See the central [Sui Code of Conduct](https://docs.sui.io/code-of-conduct) for
full details.

Our Code of Conduct is adapted from the
[Contributor Covenant version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
Loading

0 comments on commit 5c3b7d5

Please sign in to comment.