-
Notifications
You must be signed in to change notification settings - Fork 50
/
.gitlab-ci.yml
executable file
·90 lines (82 loc) · 3.41 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
stages:
- containerize
- install
- validate
- build
- test
- release
- build production
- deploy
image: $CI_REGISTRY_IMAGE/gitlab-ci:$CI_COMMIT_REF_SLUG
variables:
# Prefix created compose services so we can act on them (volumes, network, not container because they are named by container_name), should be same as package.json name
# Also consider that all docker relevant prefixes should also contain the CI_COMMIT_REF_SLUG environment variable
COMPOSE_PROJECT_NAME: wp-reactjs-multi-starter
# Define cache folders for yarn and cypress so they can be cached
CYPRESS_CACHE_FOLDER: $CI_PROJECT_DIR/.cypress
YARN_CACHE_FOLDER: $CI_PROJECT_DIR/.yarn
COMPOSER_HOME: $CI_PROJECT_DIR/.composer
# This is set to 1 by your project variables so jobs like E2E and review apps gets activated. Currently I do not know another way to detect that, feel free to contribute...
# DOCKER_DAEMON_ALLOW_UP: 1
# Additional settings
DOCKER_DRIVER: overlay2
JOB_PACKAGE_FOLDER: plugins
LERNA_SKIP_MESSAGE: Lerna detected no change in this package, skip it...
GL_TOKEN: $GITLAB_TOKEN
# Allow git interactions (e. g. lerna version & publish)
GIT_AUTHOR_NAME: $GITLAB_USER_NAME
GIT_AUTHOR_EMAIL: $GITLAB_USER_EMAIL
GIT_COMMITTER_NAME: $GITLAB_USER_NAME
GIT_COMMITTER_EMAIL: $GITLAB_USER_EMAIL
# Cache installation of yarn, cypress and co
cache: &cache # see https://gitlab.com/gitlab-org/gitlab-runner/issues/2838#note_95134689
key: "$CI_COMMIT_REF_SLUG"
untracked: true
policy: pull # As we have an install job, all next steps do not need to push again
paths:
- .yarn/
- .cypress/
- .composer/
- node_modules/
- plugins/*/node_modules/*
- plugins/*/vendor/*
- packages/*/node_modules/*
- packages/*/vendor/*
# Install all needed node and composer modules as extendable job
.install:
before_script:
# Set composer github token to avoid API rate limit (https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens)
- test $PHP_COMPOSER_GITHUB_TOKEN && composer config -g github-oauth.github.com $PHP_COMPOSER_GITHUB_TOKEN
# Make sure all dependencies are installed correctly
- yarn bootstrap
# Make sure cypress is installed correctly
- test $DOCKER_DAEMON_ALLOW_UP && yarn cypress install
# Run a job only in production branch
.only production:
only:
refs: [master]
# Only go on with the job if lerna detected changes
.lerna changes:
before_script:
- "[ ! -f $JOB_PACKAGE_FOLDER/$JOB_PACKAGE_NAME/.publish ] && [ ! $LERNA_CHANGES_FORCE ] && echo $LERNA_SKIP_MESSAGE && exit 0"
# Initial installation so the cache gets filled
install:
extends: .install
stage: install
cache:
<<: *cache
policy: pull-push
script:
- echo Installation done, make cache for the next jobs...
include:
- /devops/.gitlab/stage-containerize.yml
- /devops/.gitlab/stage-validate.yml
- /devops/.gitlab/stage-build.yml
- /devops/.gitlab/stage-test.yml
- /devops/.gitlab/stage-release.yml
- /packages/utils/devops/.gitlab/.gitlab-ci.yml
# Below you will se a custom "anchor".
# Do not remove that because it is used in `create-wp-react-app create-plugin`
# create-wp-react-app -->
- /plugins/wp-reactjs-starter/devops/.gitlab/.gitlab-ci.yml
# <-- create-wp-react-app