-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Motivation A shell script just failed because it was written in bash, had no shebang, and was executed in dash. So I'm adding shellcheck and also shfmt, while I am about it. # Changes - Add shellcheck and shfmt, both as github checks and as scripts to be executed locally. - Note: I have not made github automatically commit shfmt output, as reformatting shell is riskier than reformatting most things. - Note: I have made the indent 2 spaces rather than the 4 used in the main ic repo shfmt, to match the existing code. - Note: I have kept the formatting scripts simple and lightweight rather than using the more sophisticated approach used in the main ic repo. - Combined the github actions formatting steps into a single job, otherwise one of the pushes will fail, if there are several. - Added `cargo fmt` to the formatting commands, alongside shfmt and prettier for ts and a special prettier for svelte. - Removed an empty "generate-wasm.sh" file that was generating linter errors and doesn't seem to be used. - Added `set -euo pipefail` in various places as requested.
- Loading branch information
Showing
25 changed files
with
394 additions
and
665 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,64 @@ on: | |
push: | ||
branches: | ||
- main | ||
- svelte | ||
pull_request: | ||
|
||
jobs: | ||
|
||
formatting: | ||
runs-on: ubuntu-latest | ||
env: | ||
DEPLOY_ENV: mainnet | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install shfmt | ||
run: sudo snap install shfmt | ||
|
||
- name: Install Rust | ||
run: | | ||
rustup update ${{ matrix.rust }} --no-self-update | ||
rustup default ${{ matrix.rust }} | ||
rustup component add rustfmt | ||
- name: Format rust | ||
run: cargo fmt | ||
|
||
- name: Format shell scripts | ||
run: ./scripts/fmt-sh | ||
|
||
- name: Install ts dependencies | ||
run: npm ci | ||
working-directory: ./frontend/ts | ||
- name: Format ts | ||
run: npm run format | ||
working-directory: ./frontend/ts | ||
|
||
- name: Install svelte dependencies | ||
run: npm ci | ||
working-directory: ./frontend/svelte | ||
- name: Format svelte | ||
run: npm run format | ||
working-directory: ./frontend/svelte | ||
|
||
- name: Commit Formatting changes - will not trigger rebuild | ||
uses: EndBug/[email protected] | ||
if: ${{ github.event_name == 'pull_request' }} | ||
with: | ||
add: . | ||
author_name: Formatting Committer | ||
author_email: "<[email protected]>" | ||
message: "Updating svelte frontend formatting" | ||
# do not pull: if this branch is behind, then we might as well let | ||
# the pushing fail | ||
pull_strategy: "NO-PULL" | ||
|
||
|
||
cargo-tests: | ||
needs: formatting | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
|
@@ -49,6 +103,7 @@ jobs: | |
RUST_BACKTRACE: 1 | ||
|
||
flutter-tests: | ||
needs: formatting | ||
runs-on: ubuntu-latest | ||
env: | ||
DEPLOY_ENV: mainnet | ||
|
@@ -69,21 +124,6 @@ jobs: | |
run: npm run test | ||
working-directory: ./frontend/ts | ||
|
||
- name: Check formatting | ||
run: npm run format | ||
working-directory: ./frontend/ts | ||
- name: Commit Formatting changes | ||
uses: EndBug/[email protected] | ||
if: ${{ github.event_name == 'pull_request' }} | ||
with: | ||
add: . | ||
author_name: Formatting Committer | ||
author_email: "<[email protected]>" | ||
message: "Updating frontend formatting" | ||
# do not pull: if this branch is behind, then we might as well let | ||
# the pushing fail | ||
pull_strategy: "NO-PULL" | ||
|
||
- name: Flutter setup | ||
uses: subosito/flutter-action@v1 | ||
with: | ||
|
@@ -103,6 +143,7 @@ jobs: | |
working-directory: ./frontend/dart | ||
|
||
svelte-tests: | ||
needs: formatting | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
|
@@ -124,17 +165,13 @@ jobs: | |
- name: Run linter | ||
run: npm run check | ||
|
||
- name: Check formatting | ||
run: npm run format | ||
|
||
- name: Commit Formatting changes - will not trigger rebuild | ||
uses: EndBug/[email protected] | ||
if: ${{ github.event_name == 'pull_request' }} | ||
with: | ||
add: . | ||
author_name: Formatting Committer | ||
author_email: "<[email protected]>" | ||
message: "Updating svelte frontend formatting" | ||
# do not pull: if this branch is behind, then we might as well let | ||
# the pushing fail | ||
pull_strategy: "NO-PULL" | ||
shell-checks: | ||
needs: formatting | ||
name: ShellCheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run ShellCheck | ||
uses: ludeeus/action-shellcheck@master | ||
env: | ||
SHELLCHECK_OPTS: -e SC1090 -e SC2119 -e SC1091 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
max_width=120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
NETWORK=$1 | ||
|
||
echo "Deploying to $NETWORK..." | ||
DEPLOY_ENV=$NETWORK dfx deploy --no-wallet --network $NETWORK | ||
DEPLOY_ENV=$NETWORK dfx deploy --no-wallet --network "$NETWORK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
# A script for generating the JS of proto files. | ||
protoc \ | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./" \ | ||
--js_out="import_style=commonjs,binary:./" \ | ||
--proto_path="./" \ | ||
./proto/base_types.proto | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./" \ | ||
--js_out="import_style=commonjs,binary:./" \ | ||
--proto_path="./" \ | ||
./proto/base_types.proto | ||
|
||
protoc \ | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./proto" \ | ||
--js_out="import_style=commonjs,binary:./proto" \ | ||
--proto_path="./proto" \ | ||
./proto/ledger.proto | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./proto" \ | ||
--js_out="import_style=commonjs,binary:./proto" \ | ||
--proto_path="./proto" \ | ||
./proto/ledger.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
# A script for updating the protobuf files. | ||
|
||
protoc \ | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./src/proto" \ | ||
--js_out="import_style=commonjs,binary:./src/proto" \ | ||
--proto_path="./src/proto" \ | ||
./src/proto/base_types.proto | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./src/proto" \ | ||
--js_out="import_style=commonjs,binary:./src/proto" \ | ||
--proto_path="./src/proto" \ | ||
./src/proto/base_types.proto | ||
|
||
protoc \ | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./src/proto" \ | ||
--js_out="import_style=commonjs,binary:./src/proto" \ | ||
--proto_path="./src/proto" \ | ||
./src/proto/governance.proto | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./src/proto" \ | ||
--js_out="import_style=commonjs,binary:./src/proto" \ | ||
--proto_path="./src/proto" \ | ||
./src/proto/governance.proto | ||
|
||
protoc \ | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./src/proto" \ | ||
--js_out="import_style=commonjs,binary:./src/proto" \ | ||
--proto_path="./src/proto" \ | ||
./src/proto/ledger.proto | ||
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \ | ||
--ts_out="./src/proto" \ | ||
--js_out="import_style=commonjs,binary:./src/proto" \ | ||
--proto_path="./src/proto" \ | ||
./src/proto/ledger.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
didc bind src/canisters/icManagement/canister.did -t ts > ./src/canisters/icManagement/rawService.ts; | ||
didc bind src/canisters/icManagement/canister.did -t js > ./src/canisters/icManagement/canister.did.js | ||
didc bind src/canisters/governance/canister.did -t ts > ./src/canisters/governance/rawService.ts; | ||
didc bind src/canisters/governance/canister.did -t js > ./src/canisters/governance/canister.did.js | ||
didc bind ../../rs/nns-dapp.did -t ts > ./src/canisters/nnsDapp/rawService.ts | ||
didc bind ../../rs/nns-dapp.did -t js > ./src/canisters/nnsDapp/canister.did.js | ||
#!/usr/bin/env bash | ||
didc bind src/canisters/icManagement/canister.did -t ts >./src/canisters/icManagement/rawService.ts | ||
didc bind src/canisters/icManagement/canister.did -t js >./src/canisters/icManagement/canister.did.js | ||
didc bind src/canisters/governance/canister.did -t ts >./src/canisters/governance/rawService.ts | ||
didc bind src/canisters/governance/canister.did -t js >./src/canisters/governance/canister.did.js | ||
didc bind ../../rs/nns-dapp.did -t ts >./src/canisters/nnsDapp/rawService.ts | ||
didc bind ../../rs/nns-dapp.did -t js >./src/canisters/nnsDapp/canister.did.js |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.