Created
March 10, 2016 06:52
-
-
Save bradjones1/eb236dcef07bb73a17d2 to your computer and use it in GitHub Desktop.
GitLab CI yml for containerized Docker testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- test | |
- spawn | |
- phpunit | |
- deploy | |
- cleanup | |
build_image: | |
cache: | |
untracked: true | |
script: | |
- whoami && docker info && docker-compose -v | |
- if [[ -n "$GITHUB_API_KEY" ]]; then composer config -g github-oauth.github.com "$GITHUB_API_KEY"; fi | |
- composer install --ignore-platform-reqs | |
- docker-compose -f docker-compose.ci.yml build | |
spawn_containers: | |
stage: spawn | |
script: | |
- docker-compose -f docker-compose.ci.yml up -d | |
unit_test: | |
stage: phpunit | |
script: | |
- docker exec -t $(docker-compose -f docker-compose.ci.yml ps -q web) | |
su -c '~www-data/html/tests/scripts/unit-testing.sh' -s /bin/bash www-data | |
deploy: | |
stage: deploy | |
only: | |
- master | |
script: | |
- docker build -t "$DEPLOY_SERVER"/"$DEPLOY_REPO" . | |
- docker login --username="${DEPLOY_USER}" --password="${DEPLOY_PASS}" [email protected] "$DEPLOY_SERVER" | |
- docker push "$DEPLOY_SERVER"/"$DEPLOY_REPO" | |
- docker rmi "$DEPLOY_SERVER"/"$DEPLOY_REPO" | |
cleanup: | |
stage: cleanup | |
when: always | |
script: | |
- docker-compose -f docker-compose.ci.yml down | |
- composer config -g --unset github-oauth.github.com | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment