Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.4.0 #473

Merged
merged 9 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions frontend/.dockerignore → .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
.git
.dockerignore
.gitignore
.github/*
.github/
README.md
Dockerfile

docker/
.venv/
.vscode/
.ollama/

# Artifacts that will be built during image creation.
# This should contain all files created during `yarn build`.
dist
node_modules
npm-debug.log
.DS_Store
frontend/dist
frontend/node_modules
frontend/npm-debug.log
frontend/.DS_Store

src/assets/examples
.nyc_output
coverage
vite.config.ts.timestamp-*
frontend/src/assets/examples
frontend/.nyc_output
frontend/coverage
frontend/vite.config.ts.timestamp-*
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Fixes #issue-number-here
- [ ] I have tested this code
- [ ] I have reviewed my own PR
- [ ] I have created an issue for this PR
- [ ] I have set the PR name to the issue name
- [ ] I have set a descriptive PR title compliant with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)

# Reviewing tips

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/backend_integration_tests_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
pip install -r requirements.test.txt

- name: Run tests
run: pytest tests/integration/
run: pytest tests/integration/ -vv

- name: Dump Docker Compose logs
run: docker compose logs
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/conventional-commit-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: PR Conventional Commit Validation

on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches: [staging]

jobs:
validate-pr-title:
runs-on: ubuntu-latest
steps:
- name: PR Conventional Commit Validation
uses: ytanikin/[email protected]
with:
task_types: '["feat","fix","docs","test","ci","refactor","perf","chore","revert"]'
add_label: "false"
26 changes: 26 additions & 0 deletions .github/workflows/only-merge-release-branches-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Only merge release branches to main

on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches:
- main
- staging

jobs:
validate-pr-source-branch:
runs-on: ubuntu-latest
steps:
- name: Check if source branch is a release branch
run: |
if [[ ${{ github.event.pull_request.base.ref }} == "staging" ]]; then
echo "Target branch is staging"
exit 0
fi
if [[ ${{ github.event.pull_request.head.ref }} =~ ^release/.*$ ]]; then
echo "Source branch is a release branch"
exit 0
else
echo "Source branch is not a release branch"
exit 1
fi
19 changes: 12 additions & 7 deletions .github/workflows/release-from-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ jobs:
runs-on: ubuntu-latest
permissions: # As per https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release
contents: write
pull-requests: read

steps:
- uses: actions/checkout@v4
# We retrieve the original PR since the commit message is line wrapped
# Depends on the following format from the commit message:
# Release vX.Y.Z ...
#
# Release notes here
# ...
# Release vX.Y.Z (#PR_NUMBER)
# ... body of the PR ...
- name: Create release
run: |
commit_msg=$(git log -1 --pretty=%B)
semver=$(echo $commit_msg | head -n -1 | awk '{print $2}')
echo $commit_msg | tail -n +3 > body.txt
commit_msg_head=$(git log -1 --pretty=%B | head -n 1)
echo $commit_msg_head
release_pr_number=$(echo $commit_msg_head | awk '{print $3}' | grep -oP '\(\#\K[0-9]+')
echo $release_pr_number
semver=$(echo $commit_msg_head | awk '{print $2}')
echo $semver
gh pr view $release_pr_number --json body --jq .body > body.txt
cat body.txt
gh release create $semver --title $semver -F body.txt --prerelease
# TODO: remove prerelease flag after testing ^^^^^^^^^^^^
env:
Expand Down
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ repos:
entry: sh -c "cd frontend && npm run format"
language: system
files: frontend
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []

default_install_hook_types:
- pre-commit
Expand Down
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@
"host": "localhost"
},
"justMyCode": true
},
{
"name": "SQLAlchemy tests: Remote Attach",
"type": "debugpy",
"request": "attach",
"pathMappings": [
{
"localRoot": "${workspaceFolder}/backend",
"remoteRoot": "/app/backend"
},
{
"localRoot": "${workspaceFolder}/tests/db-sqlalchemy",
"remoteRoot": "/app"
}
],
"connect": {
"port": 5678,
"host": "localhost"
},
"justMyCode": true
}
],
"compounds": [
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
114 changes: 34 additions & 80 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,120 +14,74 @@ Contributions to the GenLayer Simulator are welcome in several forms:

Help us make the simulator better by testing and giving feedback:

- First, install the simulator using the GenLayer [CLI](https://github.com/yeagerai/genlayer-simulator?tab=readme-ov-file#quick-install).
- Start installing the simulator using the GenLayer [CLI](https://github.com/yeagerai/genlayer-simulator?tab=readme-ov-file#quick-install).
- Try out the Simulator features and tell us what you think through our [feedback form](https://docs.google.com/forms/d/1IVNsZwm936kSNCiXmlAP8bgJnbik7Bqaoc3I6UYhr-o/viewform) or on our [Discord Channel](https://discord.gg/8Jm4v89VAu).
- If you find any issues, please report them on our [GitHub issues page](https://github.com/yeagerai/genlayer-simulator/issues).

### Sharing New Ideas and Use Cases

Have ideas for new features or usecases? We're eager to hear them! But first:
Have ideas for new features or use cases? We're eager to hear them! But first:

- Ensure you have the [Simulator installed](https://github.com/yeagerai/genlayer-simulator?tab=readme-ov-file#quick-install) first to explore existing use cases.
- After you've familiarized yourself with the simulator, contribute your unique use case and share your ideas in our [Discord channel](https://discord.gg/8Jm4v89VAu).
- After familiarizing yourself with the simulator, contribute your unique use case and share your ideas in our [Discord channel](https://discord.gg/8Jm4v89VAu).

### Writing Code
### Bug fixing and Feature development

To contribute to feature development or bug fixes. Check our [issue tracker](https://github.com/yeagerai/genlayer-simulator/issues) for tasks labeled `help wanted`.
#### 1. Set yourself up to start coding

#### Setup Simulator manually
- **1.1. Pick an issue**: Select one from the project GitHub repository [issue list](https://github.com/yeagerai/genlayer-simulator/issues) and assign it to yourself.

###### Frontend
- **1.2. Create a branch**: create the branch that you will work on by using the link provided in the issue details page (right panel at the bottom - section "Development")

We run ESLint and Prettier on the frontend code. To install the dependencies, run:

```sh
$ cd frontend
$ npm install
```

##### Window One

```sh
$ cp .env.example .env
$ docker compose up
```

##### Window Two

1. Installing the Ollama model
- **1.3. Setup the Simulator locally**: launch the simulator's frontend and backend by running the docker compose command (Please note that you must have docker, node, and npm installed)

```sh
$ docker exec ollama ollama pull llama3
$ cp .env.example .env
$ docker compose up
```

2. Setup your environment

- Linux / MacOS

```sh
$ virtualenv .venv
$ source .venv/bin/activate
(.venv) $ pip install -r requirements.txt
(.venv) $ export PYTHONPATH="$(pwd)"
```

- Windows (cmd)

```sh
$ virtualenv .venv
$ .\.venv\Scripts\activate
(.venv) $ pip install -r requirements.txt
(.venv) $ set PYTHONPATH=%cd%
```

- Windows (PowerShell)

```sh
$ virtualenv .venv
$ .\.venv\Scripts\activate
(.venv) $ pip install -r requirements.txt
(.venv) $ $env:PYTHONPATH = (Get-Location).Path
```

3. Install [pre-commit](https://pre-commit.com) hooks (used for linting, testing, conventions)
#### 2. Submit your solution
- **2.1. Install [pre-commit](https://pre-commit.com) hooks**: this is used for linting, testing, and enforcing conventions.

```sh
(.venv) $ pre-commit install
```

To see the configuration, check the `.pre-commit-config.yaml` file.
To look into the configuration details, check the `.pre-commit-config.yaml` file.

Some of our configurations are:
Some of the configurations applied are:

- Python Black formatter
- Python pytest for unit tests
- ESLint for frontend code
- Prettier for frontend code
- [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) for commit messages

4. Execute the Demo
- **2.2. Black Formatter on Save File**: Configure IDE extensions to format your code with [Black](https://github.com/psf/black) before submitting it.
- **2.3. Code solution**: implement the solution in the code.
- **2.4. Pull Request**: Submit your changes through a pull request (PR). Fill the entire PR template and set the PR title as a valid conventional commit.
- **2.5. Check PR and issue linking**: if the issue and the PR are not linked, you can do it manually in the right panel of the Pull Request details page.
- **2.6. PR Validation and Testing**: Your PR will be automatically validated, analyzed, and tested. Please make sure all tests and validations pass before proceeding.
- **2.7. Peer Review**: One or more core contributors will review your PR. They may suggest changes or improvements.
- **2.8. Approval and Merge**: After approval from the reviewers, you can merge your PR with a squash and merge type of action.

#### 3. Other considerations
- **3.1. Small fixes don't require creating an issue**: significantly small issues can be submitted through a valid Pull Request without needing to create an issue.
- **3.2. Run the frontend in dev mode**: to run the frontend separately from the backend and with hot reload enabled, first launch the backend without the frontend:

```sh
(.venv) $ python scripts/debug_simulator.py
$ docker compose upjsonrpc webrequest ollama database-migration postgres
```
Then launch the frontend in dev mode:
```sh
$ cd frontend
$ npm install
$ npm run dev
```

### Improving Documentation

To contribute to our docs, start by visiting our [Documentation Repository](https://github.com/yeagerai/genlayer-docs) to create new issues or contribute to existing issues.

## Review Process

We strive to maintain high-quality code and ensure that all contributions align with our goals. Here’s our process:

- **Black Formatter on Save File**: Configure IDE extensions to format your code with [Black](https://github.com/psf/black) before submitting it.
- **Pull Request**: Submit your changes through a pull request (PR).
- **Automated Tests**: Your PR will automatically be tested. Ensure all tests pass to proceed.
- **Peer Review**: One or more core contributors will review your PR. They may suggest changes or improvements.
- **Approval and Merge**: After approval from the reviewers, your PR will be merged into the project.

### PR Checks

On PRs we have the following checks:

- Backend end-to-end tests
- Frontend unit tests
To contribute to our docs, visit our [Documentation Repository](https://github.com/yeagerai/genlayer-docs) to create new issues or contribute to existing issues.

These will be run automatically when you open a PR (and would need an approval from a maintainer if you are not a maintainer). If you modify your PR afterwards, you'll need to manually run the checks again by commenting `/test` on the PR.

## Community

Expand All @@ -136,4 +90,4 @@ Connect with the GenLayer community to discuss, collaborate, and share insights:
- **[Discord Channel](https://discord.gg/8Jm4v89VAu)**: Our primary hub for discussions, support, and announcements.
- **[Telegram Group](https://t.me/genlayer)**: For more informal chats and quick updates.

Your continuous feedback drives better product development. Engage with us regularly to test, discuss, and improve the GenLayer Simulator.
Your continuous feedback drives better product development. Please engage with us regularly to test, discuss, and improve the GenLayer Simulator.
Loading