]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
ci: changed the way CI works
authorVasek Sraier <git@vakabus.cz>
Thu, 22 Apr 2021 17:55:39 +0000 (19:55 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 8 Apr 2022 14:17:52 +0000 (16:17 +0200)
Squashed commit of the following:

commit b439b895b4ea18fc63124fb66b55b439f7b10fef
Author: Vasek Sraier <git@vakabus.cz>
Date:   Thu Apr 22 19:47:48 2021 +0200

    ci: npm global install in dev container

commit c3a896269b222a8d23af54910ed2fe98193fa496
Author: Vasek Sraier <git@vakabus.cz>
Date:   Thu Apr 22 19:12:12 2021 +0200

    ci: installing npm dependencies globally

commit 473fbf4878c40f859b4bb2eb25c9ccd2ac5a427d
Author: Vasek Sraier <git@vakabus.cz>
Date:   Thu Apr 22 18:56:57 2021 +0200

    scripts: virtual env or ci detection

commit fcf1d0e8035825fc1bd236b9c84bf792198c2aab
Author: Vasek Sraier <git@vakabus.cz>
Date:   Thu Apr 22 18:48:41 2021 +0200

    scripts: fixed bash options

commit aa96cf925ac0cd6ad36b89f011e449006dd6d8e9
Author: Vasek Sraier <git@vakabus.cz>
Date:   Thu Apr 22 18:45:49 2021 +0200

    ci: updated check stage definition

commit 40a00e1261cf51c8a15e237e73d9a1dd2ffd3e61
Author: Vasek Sraier <git@vakabus.cz>
Date:   Thu Apr 22 18:33:51 2021 +0200

    ci: fix dev container definition

commit ccedf3e18aead5097bec11384c2fd08c783129cd
Author: Vasek Sraier <git@vakabus.cz>
Date:   Thu Apr 22 18:30:37 2021 +0200

    ci: fixed typo in .gitlab-ci.yml

commit eaada4a0cfe1282fd90af838f6d2dade0129c47e
Author: Vasek Sraier <git@vakabus.cz>
Date:   Thu Apr 22 18:06:39 2021 +0200

    ci: use different container and always build it

manager/.gitlab-ci.yml
manager/README.md
manager/containers/dev/Containerfile
manager/pyproject.toml
manager/scripts/_env.sh
manager/scripts/codecheck

index f427e0b1ee32a77754c0d74819821c4f70ead453..fe80186536503ef068aa6a478078ed86003b0a16 100644 (file)
@@ -13,7 +13,6 @@ image: registry.nic.cz/knot/knot-resolver-manager/devenv:latest
 build:
   image: docker:20-dind
   stage: image
-  when: manual
   tags:
     - dind
   variables:
@@ -22,23 +21,16 @@ build:
     - docker info
   script:
     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
-    - docker build -t $IMAGE_TAG ci/devenv
+    - docker build -t $IMAGE_TAG -f containers/dev/Containerfile .
     - docker push $IMAGE_TAG
 
 
-# agressively cache Poetry's and NPM's data
-cache:
-  key: "always-the-same-cache"
-  paths:
-    - node_modules/
-    - .venv/
-  policy: pull-push
-
 lint:
   stage: check
   script:
-    # run the actual tests
-    - poetry env use $(pyenv which python)
-    - poetry install
-    - npm install
-    - ./poe check
+    - poe check
+
+test:
+  stage: check
+  script:
+    - poe test
index 06ee147bb483cd6527cf2f2b638c6a797a71c08f..5cde56cf903fd2651f2d8a6f1dca642012523dcf 100644 (file)
@@ -23,7 +23,7 @@ pyenv install 3.8.7
 pyenv install 3.9.1
 poetry env use $(pyenv which python)
 poetry install
-yarn install # or "npm install"
+npm install # or "yarn install"
 ```
 
 With this environment, **everything else should just work**. You can run the same checks the CI runs, all commands listed bellow should pass.
index d29d7e6af6cb09de7bc5f3ebaff63c8caee5a8dc..9bbd9b8dfbf11aae10a6fc2227ee162f8506e41d 100644 (file)
@@ -52,7 +52,6 @@ RUN apt-get update \
   && echo "deb https://deb.nodesource.com/$NODE_VERSION $(lsb_release -s -c) main" | tee /etc/apt/sources.list.d/nodesource.list \
   && echo "deb-src https://deb.nodesource.com/$NODE_VERSION $(lsb_release -s -c) main" | tee -a /etc/apt/sources.list.d/nodesource.list \
   && apt-get update && apt-get install --no-install-recommends --no-install-suggests -y nodejs \
-  && npm install -g yarn \
   # Installing `poetry` package manager:
   # https://github.com/python-poetry/poetry
   && curl -sSL 'https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py' | python \
@@ -70,7 +69,7 @@ COPY ./config/knot-resolver-manager.service /etc/systemd/system
 COPY ./config/kres-manager.yaml /etc/knot-resolver
 
 # Copy only requirements, to cache them in docker layer
-COPY ./poetry.lock ./pyproject.toml ./yarn.lock ./package.json /code/
+COPY ./poetry.lock ./pyproject.toml ./package.json /code/
 
 WORKDIR /code
 
@@ -79,7 +78,8 @@ RUN echo "Running in $KNOT_ENV" \
   && poetry install \
     $(if [ "$KNOT_ENV" != 'dev' ]; then echo '--no-dev'; fi) \
     --no-interaction --no-ansi \
-  && if test "$KNOT_ENV" = "dev"; then yarn install; fi
+  && if test "$KNOT_ENV" = "dev"; then \
+   npm install -g $(python -c "import json; print(*(k for k in json.loads(open('package.json').read())['dependencies']))"); fi
 
 # Here, we would copy the remaining code if we wanted to permanently keep it in the container. We don't do that, we use read-only bind mounts
 # COPY . /code
index 598a40189e7c30ab4d38ce78929ebdfce9f0e338..63aceecabfd75c15c603a8dcd98d05196c68672e 100644 (file)
@@ -39,7 +39,7 @@ run-debug = { cmd = "scripts/run-debug", help = "Run the manager under debugger"
 test = { cmd = "pytest --cov=knot_resolver_manager --show-capture=all tests/", help = "Run tests" }
 check = { cmd = "scripts/codecheck", help = "Run static code analysis" }
 format = { shell = "poetry run black knot_resolver_manager/ tests/; isort -rc .", help = "Run code formatter" }
-fixdeps = { shell = "poetry install; yarn install", help = "Install/update dependencies according to configuration files"}
+fixdeps = { shell = "poetry install; npm install", help = "Install/update dependencies according to configuration files"}
 commit = { shell = "scripts/commit", help = "Invoke every single check before commiting" }
 container-build = { cmd = "scripts/container-build", help = "Build containers (no arguments = all, otherwise arguments are tags that should be built)" }
 container-run = { cmd = "scripts/container-run.py", help = "Run a container" }
index 3bcbf4e46de3dffabb2790c925910d83003dd313..f5ec18abbbf956cc6b796384e1db407391e596f3 100644 (file)
@@ -1,5 +1,5 @@
 # fail on errors
-set -o errexit -o nounset
+set -o errexit
 
 # define color codes
 red="\033[0;31m"
@@ -17,7 +17,7 @@ fi
 cd $gitroot
 
 # ensure consistent environment with virtualenv
-if test -z "$VIRTUAL_ENV"; then
+if test -z "$VIRTUAL_ENV" -a "$CI" != "true"; then
        echo -e "${yellow}You are NOT running the script within the project's virtual environment.${reset}"
        echo -e "Do you want to continue regardless? [yN]"
        read cont
@@ -25,4 +25,10 @@ if test -z "$VIRTUAL_ENV"; then
                echo -e "${red}Exiting early...${reset}"
                exit 1
        fi
-fi
\ No newline at end of file
+fi
+
+# update PATH with node_modules
+PATH="$PATH:$gitroot/node_modules/.bin"
+
+# fail even on unbound variables
+set -o nounset
\ No newline at end of file
index 882bee8741e58515c2aeb267580cadd9eb511e97..883e9dd9f01d6113d295785cd8ace2180f6ea805 100755 (executable)
@@ -36,7 +36,7 @@ echo
 
 # check types with pyright
 echo -e "${yellow}Type checking using pyright...${reset}"
-node_modules/.bin/pyright knot_resolver_manager
+pyright knot_resolver_manager
 check_rv $?
 echo