Skip to content
Snippets Groups Projects
Commit 460142c3 authored by Matt Trefilek's avatar Matt Trefilek
Browse files

NETID-238 Dockerize PHP NetID RPC

Added in a DOCKERFILE and a docker-compose.yml which create environments to run unit and integration tests without any prerequisites (aside from docker) installed. Added a release script to release to the remote repository and an environment file to keep track of version locally.
parent 34429613
No related branches found
Tags 2.3.0
No related merge requests found
.env 0 → 100644
VERSION=2.2.4
BRANCH=master
REMOTE=upstream
\ No newline at end of file
FROM ubuntu:latest
RUN apt-get update && apt-get install php7.0 php7.0-xml php7.0-soap wget git -y
RUN wget http://pear.php.net/go-pear.phar && php go-pear.phar && pear install VersionControl_Git-alpha
ADD . /code
\ No newline at end of file
......@@ -90,42 +90,25 @@ You will need to run `phpdoc` at the root of the project in order to generate th
## Development Requirements
1. [phing](http://www.phing.info/)
1. docker [Installation](https://docs.docker.com/install/)
2. docker-compose [Installation](https://docs.docker.com/compose/install/)
## Developer Setup
### Vagrant
### Building the Docker Image
A vagrant file has been created for your convenience. This will install a Vagrant development virutal box with all the necessary build tools. Simply run at the project root:
If this is your first time running the PHP client or after any changes to the DOCKERFILE, run at the root of the project:
```bash
vagrant up
```
### Building
At the root of the project, run the following command:
```bash
php phing.phar
docker-compose build
```
This will retrieve dependencies and run PHPUnit.
**Note:** If you are not using Vagrant, you will need to [obtain Phing](https://www.phing.info/trac/wiki/Users/Installation). (I recommend downloading the Phar file to stay consistent with this documentation.)
## Testing
PHPUnit tests are located in `src/test`. To run the tests, at the root of the project, enter:
```bash
php phpunit.phar
```
or:
```bash
php phing.phar test
docker-compose up test
```
## Integration Testing
......@@ -133,13 +116,7 @@ php phing.phar test
Integration with the MST NetID web service can be tested by running:
```bash
php phpunit.phar --configuration phpunit-it.xml
```
or:
```bash
php phing.phar integration-test
docker-compose up integration-test
```
A valid client certificate is required to authenticate with Middleware's web service. Test data must be supplied in `src/test/resources/integration-test-data.ini`.
......
# Release Process #
1. User has cloned the [primary repository](https://git.doit.wisc.edu/adi-ia/rpc-netid-php/) and has write access to it.
2. User runs the following command: `php phing.phar release -Dversion=1.2.3 [-Dbranch=some-alternate-branch]` The branch argument is optional and defaults to `master`.
3. The designated branch is checked out.
4. A tag is created with the name equal to the version number with no extra characters
5. The repository is pushed to origin with all tags.
2. User has modified the version variable in the **.env** file. If a different branch is to be released, that is also specified
in the .env file.
3. User runs the following command: `docker-compose up release`
4. The designated branch is checked out.
5. A tag is created with the name equal to the version number with no extra characters
6. The repository is pushed to origin with all tags.
The end result is a new tag in the remote repository equal to the version number. Composer clients will now pick up on the new version number.
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "rpc-netid-php-dev"
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777","fmode=666"]
config.vm.provision "shell", inline: "apt-get update"
config.vm.provision "puppet" do |puppet|
end
config.vm.provider "virtualbox" do |v|
v.memory=1024
end
end
test:
build: .
command: bash -c "cd /code && wget -O phing.phar http://www.phing.info/get/phing-2.15.2.phar && php phing.phar test"
ports:
- "8000:8000"
volumes:
- .:/code
integration-test:
build: .
command: bash -c "cd /code && wget -O phing.phar http://www.phing.info/get/phing-2.15.2.phar && php phing.phar integration-test"
ports:
- "8000:8000"
volumes:
- .:/code
\ No newline at end of file
# Set path globally
Exec {
path => [ "/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin" ],
}
# Install phpunit
package { 'phpunit':
ensure => installed,
}
# Install XDebug
package { 'php5-xdebug':
ensure => installed,
}
# Download phing
exec { 'download-phing':
cwd => '/vagrant',
command => 'wget http://www.phing.info/get/phing-latest.phar -O phing.phar',
creates => '/vagrant/phing.phar'
}
#!/usr/bin/env bash
source ./.env
echo "Releasing version "$VERSION", the current state of branch "$BRANCH" on upstream"
git checkout $REMOTE/$BRANCH
git tag $VERSION
git push $REMOTE master
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment