Commit 3b204a90 authored by Antoine's avatar Antoine
Browse files

[CI] Cache pip and apt dependencies, and ensure they are installed before running the test stage.

parent 88e808f2
Pipeline #215074 failed with stages
in 5 minutes and 49 seconds
......@@ -2,16 +2,27 @@
# and readable through email notifications.
image: node:12
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
APT_CACHE_DIR: "$CI_PROJECT_DIR/apt-cache"
cache: &global_cache
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- yarn.lock
- .cache/pip
- apt-cache/
- venv
- weboob
policy: pull-push
stages:
- lint # Check code syntax and coding style.
- build # Try to build Kresus code.
- install_deps # Install weboob.
- test # Run unit tests.
# Lint and check last commit in a dedicated task.
......@@ -38,59 +49,46 @@ build:
<<: *global_cache
policy: pull
# Run tests.
test:
stage: test
before_script:
install_deps:
stage: install_deps
script:
- yarn install
- mkdir -p apt-cache
- apt-get update && apt-get install -o dir::cache::archives=$APT_CACHE_DIR -y python3-pip python3-lxml python3-dev python3-yaml locales python3-virtualenv
- update-alternatives --install /usr/bin/python python $(which python3) 1
- pip3 install --upgrade pip
# Install weboob.
- apt-get update && apt-get install -y python3-pip python3-lxml python3-dev python3-yaml locales
- echo "en_US UTF-8" > /etc/locale.gen
- locale-gen C.UTF-8 && update-locale C.UTF-8
- export LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
- mkdir ./weboob
# Fix for outdated pip and setuptools.
- pip3 install --upgrade requests
- pip3 install weboob --target=./weboob
- rm -r ./weboob
- mkdir -p ./weboob
- pip3 install -t ./weboob weboob
# Create a virtualenv to cache installed modules.
- rm -r ./venv
- python -m virtualenv -p /usr/bin/python3 venv
- source venv/bin/activate
- pip3 install pylint
# Run tests.
test:
stage: test
script:
# Lint Python code.
- KRESUS_WEBOOB_DIR=./weboob yarn run --silent check:python
# Run the CI test suite without weboob installed.
- yarn run --silent check:test
- source venv/bin/activate
# Lint Python code.
- KRESUS_WEBOOB_DIR=./weboob yarn run --silent check:python
# Run the CI test suite again with weboob installed.
- KRESUS_WEBOOB_DIR=./weboob yarn run --silent check:test
cache:
<<: *global_cache
policy: pull
policy: pull
# Also ensure all the commits in the MR individually pass the tests and checks.
# This is done in this testing stage to fail as soon as possible the CI if
# there is an error in the last commit.
lint_history:
stage: test
before_script:
# Install JS deps
- yarn install
# Give it a Git identity for the rebase to work.
- git config --global user.email "gitlab-ci@kresus.org"
- git config --global user.name "Gitlab CI"
# Abort any rebase in progress.
- git rebase --abort 2> /dev/null || true
# Abort any merge in progress.
- git merge --abort 2> /dev/null || true
# Install weboob.
- update-alternatives --install /usr/bin/python python $(which python3) 1
- apt-get update && apt-get install -y python3-pip python3-lxml python3-dev python3-yaml locales
- echo "en_US UTF-8" > /etc/locale.gen
- locale-gen C.UTF-8 && update-locale C.UTF-8
- export LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
- mkdir ./weboob
- pip3 install requests
- pip3 install weboob --target=./weboob
script:
- source venv/bin/activate
- yarn run --silent check:full-history
cache:
<<: *global_cache
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment