Browse Source

Merge pull request #320 from mnaamani/git-hooks-npm-husky

Git hooks management with husky
shamil-gadelshin 4 years ago
parent
commit
6bd1c6f8d9
4 changed files with 29 additions and 4 deletions
  1. 5 0
      devops/git-hooks/pre-commit
  2. 10 0
      devops/git-hooks/pre-push
  3. 10 1
      package.json
  4. 4 3
      setup.sh

+ 5 - 0
devops/git-hooks/pre-commit

@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+
+echo 'cargo fmt --all -- --check'
+cargo fmt --all -- --check

+ 10 - 0
devops/git-hooks/pre-push

@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+export BUILD_DUMMY_WASM_BINARY=1
+
+echo '+cargo test --all'
+cargo test --all
+
+echo '+cargo clippy --all -- -D warnings'
+cargo clippy --all -- -D warnings

+ 10 - 1
package.json

@@ -7,5 +7,14 @@
 	},
 	"workspaces": [
 		"tests/network-tests"
-	]
+	],
+	"devDependencies": {
+		"husky": "^4.2.5"
+	},
+	"husky": {
+	  "hooks": {
+		"pre-commit": "devops/git-hooks/pre-commit",
+		"pre-push": "devops/git-hooks/pre-push"
+	  }
+	}
 }

+ 4 - 3
setup.sh

@@ -7,8 +7,9 @@ set -e
 #  - rustup - rust insaller
 #  - rust compiler and toolchains
 #  - skips installing substrate and subkey
-curl https://getsubstrate.io -sSf | bash -s -- --fast \
-    && rustup component add rustfmt
+curl https://getsubstrate.io -sSf | bash -s -- --fast
+
+rustup component add rustfmt clippy
 
 # TODO: Install additional tools...
-# - b2sum
+# - b2sum