From 8c0a42fa95e29b17bf9a8191c1dbf3598e78bba5 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 13 Sep 2016 15:12:55 +0200 Subject: [PATCH 1/4] install npm modules & run list & test via gitlab.yml --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bf7f51d7135..2f8e5fd7c36 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: - deploy variables: GIT_DEPTH: "3" - SIMPLECOV: "true" + SIMPLECOV: "true" RUST_BACKTRACE: "1" cache: key: "$CI_BUILD_NAME/$CI_BUILD_REF_NAME" @@ -227,7 +227,9 @@ test-linux: stage: test before_script: - git submodule update --init --recursive + - cd js && npm install && cd .. script: + - cd js && npm run lint && npm test - ./test.sh --verbose tags: - rust-test From 3e2d01b412611532b6e7362301f3f93e42d15ad3 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 13 Sep 2016 15:15:44 +0200 Subject: [PATCH 2/4] eslint issues with ws --- js/src/api/transport/ws/ws.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/api/transport/ws/ws.js b/js/src/api/transport/ws/ws.js index 786b405ecad..8698f70d113 100644 --- a/js/src/api/transport/ws/ws.js +++ b/js/src/api/transport/ws/ws.js @@ -16,7 +16,7 @@ export default class Ws extends JsonRpcBase { _onMessage = (event) => { const result = JSON.parse(event.data); - const {resolve, reject} = this._messages[result.id]; + const { resolve, reject } = this._messages[result.id]; if (result.error) { this.error(event.data); From 3ba148562416fe0dcb895eb17d5fa28fc496f549 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 14 Sep 2016 10:43:12 +0200 Subject: [PATCH 3/4] add install-deps & test scripts (easier access from gitlab-ci.yml) --- .gitlab-ci.yml | 4 ++-- js/scripts/check-master.sh | 10 ---------- js/scripts/deploy-to-gh-pages.sh | 33 -------------------------------- js/scripts/install-deps.sh | 15 +++++++++++++++ js/scripts/test.sh | 15 +++++++++++++++ 5 files changed, 32 insertions(+), 45 deletions(-) delete mode 100644 js/scripts/check-master.sh delete mode 100644 js/scripts/deploy-to-gh-pages.sh create mode 100755 js/scripts/install-deps.sh create mode 100755 js/scripts/test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4a86326eaa..277acd34da2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -243,9 +243,9 @@ test-linux: stage: test before_script: - git submodule update --init --recursive - - cd js && npm install && cd .. + - ./js/scripts/install-deps.sh script: - - cd js && npm run lint && npm test + - ./js/scripts/test.sh - ./test.sh --verbose tags: - rust-test diff --git a/js/scripts/check-master.sh b/js/scripts/check-master.sh deleted file mode 100644 index a3f80d4bd93..00000000000 --- a/js/scripts/check-master.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -PROTECTED_BRANCH='master' -CURRENT_BRANCH=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') - -if [ $PROTECTED_BRANCH = $CURRENT_BRANCH ]; -then - echo "Direct commits to the branch master are not allowed" - exit 1 -fi diff --git a/js/scripts/deploy-to-gh-pages.sh b/js/scripts/deploy-to-gh-pages.sh deleted file mode 100644 index 4458816355e..00000000000 --- a/js/scripts/deploy-to-gh-pages.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# See https://medium.com/@nthgergo/publishing-gh-pages-with-travis-ci-53a8270e87db -set -o errexit - -SOURCE_BRANCH="master" -TARGET_BRANCH="gh-pages" -GIT_USER_EMAIL="admin@travis-ci.org" -GIT_USER_NAME="Travis CI" -SHA=$(git rev-parse --verify HEAD) # reference to commit deployed to TARGET_BRANCH -COMMIT_MSG="Deploy to Github Pages: ${SHA}" - -# Don't deploy if -# 1. Pull request -# 2. Not target branch -# 3. Forked repo - -if [[ ("$TRAVIS_PULL_REQUEST" != "false") || ("$TRAVIS_BRANCH" != "$SOURCE_BRANCH") || ("$TRAVIS_REPO_SLUG" != "$REPO_SLUG") ]]; then - echo 'Not deploying'; - exit 0 -fi - - -# config -git config --global user.email "$GIT_USER_EMAIL" -git config --global user.name "$GIT_USER_NAME" - -# deploy -cd lib -git init -git add . -git commit -m "$COMMIT_MSG" - -git push -f --quiet "https://${GITHUB_TOKEN}@github.com/${REPO_SLUG}.git" $SOURCE_BRANCH:$TARGET_BRANCH > /dev/null 2>&1 diff --git a/js/scripts/install-deps.sh b/js/scripts/install-deps.sh new file mode 100755 index 00000000000..9a89382a193 --- /dev/null +++ b/js/scripts/install-deps.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# change into the js directory (one down from scripts) +pushd `dirname $0` +cd .. + +# install deps and store the exit code +npm install +EXICCODE=$? + +# back to root +popd + +# exit with exit code +exit $EXITCODE diff --git a/js/scripts/test.sh b/js/scripts/test.sh new file mode 100755 index 00000000000..4bc7661ebf4 --- /dev/null +++ b/js/scripts/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# change into the js directory (one down from scripts) +pushd `dirname $0` +cd .. + +# run lint & tests and store the exit code +npm run lint && npm run test +EXICCODE=$? + +# back to root +popd + +# exit with exit code +exit $EXITCODE From 94676c834859c7ed598548843002af189f00050e Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 14 Sep 2016 10:47:49 +0200 Subject: [PATCH 4/4] fix eslint issues to make the build pass --- js/src/dapps/registry.js | 8 +++----- js/src/dapps/registry/Application/application.js | 2 ++ js/src/dapps/registry/Lookup/reducers.js | 9 ++++++--- js/src/dapps/registry/reducers.js | 9 ++++++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/js/src/dapps/registry.js b/js/src/dapps/registry.js index 03ec8885154..a42326bcd27 100644 --- a/js/src/dapps/registry.js +++ b/js/src/dapps/registry.js @@ -9,10 +9,8 @@ import './style.css'; import './registry.html'; ReactDOM.render( - ( - - - - ), + + + , document.querySelector('#container') ); diff --git a/js/src/dapps/registry/Application/application.js b/js/src/dapps/registry/Application/application.js index 9c825a0f0fd..a72d9bced11 100644 --- a/js/src/dapps/registry/Application/application.js +++ b/js/src/dapps/registry/Application/application.js @@ -33,7 +33,9 @@ export default class Application extends Component { } Application.propTypes = { + actions: PropTypes.object, contract: PropTypes.object, fee: PropTypes.object, + lookup: PropTypes.object, owner: PropTypes.string }; diff --git a/js/src/dapps/registry/Lookup/reducers.js b/js/src/dapps/registry/Lookup/reducers.js index dc0aa80b31c..384517ba49b 100644 --- a/js/src/dapps/registry/Lookup/reducers.js +++ b/js/src/dapps/registry/Lookup/reducers.js @@ -5,26 +5,29 @@ const initialState = { }; export default (state = initialState, action) => { - if (action.type === 'lookup start') + if (action.type === 'lookup start') { return { pending: true, name: action.name, key: action.key, result: null }; + } - if (action.type === 'lookup error') + if (action.type === 'lookup error') { return { pending: false, name: null, key: null, result: null }; + } - if (action.type === 'lookup success') + if (action.type === 'lookup success') { return { pending: false, name: null, key: null, result: action.result }; + } return state; }; diff --git a/js/src/dapps/registry/reducers.js b/js/src/dapps/registry/reducers.js index ee05f5f7ed6..05e794d0b4a 100644 --- a/js/src/dapps/registry/reducers.js +++ b/js/src/dapps/registry/reducers.js @@ -8,14 +8,17 @@ const initialState = { }; export default (state = initialState, action) => { - if (action.type === 'set contract') + if (action.type === 'set contract') { return { ...state, contract: action.contract }; + } - if (action.type === 'set fee') + if (action.type === 'set fee') { return { ...state, fee: action.fee }; + } - if (action.type === 'set owner') + if (action.type === 'set owner') { return { ...state, owner: action.owner }; + } if (action.type.slice(0, 6) === 'lookup') { return { ...state, lookup: lookupReducer(state.lookup, action) };