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

[fix] #4311: fix pre-commit hook #4313

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Asem-Abdelhady
Copy link
Contributor

Description

the pre-commit hook still generates the genesis in peer even though it does not exist anymore after the big change in the configuration

Linked issue

Closes #4311

Checklist

  • I've read CONTRIBUTING.md
  • I've used the standard signed-off commit format (or will squash just before merging)
  • All applicable CI checks pass (or I promised to make them pass later)
  • (optional) I've written unit tests for the code changes
  • I replied to all comments after code review, marking all implemented changes with thumbs up

@Asem-Abdelhady Asem-Abdelhady self-assigned this Feb 21, 2024
@github-actions github-actions bot added the iroha2-dev The re-implementation of a BFT hyperledger in RUST label Feb 21, 2024
@mversic mversic changed the title [refactor]: pre-commit hook to generate genesis into swarm as peer do… [refactor] #4311: pre-commit hook to generate genesis into swarm as peer do… Feb 21, 2024
@mversic mversic changed the title [refactor] #4311: pre-commit hook to generate genesis into swarm as peer do… [fix] #4311: fix pre-commit hook Feb 21, 2024
Copy link
Contributor

@Arjentix Arjentix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Iroha 1 CI was triggered...?

Copy link
Contributor

@s8sato s8sato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've wanted to check this hook as it's been a while since my last contribution.
I think someone's working example of .git/hooks/pre-commit would help

hooks/pre-commit.sample Outdated Show resolved Hide resolved
@s8sato s8sato self-assigned this Feb 26, 2024
@Arjentix
Copy link
Contributor

I think someone's working example of .git/hooks/pre-commit would help

I don't use pre-commit hook but here is

Some commands from my .vscode/tasks.json
      {
          "label": "regenerate genesis",
          "type": "shell",
          "problemMatcher": [],
          "presentation": {
              "clear": true
          },
          "command": "cargo",
          "args": [
              "run",
              "--release",
              "--bin",
              "kagami",
              "--",
              "genesis",
              "--executor-path-in-genesis=./executor.wasm",
              ">",
              "${workspaceFolder}/configs/swarm/genesis.json",
          ],
      },
      {
          "label": "regenerate executor",
          "type": "shell",
          "problemMatcher": [],
          "presentation": {
              "clear": true
          },
          "command": "cargo",
          "args": [
              "run",
              "--release",
              "--bin",
              "iroha_wasm_builder_cli",
              "--",
              "build",
              "${workspaceFolder}/default_executor",
              "--optimize",
              "--outfile",
              "${workspaceFolder}/configs/swarm/executor.wasm",
          ],
      },
      {
          "label": "regenerate schema",
          "type": "shell",
          "problemMatcher": [],
          "presentation": {
              "clear": true
          },
          "command": "cargo",
          "args": [
              "run",
              "--release",
              "--bin",
              "kagami",
              "--",
              "schema",
              ">",
              "${workspaceFolder}/docs/source/references/schema.json",
          ],
      },
      {
          "label": "regenerate docker compose single",
          "type": "shell",
          "problemMatcher": [],
          "presentation": {
              "clear": true
          },
          "command": "cargo",
          "args": [
              "run",
              "--release",
              "--bin",
              "iroha_swarm",
              "--",
              "-p",
              "1",
              "-s",
              "Iroha",
              "--force",
              "--config-dir",
              "./configs/swarm",
              "--health-check",
              "--build",
              ".",
              "--outfile",
              "configs/swarm/docker-compose.single.yml"
          ],
      },
      {
          "label": "regenerate docker compose multiple",
          "type": "shell",
          "problemMatcher": [],
          "presentation": {
              "clear": true
          },
          "command": "cargo",
          "args": [
              "run",
              "--release",
              "--bin",
              "iroha_swarm",
              "--",
              "-p",
              "4",
              "-s",
              "Iroha",
              "--force",
              "--config-dir",
              "./configs/swarm",
              "--health-check",
              "--build",
              ".",
              "--outfile",
              "configs/swarm/docker-compose.local.yml"
          ],
      },
      {
          "label": "regenerate docker compose default",
          "type": "shell",
          "problemMatcher": [],
          "presentation": {
              "clear": true
          },
          "command": "cargo",
          "args": [
              "run",
              "--release",
              "--bin",
              "iroha_swarm",
              "--",
              "-p",
              "4",
              "-s",
              "Iroha",
              "--force",
              "--config-dir",
              "./configs/swarm",
              "--health-check",
              "--image",
              "hyperledger/iroha2:dev",
              "--outfile",
              "configs/swarm/docker-compose.yml"
          ],
      },
      {
          "label": "regenerate all",
          "type": "shell",
          "problemMatcher": [],
          "presentation": {
              "clear": true
          },
          "dependsOn": [
              "regenerate genesis",
              "regenerate schema",
              "regenerate executor",
              "regenerate docker compose single",
              "regenerate docker compose multiple",
              "regenerate docker compose default",
          ]
      },

@s8sato
Copy link
Contributor

s8sato commented Feb 26, 2024

Or we could just run locally as same consistency checks as CI does:

- name: Check genesis.json
if: always()
run: ./scripts/tests/consistency.sh genesis
- name: Check schema.json
if: always()
run: ./scripts/tests/consistency.sh schema
- name: Check Docker Compose configurations
if: always()
run: ./scripts/tests/consistency.sh docker-compose

I basically think it's up to each developer to avoid failures on push, but as long as pre-commit.sample is referred in CONTRIBUTING.md it needs to be maintained and represent some consensus on pre-commit:
- Perform pre-commit routine like formatting & artifacts regeneration (see [`pre-commit.sample`](./hooks/pre-commit.sample))

@0x009922
Copy link
Contributor

@mversic mversic assigned 0x009922 and unassigned Arjentix Mar 18, 2024
@mversic
Copy link
Contributor

mversic commented Apr 15, 2024

@Asem-Abdelhady let's finish this PR

@Asem-Abdelhady
Copy link
Contributor Author

Also:

Pp till now it is not changed so we can modify it if we decided to go with the change. Unless you want me to change it in this PR of course but I suggest this should be done in a separate PR.

s8sato
s8sato previously approved these changes Apr 16, 2024
Copy link
Contributor

@s8sato s8sato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of the original issue has been reached, though, I'd make it one that ensures everything is up to date i.e. add updates to executor and docker compose files.
#4313 (comment) would help for it

@nxsaken nxsaken changed the base branch from iroha2-dev to main April 16, 2024 08:31
@nxsaken nxsaken dismissed s8sato’s stale review April 16, 2024 08:31

The base branch was changed.

…es not exist

Signed-off-by: Asem-Abdelhady <asemshawkey@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants