From cc39a626a991389ec5e78e7caa364ec1e460a24e Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sat, 29 Jun 2019 14:44:54 +0100 Subject: [PATCH] enable server part CI --- .circleci/config.yml | 85 +++++++++++++++++++++++++++--------------- README.md | 17 ++++----- ci/mypy | 8 ++++ ci/pylint | 7 ++++ ci/pytest | 7 ++++ server/ci.sh | 8 ---- server/grasp_server.py | 2 +- 7 files changed, 86 insertions(+), 48 deletions(-) create mode 100755 ci/mypy create mode 100755 ci/pylint create mode 100755 ci/pytest delete mode 100755 server/ci.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 3fbc1ae..a53821a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,27 +1,12 @@ # TODO should I use yarn as in circleci node example?? version: 2 + jobs: - build: + client_build_and_check: docker: - image: circleci/node:latest - - working_directory: ~/repo - steps: - checkout - - # ugh. circleci only got python3.6 on this node package??? and it's unclear how to combine multiple circleci docker configurations... - # - run: | - # sudo apt install python3-pip - # sudo python3 -m pip install pylint mypy - # - run: - # name: pylint - # command: python3 -m pylint -E server/grasp_server.py - # - run: - # name: mypy - # command: python3 -m mypy server/grasp_server.py - - - run: sudo npm install -g npm - restore_cache: @@ -29,26 +14,66 @@ jobs: - dependency-cache-{{ checksum "package.json" }} # fallback to using the latest cache if no exact match is found - dependency-cache- - - run: npm install - save_cache: key: dependency-cache-{{ checksum "package.json" }} paths: - ./node_modules + + - run: npm run build + + # TODO ugh. is there a way for a job to inherit a cloned repo after npm run build has ran?? I'd like to separate build and check steps - run: - name: build - command: npm run build - - run: - name: flow + name: js flow command: npm run flow + when: always - run: name: eslint command: npm run eslint - # - store_artifacts: - # path: test-results.xml - # prefix: tests - # - store_artifacts: - # path: coverage - # prefix: coverage - # - store_test_results: - # path: test-results.xml + when: always + + + server_build_and_check: + docker: + - image: circleci/python:latest + steps: + - checkout + + # TODO preserve apt cache.. + - run: sudo apt install python3-pip + - run: python3 -m pip install --user mypy pylint pytest + + - run: + name: pylint + command: ci/pylint + when: always + + - run: + name: mypy + command: ci/mypy + when: always + + - run: + name: pytest + command: ci/pytest + when: always + +workflows: + version: 2 + + build_and_test: + jobs: + - client_build_and_check + - server_build_and_check + + +# # ugh. circleci only got python3.6 on this node package??? and it's unclear how to combine multiple circleci docker configurations... + +# # - store_artifacts: +# # path: test-results.xml +# # prefix: tests +# # - store_artifacts: +# # path: coverage +# # prefix: coverage +# # - store_test_results: +# # path: test-results.xml diff --git a/README.md b/README.md index af7b7ac..f27fe67 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,19 @@ The only downside so far is that it's not as well integrated with emacs as its b However, if that's a stopper for you, please let me know, I could come up with something! # Requirements -No third party dependencies! Just `python 3.6`. +No third party dependencies! Just `python3`. # Potentional improvements * see [todos](./TODO.org) +# Permissions used +* `storage` for settings +* `notifications` for showing error notification +* `activeTab` for requesting url, title and selected text +* `http://localhost/capture` for talking with backend +* `content_security_policy` needed for webpack + # Building extension The most up-to-date instructions should be in [CI config](./.circleci/config.yml). @@ -68,14 +75,6 @@ If you do need unresticted url permissions, build the extensions like that: `ANY ## building for Firefox Default target is Chrome. use `TARGET=firefox npm run build` to build for firefox. The code is actually same, the only differences are minor appearance adjustments in manifest. -# Permissions used -* `storage` for settings -* `notifications` for showing error notification -* `activeTab` for requesting url, title and selected text -* `http://localhost/capture` for talking with backend - -* `content_security_policy` needed for webpack. - # Credits * Icon made by Freepik from www.flaticon.com, licensed by CC 3.0 BY * [Original Org Capture extension](https://github.com/sprig/org-capture-extension) diff --git a/ci/mypy b/ci/mypy new file mode 100755 index 0000000..2284e95 --- /dev/null +++ b/ci/mypy @@ -0,0 +1,8 @@ +#!/bin/bash +set -eux + +# TODO ugh. doesn't work from circleci... +# cd "$(git rev-parse --show-toplevel)" + +# TODO use strict? +python3 -m mypy --check-untyped-defs "$@" server/*.py server/setup diff --git a/ci/pylint b/ci/pylint new file mode 100755 index 0000000..a663c48 --- /dev/null +++ b/ci/pylint @@ -0,0 +1,7 @@ +#!/bin/bash +set -eux + +# TODO ugh. doesn't work from circleci... +# cd "$(git rev-parse --show-toplevel)" + +python3 -m pylint -E "$@" server/*.py server/setup diff --git a/ci/pytest b/ci/pytest new file mode 100755 index 0000000..7622e71 --- /dev/null +++ b/ci/pytest @@ -0,0 +1,7 @@ +#!/bin/bash +set -eux + +# cd "$(git rev-parse --show-toplevel)" + +python3 -m pytest "$@" server/*.py +# TODO force it to collect server/setup diff --git a/server/ci.sh b/server/ci.sh deleted file mode 100755 index 29d7377..0000000 --- a/server/ci.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -eux -# TODO add to proper ci pipeline -pylint -E *.py setup - -mypy --check-untyped-defs *.py setup - -pytest -s org_tools.py diff --git a/server/grasp_server.py b/server/grasp_server.py index 961af52..2e5d5c0 100755 --- a/server/grasp_server.py +++ b/server/grasp_server.py @@ -58,7 +58,7 @@ def capture( tags: List[str] = [] if not empty(tag_str): - tags = re.split('[\s,]', tag_str) + tags = re.split(r'[\s,]', tag_str) tags = [t for t in tags if not empty(t)] # just in case org = as_org(