Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(jenkins): enable pipeline #8

Merged
merged 6 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env groovy

@Library('apm@current') _

pipeline {
agent { label 'linux && immutable' }
environment {
REPO = 'apm-agent-php'
BASE_DIR = "src/go.elastic.co/apm/${env.REPO}"
NOTIFY_TO = credentials('notify-to')
JOB_GCS_BUCKET = credentials('gcs-bucket')
}
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
timestamps()
ansiColor('xterm')
disableResume()
durabilityHint('PERFORMANCE_OPTIMIZED')
rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true])
quietPeriod(10)
}
triggers {
issueCommentTrigger('(?i).*jenkins\\W+run\\W+(?:the\\W+)?tests(?:\\W+please)?.*')
}
stages {
stage('Checkout') {
options { skipDefaultCheckout() }
steps {
deleteDir()
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true)
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
}
}
stage('Build') {
options { skipDefaultCheckout() }
steps {
withGithubNotify(context: 'Build') {
deleteDir()
unstash 'source'
dir("${BASE_DIR}"){
sh script: 'docker build --tag apm-agent-php .', label: 'prepare docker image'
sh script: 'docker run --rm -t -v $(pwd):/app apm-agent-php', label: 'run build'
}
}
}
}
stage('Test') {
options { skipDefaultCheckout() }
steps {
withGithubNotify(context: 'Test', tab: 'tests') {
deleteDir()
unstash 'source'
dir("${BASE_DIR}"){
sh script: 'docker run --rm -t -v $(pwd):/app apm-agent-php make test', label: 'run tests'
}
}
}
post {
always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/junit.xml")
}
}
}
stage('Install') {
options { skipDefaultCheckout() }
steps {
withGithubNotify(context: 'Install') {
deleteDir()
unstash 'source'
dir("${BASE_DIR}"){
sh script: 'docker run --rm -t -v $(pwd):/app apm-agent-php make install', label: 'run install'
}
}
}
}
}
post {
cleanup {
notifyBuildResult()
}
}
}
5 changes: 5 additions & 0 deletions .ci/jobs/apm-agent-php-mbp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- job:
name: apm-agent-php/apm-agent-php-mbp
display-name: APM Agent PHP
description: APM Agent PHP
4 changes: 4 additions & 0 deletions .ci/jobs/apm-agent-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- job:
name: apm-agent-php
project-type: folder
57 changes: 57 additions & 0 deletions .ci/jobs/defaults.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---

##### GLOBAL METADATA

- meta:
cluster: apm-ci

##### JOB DEFAULTS

- job:
view: APM-CI
project-type: multibranch
logrotate:
numToKeep: 100
concurrent: true
node: linux
script-path: .ci/Jenkinsfile
scm:
- github:
branch-discovery: no-pr
discover-pr-forks-strategy: merge-current
discover-pr-forks-trust: permission
discover-pr-origin: merge-current
discover-tags: true
notification-context: 'apm-ci'
repo: apm-agent-php
repo-owner: elastic
credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
ssh-checkout:
credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
build-strategies:
- tags:
ignore-tags-older-than: -1
ignore-tags-newer-than: -1
- regular-branches: true
- change-request:
ignore-target-only-changes: false
clean:
after: true
before: true
prune: true
shallow-clone: true
depth: 3
do-not-fetch-tags: true
submodule:
disable: false
recursive: true
parent-credentials: true
timeout: 100
timeout: '15'
use-author: true
wipe-workspace: 'True'
periodic-folder-trigger: 1d
prune-dead-branches: true
publishers:
- email:
recipients: infra-root+build@elastic.co
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.ci
.dockerignore
.git
.gitignore
docker
docs
Dockerfile
README.md
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
docker/wordpress/ephemeral/
docker/wordpress/data/ext
.DS_Store

junit.xml
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM wordpress:php7.3-fpm-alpine

RUN apk --no-cache add build-base autoconf curl-dev

WORKDIR /app/src/ext

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to copy the extension to /app/src/ext first in order compile "it" on L:7

COPY src/ext /app/src/ext

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required since this particular docker image is only for the environmental requirements.
The docker container should mount the volume and therefore the CMD directive will run those commands using the mounted volume.

ENV REPORT_EXIT_STATUS=1
ENV TEST_PHP_DETAILED=1
ENV NO_INTERACTION=1
ENV TEST_PHP_JUNIT=/app/junit.xml
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This env variable and the above ones are required when running the make test to help with:

  • More detailed info
  • Report the exit
  • Avoid interactive when a test failure to send an email to the PHP community
  • Generate junit output in a file to be consumed within the Jenkins pipeline.


CMD phpize \
&& ./configure --enable-elasticapm \
&& make clean \
&& make
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ line to `elasticapm.ini`:
extension=elasticapm.so
```

### Local development

If you don't want to install any of the dependencies you might need to compile and install the library then you can use the Dockerfile.


```bash
docker build --tag apm-agent-php .

## To compile the library
docker run --rm -ti -v $(pwd):/app apm-agent-php

## To test the Library
docker run --rm -ti -v $(pwd):/app apm-agent-php make test

## To install the library
docker run --rm -ti -v $(pwd):/app apm-agent-php make install
```

## Configure

You can configure the Elastic APM agent using the following ini settings for PHP:
Expand Down