castopod/.gitlab-ci.yml

109 lines
2.4 KiB
YAML

image: thecodingmachine/php:8.0-v4-fpm-node14
stages:
- prepare
- quality
- bundle
- release
cache:
paths:
- vendor/
- node_modules/
php-dependencies:
stage: prepare
script:
# Install all php dependencies
- php composer.phar install --prefer-dist --no-ansi --no-interaction --no-progress --ignore-platform-reqs
js-dependencies:
stage: prepare
script:
# Install all npm dependencies
- npm install
lint-commit-msg:
stage: quality
script:
- chmod +x ./scripts/lint-commit.sh
# lint commit message
- ./scripts/lint-commit.sh
tests:
stage: quality
before_script:
# Install required intl PHP extension for tests
- apt-get install -y libicu-dev
- docker-php-ext-install intl
script:
# run phpunit without code coverage
# TODO: add code coverage
- vendor/bin/phpunit --no-coverage
code-style:
stage: quality
script:
# check php code style
- vendor/bin/ecs check --ansi
static-analysis:
stage: quality
script:
# phpstan - increase memory limit to 1GB to prevent script failure
- php -d memory_limit=1G vendor/bin/phpstan analyse --ansi
code-review:
stage: quality
script:
# run rector to check for php errors
- vendor/bin/rector process --dry-run --ansi
lint-js:
stage: quality
script:
- npm run prettier
- npm run typecheck
- npm run eslint
- npm run stylelint
bundle:
stage: bundle
script:
# make scripts/bundle.sh executable
- chmod +x ./scripts/bundle-prepare.sh
- chmod +x ./scripts/bundle.sh
# bundle castopod-host with commit ref as version
- ./scripts/bundle-prepare.sh
- ./scripts/bundle.sh ${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}
artifacts:
name: "castopod-host-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}"
paths:
- castopod-host
except:
- main
- beta
- alpha
release:
stage: release
script:
# make release scripts executable
- chmod +x ./scripts/bundle-prepare.sh
- chmod +x ./scripts/bundle.sh
- chmod +x ./scripts/package.sh
# prepare bundle before release, both bundle and package scripts will be run by semantic-release
- ./scripts/bundle-prepare.sh
# IMPORTANT: delete local git tags before release to prevent eventual script failure (ie. tag already exists)
- git tag | xargs git tag -d
# run semantic-release script (configured in `.releaserc.json` file)
- npm run release
only:
- main
- alpha
- beta