Skip to content
Snippets Groups Projects
Commit e7eada25 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

adjust caching, fixes #2200

Closes #2200

Merge request studip/studip!1793
parent 1de91f34
No related branches found
No related tags found
No related merge requests found
...@@ -20,14 +20,16 @@ variables: ...@@ -20,14 +20,16 @@ variables:
# Directories # Directories
CACHE_DIR: .caches CACHE_DIR: .caches
REPORT_DIR: .reports REPORT_DIR: .reports
# Set npm cache directory
npm_config_cache: $CI_PROJECT_DIR/.npm
stages: stages:
- build
- checks - checks
- analyse - analyse
- test - test
- packaging - packaging
- release - release
- build
.scripts: .scripts:
mkdir-caches: &mkdir-caches mkdir-caches: &mkdir-caches
...@@ -47,38 +49,60 @@ stages: ...@@ -47,38 +49,60 @@ stages:
- cli/studip migrate - cli/studip migrate
.caches: .caches:
php: &composer-cache composer: &composer-cache
key: "php-$CI_COMMIT_REF_SLUG" key:
files:
- composer.lock
paths: paths:
- composer/ - composer/
- $CACHE_DIR/phplint-cache policy: pull
- $CACHE_DIR/resultCache.php npm: &npm-cache
- $CACHE_DIR/cache/* key:
- $CACHE_DIR/resultCaches/* files:
js: &npm-cache - package-lock.json
key: "js-$CI_COMMIT_REF_SLUG"
paths: paths:
- node_modules/ - .npm
- $CACHE_DIR/eslint-cache
- $CACHE_DIR/stylelint-cache build-composer:
stage: build
needs: []
interruptible: true
variables:
COMPOSER_CACHE: $CACHE_DIR/composer-cache
before_script:
- mkdir -p $COMPOSER_CACHE
script:
- composer install
cache:
- *composer-cache
- key: composer-package-cache
paths:
- $COMPOSER_CACHE
policy: pull-push
lint-php: lint-php:
stage: checks stage: checks
needs: [] needs: [build-composer]
cache: *composer-cache
variables: variables:
CACHE_LOCATION: $CACHE_DIR/phplint-cache
PHPLINT_JSON_REPORT: $REPORT_DIR/phplint-report.json PHPLINT_JSON_REPORT: $REPORT_DIR/phplint-report.json
PHPLINT_CODE_QUALITY_REPORT: $REPORT_DIR/phplint-codequality.json PHPLINT_CODE_QUALITY_REPORT: $REPORT_DIR/phplint-codequality.json
interruptible: true interruptible: true
cache:
- *composer-cache
- key: "$CI_JOB_NAME_SLUG:$CI_COMMIT_REF_SLUG"
paths:
- $CACHE_LOCATION
before_script: before_script:
- *mkdir-caches - *mkdir-caches
- *mkdir-reports - *mkdir-reports
- *install-composer - *install-composer
script: script:
- php -d memory_limit=-1 - COMPOSER_MEMORY_LIMIT=-1
composer/bin/phplint composer exec phplint
--
--json $PHPLINT_JSON_REPORT --json $PHPLINT_JSON_REPORT
--cache=$CACHE_DIR/phplint-cache --cache=$CACHE_LOCATION
after_script: after_script:
- ./.gitlab/scripts/convert-phplint-report $PHPLINT_JSON_REPORT > $PHPLINT_CODE_QUALITY_REPORT - ./.gitlab/scripts/convert-phplint-report $PHPLINT_JSON_REPORT > $PHPLINT_CODE_QUALITY_REPORT
artifacts: artifacts:
...@@ -90,7 +114,12 @@ lint-js: ...@@ -90,7 +114,12 @@ lint-js:
needs: [] needs: []
image: $NODE_IMAGE image: $NODE_IMAGE
variables: variables:
CACHE_LOCATION: $CACHE_DIR/eslint-cache
ESLINT_CODE_QUALITY_REPORT: $REPORT_DIR/eslint-codequality.json ESLINT_CODE_QUALITY_REPORT: $REPORT_DIR/eslint-codequality.json
cache:
- key: "$CI_JOB_NAME_SLUG:$CI_COMMIT_REF_SLUG"
paths:
- $CACHE_LOCATION
interruptible: true interruptible: true
before_script: before_script:
- *mkdir-reports - *mkdir-reports
...@@ -101,6 +130,7 @@ lint-js: ...@@ -101,6 +130,7 @@ lint-js:
script: script:
- npx eslint - npx eslint
--ext .js,.vue --ext .js,.vue
--cache --cache-location $CACHE_LOCATION
--format gitlab --format gitlab
resources/assets/javascripts resources/vue resources/assets/javascripts resources/vue
artifacts: artifacts:
...@@ -112,8 +142,13 @@ lint-css: ...@@ -112,8 +142,13 @@ lint-css:
needs: [] needs: []
image: $NODE_IMAGE image: $NODE_IMAGE
variables: variables:
CACHE_LOCATION: $CACHE_DIR/stylelint-cache
STYLELINT_CODE_QUALITY_REPORT: $REPORT_DIR/stylelint-codequality.json STYLELINT_CODE_QUALITY_REPORT: $REPORT_DIR/stylelint-codequality.json
interruptible: true interruptible: true
cache:
- key: "$CI_JOB_NAME_SLUG:CI_COMMIT_REF_SLUG"
paths:
- $CACHE_LOCATION
before_script: before_script:
- *mkdir-reports - *mkdir-reports
- npm install - npm install
...@@ -125,7 +160,9 @@ lint-css: ...@@ -125,7 +160,9 @@ lint-css:
script: script:
- npx - npx
stylelint stylelint
--cache --cache-location $CACHE_LOCATION
--custom-formatter=node_modules/stylelint-formatter-gitlab --custom-formatter=node_modules/stylelint-formatter-gitlab
--output-file $STYLELINT_CODE_QUALITY_REPORT
resources/assets/stylesheets resources/assets/stylesheets
artifacts: artifacts:
reports: reports:
...@@ -133,16 +170,23 @@ lint-css: ...@@ -133,16 +170,23 @@ lint-css:
phpstan: phpstan:
stage: analyse stage: analyse
needs: [lint-php] needs: [build-composer]
variables: variables:
CACHE_LOCATION: $CACHE_DIR/phpstan
PHPSTAN_CODE_QUALITY_REPORT: $REPORT_DIR/phpstan-codequality.json PHPSTAN_CODE_QUALITY_REPORT: $REPORT_DIR/phpstan-codequality.json
allow_failure: true allow_failure: true
interruptible: true interruptible: true
when: manual when: manual
cache: *composer-cache cache:
- *composer-cache
- key: "$CO_JOB_NAME_SLUG:$CI_COMMIT_REF_SLUG"
paths:
- $CACHE_LOCATION
before_script: before_script:
- *mkdir-caches
- *mkdir-reports - *mkdir-reports
- *install-composer - *install-composer
- 'echo "includes:\n - phpstan.neon.dist\n\nparameters:\n tmpDir: $PHPSTAN_CACHE_PATH" > phpstan.neon'
script: script:
- php - php
composer/bin/phpstan analyse composer/bin/phpstan analyse
...@@ -150,6 +194,8 @@ phpstan: ...@@ -150,6 +194,8 @@ phpstan:
--no-progress --no-progress
--level=$PHPSTAN_LEVEL --level=$PHPSTAN_LEVEL
--error-format=gitlab > $PHPSTAN_CODE_QUALITY_REPORT --error-format=gitlab > $PHPSTAN_CODE_QUALITY_REPORT
after_script:
- rm phpstan.neon
artifacts: artifacts:
reports: reports:
codequality: $PHPSTAN_CODE_QUALITY_REPORT codequality: $PHPSTAN_CODE_QUALITY_REPORT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment