Skip to content

Commit e1e8dc3

Browse files
committed
gitlab ci
1 parent c404b7f commit e1e8dc3

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

.gitlab-ci.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
cache:
2+
paths:
3+
- vendor/
4+
5+
stages:
6+
- test
7+
8+
test:7.2:
9+
stage: test
10+
image: php:7.2
11+
before_script:
12+
- bash ci/docker_install.sh > /dev/null
13+
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
14+
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
15+
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
16+
- php composer-setup.php
17+
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
18+
- php composer.phar install
19+
script:
20+
- phpunit --configuration phpunit.xml --coverage-text --colors=never
21+
22+
dependency_scanning:
23+
stage: test
24+
image: docker:stable
25+
variables:
26+
DOCKER_DRIVER: overlay2
27+
allow_failure: true
28+
services:
29+
- docker:stable-dind
30+
script:
31+
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
32+
- docker run
33+
--env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
34+
--volume "$PWD:/code"
35+
--volume /var/run/docker.sock:/var/run/docker.sock
36+
"registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
37+
artifacts:
38+
paths: [gl-dependency-scanning-report.json]
39+
except:
40+
variables:
41+
- $DEPENDENCY_SCANNING_DISABLED

ci/docker_install.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# We need to install dependencies only for Docker
4+
[[ ! -e /.dockerenv ]] && exit 0
5+
6+
set -xe
7+
8+
# Install git (the php image doesn't have it) which is required by composer
9+
apt-get update -yqq
10+
apt-get install git -yqq
11+
apt-get install wget -yqq
12+
13+
pecl install xdebug && docker-php-ext-enable xdebug
14+
15+
# Install phpunit, the tool that we will use for testing
16+
curl --location --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar
17+
chmod +x /usr/local/bin/phpunit

phpunit.xml

+5
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@
1414
<directory suffix=".php">./tests/</directory>
1515
</testsuite>
1616
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory suffix=".php">./src</directory>
20+
</whitelist>
21+
</filter>
1722
</phpunit>

0 commit comments

Comments
 (0)