-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
53 lines (48 loc) · 1.8 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
include:
- remote: https://devops.mtra.in/tpl/v3/base/php.yml
variables:
PHP_VERSION: '8.0'
test:
extends: .php-base
stage: test
before_script:
- php --ini
- echo "xdebug.mode=coverage" > /usr/local/etc/php/conf.d/xdebug.ini
script:
- php -v
- composer -V # Composer version 1.10.15 2020-10-13 15:59:09
- composer install --prefer-dist --no-ansi --no-interaction --no-progress
- if [[ -x "vendor/brianium/paratest/bin/paratest" ]]; then composer test -vv --parallel; fi
- if [[ ! -x "vendor/brianium/paratest/bin/paratest" ]]; then composer test -vv; fi
- if [[ -f "coverage/text-coverage.txt" ]]; then head -n10 coverage/text-coverage.txt; fi
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
junit: phpunit-report.xml
cache:
key: "$CI_COMMIT_REF_SLUG-composer"
paths:
- vendor/
policy: pull
# Publishes a tag/branch to Composer Packages of the current project
publish:
image: curlimages/curl:latest
stage: build
variables:
URL: "$CI_SERVER_PROTOCOL://$CI_SERVER_HOST:$CI_SERVER_PORT/api/v4/projects/$CI_PROJECT_ID/packages/composer?job_token=$CI_JOB_TOKEN"
script:
- version=$([[ -z "$CI_COMMIT_TAG" ]] && echo "branch=$CI_COMMIT_REF_NAME" || echo "tag=$CI_COMMIT_TAG")
- insecure=$([ "$CI_SERVER_PROTOCOL" = "http" ] && echo "--insecure" || echo "")
- response=$(curl -s -w "\n%{http_code}" $insecure --data $version $URL)
- code=$(echo "$response" | tail -n 1)
- body=$(echo "$response" | head -n 1)
# Output state information
- if [ $code -eq 201 ]; then
echo "Package created - Code $code - $body";
else
echo "Could not create package - Code $code - $body";
exit 1;
fi