Skip to content

Commit

Permalink
Add justfile (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xh3rman authored Sep 15, 2024
1 parent b4bd9ae commit 2f1200c
Show file tree
Hide file tree
Showing 18 changed files with 249 additions and 223 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/ci-stone-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Setup NDK
run: make install-ndk

- name: Setup Gradle
uses: gradle/gradle-build-action@v3

- uses: actions/cache@v3
with:
path: |
Expand All @@ -64,8 +58,17 @@ jobs:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Install just
run: cargo install just

- name: Setup NDK
run: just install-ndk

- name: Setup Gradle
uses: gradle/gradle-build-action@v3

- name: Build Android Bindings
run: |
df -h
make prepare-android && make bindgen-kotlin
make android
just install-android-targets
just bindgen-kotlin && just build-android
10 changes: 7 additions & 3 deletions .github/workflows/ci-stone-ios.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: iOS CI
name: Gemstone iOS

on:
push:
Expand Down Expand Up @@ -36,10 +36,14 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Install just
run: cargo install just

- name: Run tests
run: cargo test

- name: Test iOS
run: |
make prepare-apple && make apple
make test-ios
just install-ios-targets
just build-ios && just test-ios
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ jobs:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Run tests
run: cargo test --all --verbose
run: |
cargo install just && just test-all
3 changes: 2 additions & 1 deletion .github/workflows/diesel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ jobs:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install diesel
run: make install-diesel
run: |
cargo install just && just install-diesel
- name: Run migration
run: |
diesel setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run Lint
run: make lint
run: cargo install just && just lint
7 changes: 5 additions & 2 deletions .github/workflows/release-stone-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ jobs:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Install just
run: cargo install just

- name: Build iOS frameworks
run: |
make prepare-apple
make apple BUILD_MODE=${{ env.BUILD_MODE }} IPHONEOS_DEPLOYMENT_TARGET=${{ env.IPHONEOS_DEPLOYMENT_TARGET }}
just install-ios-targets
export BUILD_MODE=${{ env.BUILD_MODE }} IPHONEOS_DEPLOYMENT_TARGET=${{ env.IPHONEOS_DEPLOYMENT_TARGET }} && just build-ios
working-directory: gemstone

- name: Zip iOS framework
Expand Down
53 changes: 27 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 3 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,42 +1,6 @@
install: install-rust install-typeshare install-postgres install-diesel
@echo Install Rust
@curl curl https://sh.rustup.rs -sSf | sh -s -- -y
install: install-rust

install-rust:
@echo Install Rust
@curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@cargo install cargo-machete

install-typeshare:
@echo Install typeshare-cli
@cargo install typeshare-cli --version 1.11.0 --force

install-diesel:
@cargo install diesel_cli --no-default-features --features postgres --version 2.2.4 --force

install-postgres:
brew install libpq postgresql@15
brew link postgresql@15
export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libpq/include"

test:
cargo test --workspace --quiet

format:
cargo fmt -q --all

lint:
cargo clippy --version
cargo clippy -- -D warnings
fix:
cargo clippy --fix --allow-dirty --allow-staged --workspace --quiet

unused:
cargo machete

migrate:
diesel migration run

localize:
@sh scripts/localize.sh core crates/localizer/i18n
@curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
cargo install just
2 changes: 1 addition & 1 deletion apps/alerter/src/price_alerts_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl PriceAlertSender {
.price_alert_client
.get_notifications_for_price_alerts(price_alert_notifications, self.topic.clone());

if notifications.len() == 0 {
if notifications.is_empty() {
return Ok(0);
}

Expand Down
19 changes: 4 additions & 15 deletions apps/parser/src/parser_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ impl ParserProxy {
pub fn new(chain: Chain, config: ParserProxyUrlConfig) -> Self {
Self {
chain,
providers: config
.urls
.clone()
.into_iter()
.map(|x| ParserProxy::new_provider(chain, &x))
.collect(),
providers: config.urls.clone().into_iter().map(|x| ParserProxy::new_provider(chain, &x)).collect(),
providers_urls: config.urls,
provider_current_index: Arc::new(Mutex::new(0)),
}
Expand All @@ -44,7 +39,7 @@ impl ParserProxy {
}
let current_index = *self.provider_current_index.lock().unwrap();
let new_index = thread_rng().gen_range(0..self.providers.len());
//TODO: Make sure it's not the same as current index
//TODO: Ensure it's not the same as current index

println!(
"parser proxy switching for chain: {}, from: {}, to: {}",
Expand All @@ -71,15 +66,9 @@ impl ChainProvider for ParserProxy {
}
}

async fn get_transactions(
&self,
block_number: i64,
) -> Result<Vec<primitives::Transaction>, Box<dyn Error + Send + Sync>> {
async fn get_transactions(&self, block_number: i64) -> Result<Vec<primitives::Transaction>, Box<dyn Error + Send + Sync>> {
let provider_index = *self.provider_current_index.lock().unwrap();
match self.providers[provider_index]
.get_transactions(block_number)
.await
{
match self.providers[provider_index].get_transactions(block_number).await {
Ok(txs) => Ok(txs),
Err(err) => Err(self.handle_error(err)),
}
Expand Down
Loading

0 comments on commit 2f1200c

Please sign in to comment.