Skip to content

Commit

Permalink
chore(ci): add ci workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Delgado <[email protected]>
  • Loading branch information
LNSD committed Jun 25, 2024
1 parent 1443cce commit 12ed289
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 16 deletions.
109 changes: 109 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
extends: [
'config:recommended',
':semanticCommits',
':semanticCommitTypeAll(chore)',
'helpers:pinGitHubActionDigests',
],
schedule: [
'before 6am on Monday',
],
configMigration: true,
rebaseWhen: 'behind-base-branch',
lockFileMaintenance: {
enabled: true,
},
packageRules: [
{
groupName: 'futures crates',
groupSlug: 'futures',
matchManagers: [
'cargo',
],
matchPackageNames: [
'futures',
],
matchPackagePrefixes: [
'futures-',
'futures_',
],
},
{
groupName: 'serde crates',
groupSlug: 'serde',
matchManagers: [
'cargo',
],
matchPackageNames: [
'serde',
],
matchPackagePrefixes: [
'serde-',
'serde_',
],
},
{
groupName: 'tonic crates',
groupSlug: 'tonic',
matchManagers: [
'cargo',
],
matchSourceUrlPrefixes: [
'https://github.com/hyperium/tonic',
'https://github.com/tokio-rs/prost',
],
},
{
groupName: 'tracing crates',
groupSlug: 'tracing',
matchManagers: [
'cargo',
],
matchSourceUrlPrefixes: [
'https://github.com/tokio-rs/tracing',
],
matchPackagePrefixes: [
'tracing-',
'tracing_',
],
},
{
groupName: 'alloy-rs core types monorepo',
groupSlug: 'alloy-core',
matchManagers: [
'cargo',
],
matchSourceUrlPrefixes: [
'https://github.com/alloy-rs/core',
],
},
{
groupName: 'async-graphql crates',
groupSlug: 'async-graphql',
matchManagers: [
'cargo',
],
matchPackageNames: [
'async-graphql',
],
matchPackagePrefixes: [
'async-graphql-',
],
},
],
customManagers: [
{
customType: 'regex',
fileMatch: [
'^rust-toolchain(\\.toml)?$',
],
matchStrings: [
'channel\\s*=\\s*"(?<currentValue>\\d+\\.\\d+\\.\\d+)"',
],
depNameTemplate: 'rust',
packageNameTemplate: 'rust-lang/rust',
datasourceTemplate: 'github-releases',
},
],
}
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: ci
on:
pull_request:
push:
branches:
- 'main'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
RUSTFLAGS: '-D warnings'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy

- name: Cache Cargo build files
uses: Leafwing-Studios/cargo-cache@c7e8aa40ae2c975774d3bd766beb92927cfd7771 # v1

- run: cargo check
- run: cargo clippy -- -Dwarnings --force-warn deprecated --force-warn dead-code

- name: Unit tests
run: cargo test --lib

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
components: rustfmt

- run: cargo +nightly fmt --all -- --check
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
## IDEs and editors
/.idea
/.vscode

## Rust
/.config/
**/*.rs.bk
/target/
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
profile = "default"
4 changes: 4 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
unstable_features = true
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
reorder_modules = true
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::{collections::BTreeMap, fmt, ops::Deref, path::PathBuf, str::FromStr};

use reqwest::Url;
use serde::Deserialize;
use serde_with::{serde_as, DisplayFromStr};
use std::{collections::BTreeMap, fmt, ops::Deref, path::PathBuf, str::FromStr};
use thegraph_core::types::alloy_primitives::{Address, B256};

#[serde_as]
Expand Down
33 changes: 20 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
mod config;
mod receipts;

use crate::receipts::track_receipts;
use std::{
collections::{HashMap, HashSet},
env, fs,
sync::Arc,
time::{Duration, SystemTime, UNIX_EPOCH},
};

use anyhow::{anyhow, Context as _};
use config::Config;
use ethers::middleware::contract::abigen;
use ethers::prelude::{Http, Provider, SignerMiddleware};
use ethers::signers::{LocalWallet, Signer as _};
use ethers::types::{Bytes, H256, U256};
use ethers::utils::keccak256;
use ethers::{
middleware::contract::abigen,
prelude::{Http, Provider, SignerMiddleware},
signers::{LocalWallet, Signer as _},
types::{Bytes, H256, U256},
utils::keccak256,
};
use serde::Deserialize;
use serde_with::serde_as;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use std::{env, fs, time::Duration};
use thegraph_core::client::Client as SubgraphClient;
use thegraph_core::types::alloy_primitives::Address;
use thegraph_core::types::alloy_sol_types::SolValue;
use thegraph_core::{
client::Client as SubgraphClient,
types::{alloy_primitives::Address, alloy_sol_types::SolValue},
};
use tokio::time::{interval, MissedTickBehavior};

use crate::receipts::track_receipts;

#[global_allocator]
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;

Expand Down
6 changes: 4 additions & 2 deletions src/receipts.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use crate::config;
use std::{collections::HashMap, fs::File, io::Write as _, path::PathBuf};

use anyhow::Context as _;
use chrono::{serde::ts_milliseconds, DateTime, Datelike, Duration, Utc};
use rdkafka::{
consumer::{Consumer, StreamConsumer},
Message,
};
use serde::Deserialize;
use std::{collections::HashMap, fs::File, io::Write as _, path::PathBuf};
use thegraph_core::types::alloy_primitives::Address;
use tokio::sync::watch;

use crate::config;

pub async fn track_receipts(
config: &config::Kafka,
graph_env: String,
Expand Down

0 comments on commit 12ed289

Please sign in to comment.