Skip to content
Snippets Groups Projects
Commit 635c3016 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
No related tags found
1 merge request!7NETID-238 Dockerize PHP NetID RPC
.env 0 → 100644
VERSION=2.3.1
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 ...@@ -90,42 +90,25 @@ You will need to run `phpdoc` at the root of the project in order to generate th
## Development Requirements ## 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 ## 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
``` ```
docker-compose build
### Building
At the root of the project, run the following command:
```bash
php phing.phar
``` ```
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 ## Testing
PHPUnit tests are located in `src/test`. To run the tests, at the root of the project, enter: PHPUnit tests are located in `src/test`. To run the tests, at the root of the project, enter:
```bash ```bash
php phpunit.phar docker-compose run --rm test
```
or:
```bash
php phing.phar test
``` ```
## Integration Testing ## Integration Testing
...@@ -133,13 +116,7 @@ php phing.phar test ...@@ -133,13 +116,7 @@ php phing.phar test
Integration with the MST NetID web service can be tested by running: Integration with the MST NetID web service can be tested by running:
```bash ```bash
php phpunit.phar --configuration phpunit-it.xml docker-compose run --rm integration-test
```
or:
```bash
php phing.phar 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`. 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 # # 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. 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`. 2. User has run `chmod +x release.sh`
3. The designated branch is checked out. 3. User has modified the version variable in the **.env** file. If a different branch is to be released, that is also specified
4. A tag is created with the name equal to the version number with no extra characters in the .env file.
5. The repository is pushed to origin with all tags. 4. User runs the following command: `./release.sh`
5. The designated branch is checked out.
6. A tag is created with the name equal to the version number with no extra characters
7. 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. 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"
echo Checking out branch $BRANCH...
git checkout $REMOTE/$BRANCH
echo Creating tag $VERSION...
git tag $VERSION
echo Pushing to remote $REMOTE...
git push $REMOTE $VERSION
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