From a925f2c44ba18c3c6db03e50a41cffd045cfe9d9 Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Tue, 19 May 2020 17:47:30 +0200 Subject: [PATCH 1/2] [build] auto install rust --- .gitlab-ci.yml | 5 ++--- neon/build.sh | 17 +++++++++++++++++ package.json | 6 +++--- test/run.sh | 11 +++++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100755 test/run.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a81c571c0..e960e8643 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,10 +31,7 @@ workflow: - . "$NVM_DIR/nvm.sh" - nvm install 10 - nvm use 10 - - curl https://sh.rustup.rs -sSf | sh -s -- -y - - export PATH="$HOME/.cargo/bin:$PATH" - export RUSTFLAGS="-D warnings" - - rustup show && rustc --version && cargo --version .cached_nvm: &cached_nvm @@ -109,6 +106,8 @@ fmt_and_clippy: - when: on_success stage: quality script: + - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + - export PATH="$HOME/.cargo/bin:$PATH" - cargo fmt -- --version - cargo fmt -- --check - cargo clippy -- -V diff --git a/neon/build.sh b/neon/build.sh index 105a7a505..19c59a84f 100755 --- a/neon/build.sh +++ b/neon/build.sh @@ -2,6 +2,23 @@ cd neon +if [ -z "${DUNITER_FAST_BUILD}" ] +then + if [ -e "${HOME}/.cargo/bin/rustup" ] + then + rustup update stable + else + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + export PATH="$HOME/.cargo/bin:$PATH" + fi + + rustup show + rustc --version + cargo --version +else + echo "WARNING: you have disabled the automatic update of Rust, remember to update Rust regularly with command \"rustup update\"." +fi + if [ "${NEON_BUILD_RELEASE}" = "true" ] || [ "${NODE_ENV}" = "production" ] then neon build --release diff --git a/package.json b/package.json index 654c92e86..22617b162 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,9 @@ "tsc": "tsc", "tscw": "tsc -w", "doc": "typedoc --out typedoc/ index.ts app/ --mode file --readme README.md --includeDeclarations --sourcefile-url-prefix \"https://git.duniter.org/nodes/typescript/duniter/blob/loki/\"", - "test": "cargo test --all && nyc --reporter html mocha", - "test:rs": "cargo test --all", - "test:ts": "nyc --reporter html mocha", + "test": "./test/run.sh", + "test:rs": "./test/run.sh rs", + "test:ts": "./test/run.sh ts", "start": "node bin/duniter start", "build": "./neon/build.sh && cd.. && tsc && cd \"../node_modules/duniter-ui\" && npm install && npm run build", "install": "./neon/build.sh", diff --git a/test/run.sh b/test/run.sh new file mode 100755 index 000000000..4f22f7774 --- /dev/null +++ b/test/run.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "${1}" = "rs" ] +then + $HOME/.cargo/bin/cargo test --all +elif [ "${1}" = "ts" ] +then + nyc --reporter html mocha +else + $HOME/.cargo/bin/cargo test --all && nyc --reporter html mocha +fi -- GitLab From fab837b94222bf07ada4c971d8b514c02d0eb9f2 Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Tue, 19 May 2020 18:50:03 +0200 Subject: [PATCH 2/2] =?UTF-8?q?[ci]=C2=A0add=20format=20check=20on=20tests?= =?UTF-8?q?=20job?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 1 + app/modules/crawler/lib/sync/Watcher.ts | 8 +++++++- format.sh | 11 +++++++++++ package.json | 4 ++-- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 format.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e960e8643..be1965504 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -86,6 +86,7 @@ tests: stage: tests script: - npm i + - npm run format:check - npm test # Push coverage to GitLab pages - tar cvzf coverage.tar.gz coverage/ diff --git a/app/modules/crawler/lib/sync/Watcher.ts b/app/modules/crawler/lib/sync/Watcher.ts index c0cfac51f..b7e663dac 100644 --- a/app/modules/crawler/lib/sync/Watcher.ts +++ b/app/modules/crawler/lib/sync/Watcher.ts @@ -265,7 +265,13 @@ export class MultimeterWatcher implements Watcher { if (duration) { const durationSecs = Math.floor(duration / 1000); const durationMillisRemain = duration % 1000; - this.multi.write("\nAll done in " + durationSecs + "." + durationMillisRemain + " seconds.\n"); + this.multi.write( + "\nAll done in " + + durationSecs + + "." + + durationMillisRemain + + " seconds.\n" + ); } else { this.multi.write("\nAll done.\n"); } diff --git a/format.sh b/format.sh new file mode 100755 index 000000000..eb54ab98b --- /dev/null +++ b/format.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "${1}" = "check" ] +then + $HOME/.cargo/bin/cargo fmt -- --check && prettier --list-different "app/**/*.{ts,json}" +elif [ "${1}" = "all" ] +then + $HOME/.cargo/bin/cargo fmt && prettier --write "app/**/*.{ts,json}" +else + echo "first argument must be \"check\" or \"all\"." +fi diff --git a/package.json b/package.json index 22617b162..a6691a256 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "install": "./neon/build.sh", "lint": "lint-staged", "prettier": "prettier --write app/**/*/*.ts", - "format:check": "prettier --list-different \"app/**/*.{ts,json}\"", - "format:all": "prettier --write \"app/**/*.{ts,json}\"" + "format:check": "./format.sh check", + "format:all": "./format.sh all" }, "nyc": { "require": [ -- GitLab