Skip to content

Commit 761c104

Browse files
committed
feat(ci): add workflows & repo templates
1 parent 53ec792 commit 761c104

File tree

10 files changed

+391
-10
lines changed

10 files changed

+391
-10
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 🐞 Bug report
2+
description: Create a report to help us improve
3+
title: "🐞 [Bug]: "
4+
labels: ["bug"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill out this bug report! Briefly describe the issue you're experiencing. Tell us what you were trying to do and what happened instead. Remember, this is not a place to ask for help debugging code. For that, we welcome you in the OpenZeppelin Community Forum: https://forum.openzeppelin.com/.
10+
- type: textarea
11+
id: what-happened
12+
attributes:
13+
label: What happened?
14+
description: if you want, you can include screenshots as well :)
15+
validations:
16+
required: true
17+
- type: checkboxes
18+
id: platform
19+
attributes:
20+
label: platform
21+
description: On which operating system did this bug emerge?
22+
options:
23+
- label: linux
24+
required: false
25+
- label: windows
26+
required: false
27+
- label: macos
28+
required: false
29+
- type: textarea
30+
id: expected
31+
attributes:
32+
label: Expected behavior
33+
description: What should have happened instead?
34+
- type: checkboxes
35+
id: terms
36+
attributes:
37+
label: Contribution Guidelines
38+
description: By submitting this issue, you agree to follow our [Contribution Guidelines](https://github.com/OpenZeppelin/rust-contracts-stylus/blob/main/CONTRIBUTING.md)
39+
options:
40+
- label: I agree to follow this project's Contribution Guidelines
41+
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
contact_links:
2+
- name: Questions & Support Requests
3+
url: https://forum.openzeppelin.com/c/support/17
4+
about: Ask in the OpenZeppelin Forum
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 🎁 Feature Request
2+
description: Suggest an idea for this project ⚡️
3+
title: "🎁 [Feature Request]: "
4+
labels: ["enhancement"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill this feature request!
10+
- type: textarea
11+
id: feature
12+
attributes:
13+
label: What is the feature you would like to see?
14+
description: Is your feature request related to a specific problem? Is it just a crazy idea? Tell us about it!
15+
validations:
16+
required: true
17+
- type: checkboxes
18+
id: terms
19+
attributes:
20+
label: Contribution Guidelines
21+
description: By submitting this issue, you agree to follow our [Contribution Guidelines](https://github.com/OpenZeppelin/rust-contracts-stylus/blob/main/CONTRIBUTING.md)
22+
options:
23+
- label: I agree to follow this project's Contribution Guidelines
24+
required: true

.github/codecov.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# ref: https://docs.codecov.com/docs/codecovyml-reference
2+
coverage:
3+
# Hold ourselves to a high bar.
4+
range: 95..100
5+
round: down
6+
precision: 1
7+
status:
8+
# ref: https://docs.codecov.com/docs/commit-status
9+
project:
10+
default:
11+
# Avoid false negatives.
12+
threshold: 1%
13+
# Test files aren't important for coverage.
14+
ignore:
15+
- "tests"
16+
- "docs"
17+
# Make comments less noisy.
18+
comment:
19+
layout: "files"
20+
require_changes: true
21+
github_checks:
22+
annotations: false

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
7+
- package-ecosystem: cargo
8+
directory: /
9+
schedule:
10+
interval: daily
11+
ignore:
12+
- dependency-name: "*"
13+
update-types:
14+
- "version-update:semver-patch"
15+
- "version-update:semver-minor"

.github/pull_request_template.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- Thank you for your interest in contributing to OpenZeppelin! -->
2+
3+
<!-- Consider opening an issue for discussion prior to submitting a PR. -->
4+
<!-- New features will be merged faster if they were first discussed and designed with the team. -->
5+
6+
Fixes #??? <!-- Fill in with issue number -->
7+
8+
<!-- Describe the changes introduced in this pull request. -->
9+
<!-- Include any context necessary for understanding the PR's purpose. -->
10+
11+
#### PR Checklist
12+
13+
<!-- Before merging the pull request all of the following must be completed. -->
14+
<!-- Feel free to submit a PR or Draft PR even if some items are pending. -->
15+
<!-- Some of the items may not apply. -->
16+
17+
- [ ] Tests
18+
- [ ] Documentation

.github/workflows/check.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: check
2+
# This workflow runs whenever a PR is opened or updated, or a commit is pushed
3+
# to main. It runs several checks:
4+
# - fmt: checks that the code is formatted according to `rustfmt`.
5+
# - clippy: checks that the code does not contain any `clippy` warnings.
6+
# - doc: checks that the code can be documented without errors.
7+
# - hack: check combinations of feature flags.
8+
permissions:
9+
contents: read
10+
# This configuration allows maintainers of this repo to create a branch and
11+
# pull request based on the new branch. Restricting the push trigger to the
12+
# main branch ensures that the PR only gets built once.
13+
on:
14+
push:
15+
branches: [main]
16+
pull_request:
17+
# If new code is pushed to a PR branch, then cancel in progress workflows for
18+
# that PR. Ensures that we don't waste CI time, and returns results quicker
19+
# https://github.com/jonhoo/rust-ci-conf/pull/5
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
22+
cancel-in-progress: true
23+
env:
24+
CARGO_TERM_COLOR: always
25+
jobs:
26+
fmt:
27+
runs-on: ubuntu-latest
28+
name: nightly / fmt
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
submodules: true
33+
- name: Install stable
34+
# We run in nightly to make use of some features only available there.
35+
# Check out `rustfmt.toml` to see which ones.
36+
uses: dtolnay/rust-toolchain@nightly
37+
with:
38+
components: rustfmt
39+
- name: cargo fmt --all --check
40+
run: cargo fmt --all --check
41+
clippy:
42+
runs-on: ubuntu-latest
43+
name: ${{ matrix.toolchain }} / clippy
44+
permissions:
45+
contents: read
46+
checks: write
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
# Get early warning of new lints which are regularly introduced in beta
51+
# channels.
52+
toolchain: [stable, beta]
53+
steps:
54+
- uses: actions/checkout@v4
55+
with:
56+
submodules: true
57+
- name: Install ${{ matrix.toolchain }}
58+
uses: dtolnay/rust-toolchain@master
59+
with:
60+
toolchain: ${{ matrix.toolchain }}
61+
components: clippy
62+
- name: cargo clippy
63+
uses: giraffate/clippy-action@v1
64+
with:
65+
reporter: 'github-pr-check'
66+
github_token: ${{ secrets.GITHUB_TOKEN }}
67+
doc:
68+
# Run docs generation on nightly rather than stable. This enables features
69+
# like https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html
70+
# which allows an API be documented as only available in some specific
71+
# platforms.
72+
runs-on: ubuntu-latest
73+
name: nightly / doc
74+
steps:
75+
- uses: actions/checkout@v4
76+
with:
77+
submodules: true
78+
- name: Install nightly
79+
uses: dtolnay/rust-toolchain@nightly
80+
- name: cargo doc
81+
run: cargo doc --no-deps --all-features
82+
env:
83+
RUSTDOCFLAGS: --cfg docsrs
84+
hack:
85+
# `cargo-hack` checks combinations of feature flags to ensure that features
86+
# are all additive which is required for feature unification.
87+
runs-on: ubuntu-latest
88+
name: ubuntu / stable / features
89+
steps:
90+
- uses: actions/checkout@v4
91+
with:
92+
submodules: true
93+
- name: Install stable
94+
uses: dtolnay/rust-toolchain@stable
95+
- name: cargo install cargo-hack
96+
uses: taiki-e/install-action@cargo-hack
97+
# Intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
98+
# --feature-powerset runs for every combination of features
99+
- name: cargo hack
100+
run: cargo hack --feature-powerset check

.github/workflows/nostd.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: no-std
2+
# This workflow checks whether the library is able to run without the std
3+
# library. See `check.yml` for information about how the concurrency
4+
# cancellation and workflow triggering works.
5+
permissions:
6+
contents: read
7+
on:
8+
push:
9+
branches: [main]
10+
pull_request:
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
env:
15+
CARGO_TERM_COLOR: always
16+
jobs:
17+
nostd:
18+
runs-on: ubuntu-latest
19+
name: ${{ matrix.target }}
20+
strategy:
21+
matrix:
22+
target: [wasm32-unknown-unknown, thumbv7m-none-eabi, aarch64-unknown-none]
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
submodules: true
27+
- name: Install stable
28+
uses: dtolnay/rust-toolchain@stable
29+
- name: rustup target add ${{ matrix.target }}
30+
run: rustup target add ${{ matrix.target }}
31+
- name: cargo check
32+
run: cargo check --target ${{ matrix.target }} --no-default-features

.github/workflows/test.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: test
2+
# This is the main CI workflow that runs the test suite on all pushes to main
3+
# and all pull requests. It runs the following jobs:
4+
# - required: runs the test suite on ubuntu with stable and beta rust
5+
# toolchains.
6+
# - minimal: runs the test suite with the minimal versions of the dependencies
7+
# that satisfy the requirements of this crate, and its dependencies.
8+
# - os-check: runs the test suite on mac and windows.
9+
# - coverage: runs the test suite and collects coverage information.
10+
# See `check.yml` for information about how the concurrency cancellation and
11+
# workflow triggering works.
12+
permissions:
13+
contents: read
14+
on:
15+
push:
16+
branches: [main]
17+
paths-ignore:
18+
- "**.md"
19+
- "**.adoc"
20+
pull_request:
21+
paths-ignore:
22+
- "**.md"
23+
- "**.adoc"
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
26+
cancel-in-progress: true
27+
env:
28+
CARGO_TERM_COLOR: always
29+
jobs:
30+
required:
31+
runs-on: ubuntu-latest
32+
name: ubuntu / ${{ matrix.toolchain }}
33+
strategy:
34+
matrix:
35+
# Run on stable and beta to ensure that tests won't break on the next
36+
# version of the rust toolchain.
37+
toolchain: [stable, beta]
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
submodules: true
42+
- name: Install ${{ matrix.toolchain }}
43+
uses: dtolnay/rust-toolchain@master
44+
with:
45+
toolchain: ${{ matrix.toolchain }}
46+
- name: cargo generate-lockfile
47+
# Enable this ci template to run regardless of whether the lockfile is
48+
# checked in or not.
49+
if: hashFiles('Cargo.lock') == ''
50+
run: cargo generate-lockfile
51+
# https://twitter.com/jonhoo/status/1571290371124260865
52+
- name: cargo test --locked
53+
run: cargo test --locked --all-features --all-targets
54+
# https://github.com/rust-lang/cargo/issues/6669
55+
- name: cargo test --doc
56+
run: cargo test --locked --all-features --doc
57+
os-check:
58+
# Run cargo test on MacOS and Windows.
59+
runs-on: ${{ matrix.os }}
60+
name: ${{ matrix.os }} / stable
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
os: [macos-latest, windows-latest]
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
submodules: true
69+
- name: Install stable
70+
uses: dtolnay/rust-toolchain@stable
71+
- name: cargo generate-lockfile
72+
if: hashFiles('Cargo.lock') == ''
73+
run: cargo generate-lockfile
74+
- name: cargo test
75+
run: cargo test --locked --all-features --all-targets
76+
coverage:
77+
# Use llvm-cov to build and collect coverage and outputs in a format that
78+
# is compatible with codecov.io.
79+
#
80+
# Note that codecov as of v4 requires that CODECOV_TOKEN from
81+
#
82+
# https://app.codecov.io/gh/<user or org>/<project>/settings
83+
#
84+
# is set in two places on your repo:
85+
#
86+
# - https://github.com/jonhoo/guardian/settings/secrets/actions
87+
# - https://github.com/jonhoo/guardian/settings/secrets/dependabot
88+
#
89+
# (the former is needed for codecov uploads to work with Dependabot PRs)
90+
#
91+
# PRs coming from forks of your repo will not have access to the token, but
92+
# for those, codecov allows uploading coverage reports without a token.
93+
# it's all a little weird and inconvenient. see
94+
#
95+
# https://github.com/codecov/feedback/issues/112
96+
#
97+
# for lots of more discussion.
98+
runs-on: ubuntu-latest
99+
name: ubuntu / stable / coverage
100+
steps:
101+
- uses: actions/checkout@v4
102+
with:
103+
submodules: true
104+
- name: Install stable
105+
uses: dtolnay/rust-toolchain@stable
106+
with:
107+
components: llvm-tools-preview
108+
- name: cargo install cargo-llvm-cov
109+
uses: taiki-e/install-action@cargo-llvm-cov
110+
- name: cargo generate-lockfile
111+
if: hashFiles('Cargo.lock') == ''
112+
run: cargo generate-lockfile
113+
- name: cargo llvm-cov
114+
run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info
115+
- name: Record Rust version
116+
run: echo "RUST=$(rustc --version)" >> "$GITHUB_ENV"
117+
- name: Upload to codecov.io
118+
uses: codecov/codecov-action@v4
119+
with:
120+
fail_ci_if_error: true
121+
token: ${{ secrets.CODECOV_TOKEN }}
122+
env_vars: OS,RUST

0 commit comments

Comments
 (0)