Skip to content

Commit

Permalink
basic CI setup (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Aug 14, 2024
1 parent a0cf302 commit f86548d
Show file tree
Hide file tree
Showing 19 changed files with 427 additions and 12 deletions.
13 changes: 13 additions & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Keys and default values are documented here:
# https://github.com/rustsec/rustsec/blob/main/cargo-audit/audit.toml.example

[advisories]
# These should all have either:
# - tracking issues with the "security" label
# - reasons why they're ignored
ignore = []

[output]
deny = ["unmaintained"]
format = "terminal"
quiet = false
20 changes: 20 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[disallowed-types]]
path = "std::collections::HashMap"
reason = """the standard library hasher is secure by default, but not very fast.
use ahash::HashMap instead."""

[[disallowed-types]]
path = "std::collections::HashSet"
reason = """the standard library hasher is secure by default, but not very fast.
use ahash::HashSet instead."""

# Banned in #2600, presumably so that poisoning won't need to be user-handled
[[disallowed-types]]
path = "std::sync::RwLock"
reason = """the standard library synchronization primitives are poisoned when aquiring threads panic.
use parking_lot::RwLock instead to silently ignore panics."""

[[disallowed-types]]
path = "std::sync::Mutex"
reason = """the standard library synchronization primitives are poisoned when aquiring threads panic.
use parking_lot::Mutex instead to silently ignore panics."""
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Two members of the Forest team are automatically (and randomly) assigned to review all PRs.
* @ChainSafe/Forest
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "cargo"
directory: "/" # Location of package manifests
open-pull-requests-limit: 1
schedule:
interval: "weekly"
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#groups
groups:
patch-versions:
update-types:
- "patch"
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot#enabling-dependabot-version-updates-for-actions
- package-ecosystem: "github-actions"
directory: "/"
open-pull-requests-limit: 1
schedule:
interval: "weekly"
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI for rust-f3
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: "${{ github.ref != 'refs/heads/main' }}"
"on":
workflow_dispatch:
merge_group:
pull_request:
branches:
- main
push:
branches:
- main
schedule:
- cron: 0 0 * * *
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: sccache
CC: sccache clang
CXX: sccache clang++
jobs:
test:
name: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.5
timeout-minutes: 5
continue-on-error: true
- name: Build
run: make check
- name: Test
run: make test

lint:
name: All lint checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.5
timeout-minutes: 5
continue-on-error: true
- name: Install Lint tools
run: make install-lint-tools-ci
env:
RUSTFLAGS: "-Cstrip=symbols"
- name: Lint
run: make lint-all

dependencies-check:
name: Check cargo dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
- name: Run dependencies checks
run: |
gem install toml-rb --no-document
ruby scripts/linters/find_unused_deps.rb
codedov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@cargo-llvm-cov
- run: cargo llvm-cov --all-features --lcov --output-path lcov.info
env:
RUSTC_WRAPPER:
- uses: actions/upload-artifact@v4
with:
name: lcov.info
path: lcov.info
if-no-files-found: error
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: false # Rate limit reached. Please upload with the Codecov repository upload token to resolve issue.
with:
# token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true
97 changes: 91 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Created by https://www.toptal.com/developers/gitignore/api/rust,go,osx,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,go,osx,visualstudiocode
# Created by https://www.toptal.com/developers/gitignore/api/rust,go,osx,visualstudiocode,intellij+all
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,go,osx,visualstudiocode,intellij+all

### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
Expand All @@ -24,6 +24,94 @@
# Go workspace file
go.work

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### OSX ###
# General
.DS_Store
Expand Down Expand Up @@ -83,12 +171,9 @@ Cargo.lock
# Built Visual Studio Code Extensions
*.vsix

### IntelliJ IDE
.idea/

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/rust,go,osx,visualstudiocode
# End of https://www.toptal.com/developers/gitignore/api/rust,go,osx,visualstudiocode,intellij+all
13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[workspace]
resolver = "2"
members = ["blssig", "gpbft"]

members = [
"blssig",
"gpbft"
]
[workspace.package]
authors = ["ChainSafe Systems <forest@chainsafe.io>"]
repository = "https://github.com/ChainSafe/rust-f3"
license = "MIT OR Apache-2.0"
edition = "2021"

[workspace.dependencies]
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
check:
cargo check

test:
cargo test

doc:
cargo doc
cp ./build/vendored-docs-redirect.index.html target/doc/index.html

bench:
cargo bench

# Lints with everything we have in our CI arsenal
lint-all: audit lint-fmt clippy license spellcheck

audit:
cargo audit || (echo "See .config/audit.toml"; false)

lint-fmt:
cargo fmt --all --check
taplo fmt --check
taplo lint

fmt:
cargo fmt --all
taplo fmt

clippy:
cargo clippy --all-targets --quiet --no-deps -- --deny=warnings
cargo clippy --all-targets --no-default-features --quiet --no-deps -- --deny=warnings
cargo clippy --all-targets --all-features --quiet --no-deps -- --deny=warnings

# Checks if all headers are present and adds if not
license:
./scripts/add_license.sh

spellcheck:
cargo spellcheck --code 1 || (echo "See .config/spellcheck.md for tips"; false)

install-lint-tools:
cargo install --locked taplo-cli
cargo install --locked cargo-audit
cargo install --locked cargo-spellcheck

install-lint-tools-ci:
wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
tar xzf cargo-binstall-x86_64-unknown-linux-musl.tgz
cp cargo-binstall ~/.cargo/bin/cargo-binstall

cargo binstall --no-confirm taplo-cli cargo-spellcheck cargo-audit
8 changes: 7 additions & 1 deletion blssig/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
[package]
name = "filecoin-f3-blssig"
version = "0.1.0"
edition = "2021"

authors.workspace = true
repository.workspace = true
license.workspace = true
edition.workspace = true

[dependencies]

[dev-dependencies]
3 changes: 3 additions & 0 deletions blssig/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

pub fn add(left: usize, right: usize) -> usize {
left + right
}
Expand Down
9 changes: 9 additions & 0 deletions build/vendored-docs-redirect.index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>

<html>

<head>
<meta http-equiv="Refresh" content="0; url='./filecoin_f3_gpbft/index.html'" />
</head>

</html>
23 changes: 23 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "70...100"

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach,diff,flags,files,footer"
behavior: default
require_changes: no

ignore:
- "tests"
8 changes: 7 additions & 1 deletion gpbft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
[package]
name = "filecoin-f3-gpbft"
version = "0.1.0"
edition = "2021"

authors.workspace = true
repository.workspace = true
license.workspace = true
edition.workspace = true

[dependencies]

[dev-dependencies]
Loading

0 comments on commit f86548d

Please sign in to comment.