From ca232364599c56c766967f4cad3532d5208248d0 Mon Sep 17 00:00:00 2001 From: "Jason M. Gates" Date: Wed, 22 Sep 2021 16:46:52 -0600 Subject: [PATCH] Replace cache with artifacts It seems storing the virtual environment in the cache was causing non-deterministic problems with `shelllogger` sometimes not existing in the environment after it was installed. Hopefully using artifacts instead of the cache will solve the problem. --- .gitlab-ci.yml | 54 ++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f0097b..c830e67 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,16 +3,6 @@ # https://docs.gitlab.com/ee/ci/yaml/. -# Set up a global cache to pass information across stages. -cache: &global_cache - key: "${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}" - paths: - - doc/html/ - - tests/htmlcov/ - - venv-clean-python/ - policy: pull-push - - # Set up the pipeline stages. stages: - prepare @@ -31,10 +21,10 @@ before_script: ${LSB_RELEASE} -a fi - |- - if [ -d "venv-clean-python" ]; then - source venv-clean-python/bin/activate + if [ -d "shelllogger-venv" ]; then + source shelllogger-venv/bin/activate else - echo "Virtual Environment 'venv-clean-python' was not found" + echo "Virtual Environment 'shelllogger-venv' was not found" exit 1 fi echo "-----" @@ -55,20 +45,16 @@ after_script: #----------------------------------------------------------------------- -# Create the virtual environment, install the requirements, and save the -# environment to the cache. +# Create the virtual environment and install the requirements. install requirements: stage: prepare timeout: 10m before_script: - - python3 -m venv venv-clean-python - cache: - <<: *global_cache - when: on_success + - python3 -m venv shelllogger-venv script: # Activate the virtual environment. - - source venv-clean-python/bin/activate + - source shelllogger-venv/bin/activate # Ensure `pip` is up-to-date. - python3 -m pip install --upgrade pip @@ -81,6 +67,9 @@ install requirements: -r requirements.txt -r tests/requirements.txt -r doc/requirements.txt + artifacts: + paths: + - shelllogger-venv #----------------------------------------------------------------------- @@ -93,13 +82,9 @@ build distribution: stage: install needs: ["install requirements"] timeout: 5m - cache: - <<: *global_cache - policy: pull script: - python3 -m pip wheel --no-deps -w dist . artifacts: - name: "shelllogger-dist" paths: - dist/shelllogger*.whl expire_in: 6 weeks @@ -110,10 +95,11 @@ install package: stage: install needs: ["install requirements"] timeout: 5m - cache: - <<: *global_cache script: - python3 -m pip install . + artifacts: + paths: + - shelllogger-venv #----------------------------------------------------------------------- @@ -126,8 +112,6 @@ pytest: stage: test needs: ["install requirements"] timeout: 5m - cache: - <<: *global_cache script: - python3 -m pytest --cov=src.shelllogger @@ -151,11 +135,9 @@ flake8: stage: test needs: ["install requirements"] timeout: 5m - cache: - <<: *global_cache script: - python3 -m flake8 - --exclude=venv-clean-python + --exclude=shelllogger-venv # Ensure the examples run without problems. @@ -163,9 +145,6 @@ examples: stage: test needs: ["install requirements", "install package"] timeout: 5m - cache: - <<: *global_cache - policy: pull script: - cd examples - python3 -m pip list @@ -188,8 +167,6 @@ sphinx: stage: documentation needs: ["install requirements", "install package"] timeout: 5m - cache: - <<: *global_cache script: - cd doc - bash make_html_docs.sh @@ -208,9 +185,6 @@ pages: stage: deploy needs: ["pytest", "sphinx"] timeout: 5m - cache: - <<: *global_cache - policy: pull rules: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' script: @@ -231,7 +205,5 @@ pages: uninstall package: stage: finish timeout: 5m - cache: - <<: *global_cache script: - python3 -m pip uninstall -y shelllogger