Skip to content

Commit

Permalink
Merge pull request #83 from cristianFleita/pre-push
Browse files Browse the repository at this point in the history
Feat: Pre push hook
  • Loading branch information
danielcdz authored Oct 28, 2024
2 parents 38a20c2 + 0bc9e7e commit 7261439
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 1,741 deletions.
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
katana:
katana --disable-fee --allowed-origins "*" --invoke-max-steps 4294967295

setup:
@./scripts/setup.sh

init:
@mkdir -p .git/hooks
@touch .git/hooks/pre-push
@echo '#!/bin/bash' > .git/hooks//pre-push
@echo 'echo "Running pre-push hook..."' >> .git/hooks/pre-push
@echo 'echo "Executing sozo test..."' >> .git/hooks/pre-push
@echo '' >> .git/hooks/pre-push
@echo '# Run sozo test' >> .git/hooks/pre-push
@echo 'if ! sozo test; then' >> .git/hooks/pre-push
@echo ' echo "❌ sozo test failed. Push aborted."' >> .git/hooks/pre-push
@echo ' exit 1' >> .git/hooks/pre-push
@echo 'fi' >> .git/hooks/pre-push
@echo '' >> .git/hooks/pre-push
@echo 'echo "✅ sozo test passed. Proceeding with push..."' >> .git/hooks/pre-push
@echo 'exit 0' >> .git/hooks/pre-push
@chmod +x .git/hooks/pre-push
@echo "Git hooks initialized successfully!"

# Define tasks that are not real files
.PHONY: katana setup torii init

# Catch-all rule for undefined commands
%:
@echo "Error: Command '$(MAKECMDGOALS)' is not defined."
@exit 1
48 changes: 35 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<img src="https://img.shields.io/github/stars/ByteBuildersLabs?style=social"/>
</a>


[![Telegram Chat][tg-badge]][tg-url]

[tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fdojoengine
Expand Down Expand Up @@ -53,21 +52,27 @@ Go to the [Rust installation page](https://doc.rust-lang.org/book/ch01-01-instal
After installing Rust, ensure your `PATH` environment variable includes the Cargo bin directory (usually `$HOME/.cargo/bin`).

### Install Git 🧑‍💻

Go to the [Git installation page](https://git-scm.com/downloads) and follow the instructions for your operating system to install Git.

### Install Scarb ⚙️

The Dojo toolchain integrates [Scarb](https://docs.swmansion.com/scarb/) to build and run Dojo projects, installation instructions are [here](https://docs.swmansion.com/scarb/download.html).

### Install Dojo using `dojoup` 🥋

You can install with the `dojoup` version manager which enables you to easily install, update and manage your Dojo installation.

### Install dojoup 🛠️

```bash
curl -L https://install.dojoengine.org | bash
```

### Install the Dojo v1.0.0-alpha.5 release 🚀

dojoup --version 1.0.0-alpha.5

### Install Dojo using `asdf` 📦

You can alternatively use the `asdf` package manager to install and manage your Dojo installation.
Expand All @@ -90,40 +95,57 @@ asdf install dojo 0.7.0 # For a specific version

```

### Set the global or local version 📁
### Set the global or local version 📁

```bash
asdf global dojo latest # Set globally
asdf local dojo 0.7.0 # Set locally in your project directory

```

### Setup the hooks

This project uses `Git hooks` to ensure code quality and prevent issues before they reach the remote repository.

#### Pre-push Hook

We have implemented a `pre-push` hook that automatically runs tests before any code is pushed to the remote repository. This helps maintain code quality and prevents broken code from being pushed.

##### What it does

- Runs `sozo test` automatically before each push
- Blocks the push if tests fail
- Allows the push to proceed only if all tests pass

##### Setup Instructions

```bash
# Run Katana
make init
```

## Running Locally 🖥️

### Terminal one (Make sure this is running) 🏃

```bash
# Run Katana
katana --disable-fee --allowed-origins "*"
make katana
```

### Terminal two 🔄
```bash
# Build the example
sozo build

# Migrate the example
sozo migrate apply

# Start Torii
torii --world 0x70835f8344647b1e573fe7aeccbf044230089eb19624d3c7dea4080f5dcb025 --allowed-origins "*"
```bash
# Build migrate and start torii
make setup
```

## Contribution 🤝

We welcome contributions from developers of all levels! If you're interested in contributing to this project, please follow our [CONTRIBUTION GUIDELINES](./CONTRIBUTION.md) to get started.
We welcome contributions from developers of all levels! If you're interested in contributing to this project, please follow our [CONTRIBUTION GUIDELINES](./CONTRIBUTION.md) to get started.

Whether it's fixing bugs, improving documentation, or adding new features, your help is greatly appreciated. Don't hesitate to ask questions or reach out for support—we're here to help!


## Communication channel 📢

If you're a contributor or would like to connect with the project maintainers, feel free to join our [Telegram](https://t.me/+-84e2pqLtqNkZDAx) group!
Loading

0 comments on commit 7261439

Please sign in to comment.