feat: Add Cargo files, CI, configs and README

This commit is contained in:
Diana Carvalho
2025-01-16 12:53:28 +00:00
parent a2784be122
commit c27b253ef5
17 changed files with 3980 additions and 1 deletions

17
.github/workflows/ci.yaml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Continuous Integration
on:
pull_request:
permissions:
id-token: write
contents: read
jobs:
tests-and-lints:
uses: ./.github/workflows/tests-and-lints-template.yaml
secrets:
eth_rpc_url: ${{ secrets.ETH_RPC_URL }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

View File

@@ -0,0 +1,123 @@
name: Continuous Integration
on:
workflow_call:
inputs:
runs_on:
required: false
type: string
default: ubuntu-latest
timeout_minutes:
required: false
type: number
default: 15
secrets:
eth_rpc_url:
required: true
app_id:
required: true
app_private_key:
required: true
permissions:
id-token: write
contents: read
env:
CARGO_TERM_COLOR: always
ETH_RPC_URL: ${{ secrets.eth_rpc_url }}
jobs:
compile_and_test:
name: Compile & Test
runs-on: ${{ inputs.runs_on }}
timeout-minutes: ${{ inputs.timeout_minutes }}
strategy:
matrix:
toolchain:
- stable
steps:
- name: Generate a token
id: generate-token
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.app_id }}
private_key: ${{ secrets.app_private_key }}
- name: Install git
run: sudo apt update && sudo apt install -y git
- name: Checkout
uses: actions/checkout@v3
- name: Setup git to use https
run: |
git config --global credential.helper store
echo "https://${{ steps.generate-token.outputs.token }}@github.com" > ~/.git-credentials
git config --global url."https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com".insteadOf ssh://github.com
- name: Setup toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Test
run: cargo nextest run --workspace --lib --all-targets --all-features && cargo test --doc
lint:
name: Code Lint
runs-on: ${{ inputs.runs_on }}
timeout-minutes: ${{ inputs.timeout_minutes }}
steps:
- name: Generate a token
id: generate-token
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.app_id }}
private_key: ${{ secrets.app_private_key }}
- name: Install git
run: sudo apt update && sudo apt install -y git
- name: Checkout
uses: actions/checkout@v3
- name: Setup git to use https
run: |
git config --global credential.helper store
echo "https://${{ steps.generate-token.outputs.token }}@github.com" > ~/.git-credentials
git config --global url."https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com".insteadOf ssh://github.com
- name: Setup clippy toolchain - stable
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: clippy
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo clippy --workspace --lib --all-targets --all-features -- -D clippy::dbg-macro
env:
RUSTFLAGS: -Dwarnings
- run: cargo check --no-default-features
env:
RUSTFLAGS: -Dwarnings
- name: Setup rustfmt toolchain - nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo +nightly fmt --all --check

42
.github/workflows/v2-main-workflow.yaml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Main workflow
on:
push:
branches:
- main
jobs:
tests-and-lints:
uses: ./.github/workflows/tests-and-lints-template.yaml
secrets:
eth_rpc_url: ${{ secrets.ETH_RPC_URL }}
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
check-release:
uses: propeller-heads/ci-cd-templates/.github/workflows/release-v2.yaml@main
with:
args: --dry-run --no-ci
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
secrets:
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
release:
needs:
- tests-and-lints
- check-release
if: needs.check-release.outputs.verify_release_version != ''
uses: propeller-heads/ci-cd-templates/.github/workflows/release-v2.yaml@main
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
secrets:
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}

19
.github/workflows/v2-validate-pr.yaml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Validate PR title
on:
pull_request_target:
branches:
- main
- release/*
types:
- opened
- edited
- synchronize
jobs:
validate-pr:
uses: propeller-heads/ci-cd-templates/.github/workflows/validate-pr.yaml@main
secrets:
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}