-
Notifications
You must be signed in to change notification settings - Fork 121
/
.gitlab-ci.yml
103 lines (96 loc) · 2.58 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
91
92
93
94
95
96
97
98
99
100
101
102
103
stages:
- test
- build
- review
- cleanup
variables:
COMPOSER_HOME: /cache/composer
# The PF_PROJECT_ID is required.
# PF_PROJECT_ID:
PF_PARENT_ENV: main
PF_NO_CLONE_PARENT: 1 # CLI environments are stateless, so no need for data cloning
quick-tests:
stage: test
image: php:7.4-cli
before_script:
- apt-get update
- apt-get install zip unzip git lsof -y
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php
- mkdir -p /cache/composer/bin && chmod +x composer.phar && mv composer.phar /cache/composer/bin/composer
script:
- export PATH="/cache/composer/bin:$PATH"
# No Composer scripts, because Box isn't needed (and Box needs PHP 7.4).
- composer install --no-interaction --no-scripts
- scripts/test/unit.sh
- scripts/test/offline.sh
build:
stage: build
needs:
- quick-tests
image: php:7.4-cli
before_script:
- apt-get update
- apt-get install zip unzip
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php
- mkdir -p /cache/composer/bin && chmod +x composer.phar && mv composer.phar /cache/composer/bin/composer
script:
- export PATH="/cache/composer/bin:$PATH"
- composer install --no-dev --no-interaction
- |
cd vendor-bin/box
composer install --no-interaction
cd -
mkdir -p vendor/bin
ln -s "$(realpath vendor-bin/box/vendor/bin/box)" vendor/bin/box
- ./bin/platform self:build --no-composer-rebuild --yes --replace-version "$CI_COMMIT_REF_NAME"-"$CI_COMMIT_SHORT_SHA" --output platform.phar
artifacts:
expose_as: 'cli-phar'
paths: ['platform.phar']
push-review-env:
image: pjcdawkins/platformsh-cli
script:
- bash scripts/gitlab-ci/push-platform.sh
needs:
- quick-tests
stage: review
artifacts:
reports:
dotenv: environment.env # makes PRIMARY_URL available
environment:
name: review/$CI_COMMIT_REF_SLUG
url: $PRIMARY_URL
auto_stop_in: 7 day
on_stop: delete-review-env
only:
- branches
cleanup-review-envs:
image: pjcdawkins/platformsh-cli
script:
- bash scripts/gitlab-ci/cleanup-platform.sh
needs:
- push-review-env
stage: cleanup
allow_failure: true
only:
- branches
delete-review-env:
image: pjcdawkins/platformsh-cli
script:
- bash scripts/gitlab-ci/delete-platform.sh
stage: cleanup
when: manual
needs:
- push-review-env
environment:
name: review/$CI_COMMIT_REF_SLUG
action: stop
only:
- branches
except:
- 3.x
- 4.x
- 5.x
- main
- master