Skip to content

Commit

Permalink
Add trunk to CI and fixes (#1376)
Browse files Browse the repository at this point in the history
* Add trunk in CI and fix existing issues

* Remove references to old hook script

* Add merge_group to the PR workflow
  • Loading branch information
ClementWalter authored Sep 11, 2024
1 parent 333788c commit 0a175c2
Show file tree
Hide file tree
Showing 34 changed files with 435 additions and 313 deletions.
26 changes: 9 additions & 17 deletions .github/workflows/deno_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@ on:
workflow_call:

jobs:
formatting:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v4
with:
sparse-checkout: indexer
- uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x
- name: Run formatting
run: deno fmt --check indexer/

test:
runs-on: ubuntu-latest
timeout-minutes: 30
Expand All @@ -29,7 +15,10 @@ jobs:
deno-version: v1.x
# Checkout target branch and run tests
- name: Run Tests with Coverage on target branch
run: DEFAULT_BLOCK_GAS_LIMIT=7000000 STARKNET_NETWORK=http://0.0.0.0:1010 KAKAROT_ADDRESS=0x11c5faab8a76b3caff6e243b8d13059a7fb723a0ca12bbaadde95fb9e501bda deno test --allow-env --allow-read --coverage=cov_profile
run:
DEFAULT_BLOCK_GAS_LIMIT=7000000 STARKNET_NETWORK=http://0.0.0.0:1010
KAKAROT_ADDRESS=0x11c5faab8a76b3caff6e243b8d13059a7fb723a0ca12bbaadde95fb9e501bda
deno test --allow-env --allow-read --coverage=cov_profile
- name: Generate Coverage Report on target branch
run: deno coverage cov_profile --html
- name: Install bc
Expand All @@ -47,7 +36,10 @@ jobs:
ref: ${{ github.base_ref }}
clean: false
- name: Run Tests with Coverage on base branch
run: DEFAULT_BLOCK_GAS_LIMIT=7000000 STARKNET_NETWORK=http://0.0.0.0:1010 KAKAROT_ADDRESS=0x11c5faab8a76b3caff6e243b8d13059a7fb723a0ca12bbaadde95fb9e501bda deno test --allow-env --allow-read --coverage=cov_profile_main
run:
DEFAULT_BLOCK_GAS_LIMIT=7000000 STARKNET_NETWORK=http://0.0.0.0:1010
KAKAROT_ADDRESS=0x11c5faab8a76b3caff6e243b8d13059a7fb723a0ca12bbaadde95fb9e501bda
deno test --allow-env --allow-read --coverage=cov_profile_main
- name: Generate HTML report from for the base branch
run: deno coverage cov_profile_main --html
- name: Extract coverage percentage from HTML for the base branch
Expand All @@ -65,4 +57,4 @@ jobs:
if (( $(echo "$change > 5.0" | bc -l) )); then
echo "Coverage dropped by more than 5%!"
exit 1
fi
fi
6 changes: 4 additions & 2 deletions .github/workflows/kakarot_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: release

on:
release:
types: [ published ]
types: [published]

env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}/node
Expand Down Expand Up @@ -162,7 +162,9 @@ jobs:
platforms: ${{ matrix.platform }}
file: ./docker/indexer/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.INDEXER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
outputs:
type=image,name=${{ env.INDEXER_IMAGE
}},push-by-digest=true,name-canonical=true,push=true
build-args: |
APIBARA_DOWNLOAD_URL=${{ matrix.apibara_download_url }}
- name: Export digest
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Workflow - Pull Request

on: [pull_request]
on: [pull_request, merge_group]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -19,3 +19,10 @@ jobs:
deno-tests:
name: Deno tests
uses: ./.github/workflows/deno_test.yml

trunk-check:
name: Trunk check
permissions:
checks: write
contents: read
uses: ./.github/workflows/trunk_check.yml
17 changes: 1 addition & 16 deletions .github/workflows/rust_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@ on:
workflow_call:

jobs:
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

test:
runs-on: ubuntu-latest-16-cores
timeout-minutes: 30
Expand Down Expand Up @@ -64,10 +53,6 @@ jobs:
# Create dump
- name: Create dump
run: ./scripts/make_with_env.sh katana-genesis
- name: Lint
run: |
cargo check &&
cargo clippy --workspace --all-features --all-targets -- -D warnings
- name: Test code
run: make test

Expand Down Expand Up @@ -124,7 +109,7 @@ jobs:
strategy:
fail-fast: false
matrix:
sim: [ ethereum/rpc ]
sim: [ethereum/rpc]
include:
- sim: ethereum/rpc-compat
include:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ jobs:
scarb-version: 0.7.0
- name: Run staging script
env:
KAKAROT_STAGING_PRIVATE_KEY: ${{ secrets.KAKAROT_STAGING_PRIVATE_KEY }}
KAKAROT_STAGING_PRIVATE_KEY:
${{ secrets.KAKAROT_STAGING_PRIVATE_KEY }}
run: |
cd scripts
sh upgrade.sh deploy test --staging
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/trunk_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Trunk

on:
workflow_call:

permissions:
checks: write # For trunk to post annotations
contents: read # For repo checkout

jobs:
trunk-check:
name: Trunk
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- run: rustup update
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"

- name: Trunk Check
uses: trunk-io/trunk-action@v1
21 changes: 0 additions & 21 deletions .hooks/pre-push

This file was deleted.

2 changes: 2 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prettier friendly markdownlint config (all formatting rules disabled)
extends: markdownlint/style/prettier
3 changes: 3 additions & 0 deletions .trunk/configs/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"proseWrap": "always"
}
5 changes: 1 addition & 4 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ['{|}']
empty-values:
forbid-in-block-mappings: true
forbid-in-flow-mappings: true
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
19 changes: 15 additions & 4 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,30 @@ runtimes:
- go@1.21.0
- node@18.12.1
- python@3.10.8
definitions:
- type: rust
system_version: allowed
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
disabled:
- checkov
definitions:
- name: clippy
commands:
- name: lint
run:
cargo clippy --message-format json --locked --all-targets
--all-features -- --cap-lints=warn --no-deps
enabled:
- actionlint@1.7.1
- clippy@1.65.0
- clippy@SYSTEM
- rustfmt@SYSTEM
- git-diff-check
- hadolint@2.12.0
- markdownlint@0.41.0
- osv-scanner@1.8.2
- oxipng@9.1.1
- prettier@3.3.2
- rustfmt@1.65.0
- shellcheck@0.10.0
- shfmt@3.6.0
- taplo@0.8.1
Expand All @@ -44,7 +55,7 @@ lint:
actions:
disabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
enabled:
- trunk-upgrade-available
- trunk-fmt-pre-commit
- trunk-check-pre-push
12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,16 @@ serde_json = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
opentelemetry = { version = "0.23.0", features = ["metrics"] }
opentelemetry-otlp = { version = "0.16.0", features = ["trace", "tonic", "metrics"] }
opentelemetry_sdk = { version = "0.23.0", features = ["trace", "metrics", "rt-tokio"] }
opentelemetry-otlp = { version = "0.16.0", features = [
"trace",
"tonic",
"metrics",
] }
opentelemetry_sdk = { version = "0.23.0", features = [
"trace",
"metrics",
"rt-tokio",
] }
tracing-opentelemetry = "0.24.0"


Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ setup: .gitmodules
cd lib/kakarot && make setup && make build && make build-sol && \
mv build/ssj/contracts_Cairo1Helpers.contract_class.json build/cairo1_helpers.json && rm -fr build/ssj
./scripts/extract_abi.sh
chmod +x ./scripts/install_hooks.sh
./scripts/install_hooks.sh

deploy-kakarot:
cd lib/kakarot && STARKNET_NETWORK=$(STARKNET_NETWORK) poetry run python ./kakarot_scripts/deploy_kakarot.py && cd ..
Expand Down
Loading

0 comments on commit 0a175c2

Please sign in to comment.