From 9b78e90b57ff224e2620437fc85ab21891c5ff49 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Fri, 3 Dec 2021 16:46:00 +0100 Subject: [PATCH] Initial commit --- .dockerignore | 2 ++ .gitignore | 3 +++ .woodpecker.yml | 15 +++++++++++++++ Dockerfile | 12 ++++++++++++ README.md | 7 ++++++- composer.json | 12 ++++++++++++ hello | 7 +++++++ phpunit.xml | 26 ++++++++++++++++++++++++++ src/HelloApplication.php | 17 +++++++++++++++++ tests/HelloApplicationTest.php | 15 +++++++++++++++ 10 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 .woodpecker.yml create mode 100644 Dockerfile create mode 100644 composer.json create mode 100755 hello create mode 100644 phpunit.xml create mode 100644 src/HelloApplication.php create mode 100644 tests/HelloApplicationTest.php diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b69e77b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +/.* + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1183410 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/vendor/ +/.phpunit.cache/ + diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..60a3404 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,15 @@ +pipeline: + phpunit: + image: walkero/phpunit-alpine:php8.0-phpunit9 + commands: + - composer install + - phpunit + - echo -n "latest,1.0,1.0.0" > .tags + dockerbuild: + image: plugins/docker + settings: + repo: docker.noccylabs.info/pipeline-test + registry: docker.noccylabs.info + + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8dc1324 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM composer:latest + +FROM php:8.0-cli-alpine + +WORKDIR /application + +COPY . /application +COPY --from=0 /usr/bin/composer /usr/bin/composer +RUN composer install + +ENTRYPOINT /application/hello + diff --git a/README.md b/README.md index c30fe86..749d4c8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ # docker-pipeline-test -Test pipeline with gitea→woodpecker→docker registry \ No newline at end of file +This is a repository with an example application to test a custom docker pipeline +using Gitea, Woodpecker and a private registry. + +- Runs phpunit against the code +- Builds image from Dockerfile, tags the image and pushes to repo + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..17b115b --- /dev/null +++ b/composer.json @@ -0,0 +1,12 @@ +{ + "name": "noccy/docker-pipeline-test", + "description": "Pipeline test", + "type": "application", + "license": "MIT", + "require": {}, + "autoload": { + "psr-4": { + "Hello\\": "src/" + } + } +} diff --git a/hello b/hello new file mode 100755 index 0000000..fc2a8b6 --- /dev/null +++ b/hello @@ -0,0 +1,7 @@ +#!/usr/bin/env php +run(); diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..21d3ddc --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,26 @@ + + + + + tests + + + + + + src + + + diff --git a/src/HelloApplication.php b/src/HelloApplication.php new file mode 100644 index 0000000..1442807 --- /dev/null +++ b/src/HelloApplication.php @@ -0,0 +1,17 @@ +getMessage(); + } + + public function getMessage() + { + return "Hello World!\n"; + } +} + diff --git a/tests/HelloApplicationTest.php b/tests/HelloApplicationTest.php new file mode 100644 index 0000000..2737483 --- /dev/null +++ b/tests/HelloApplicationTest.php @@ -0,0 +1,15 @@ +assertEquals("Hello World!\n", $app->getMessage()); + } +}