From b1a4580e411699925f66866b69b62e54ae06d121 Mon Sep 17 00:00:00 2001 From: DNickolay Date: Wed, 10 Jan 2024 06:42:41 +0300 Subject: [PATCH] gst --- .github/workflows/deploy.yml | 6 +++++ .github/workflows/test.yml | 30 +++++++++++++++++++++++ app/.env.example | 3 ++- app/composer.json | 2 ++ app/docker-compose.yml | 2 -- app/index.php | 47 ++++++++++++++++++++++++------------ app/tests/DefaultTest.php | 12 +++++++++ 7 files changed, 84 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 app/tests/DefaultTest.php diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 897f14034..a0345df87 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,6 +5,10 @@ on: branches: - NDybnov/hw21 +env: + COMMENT: 'my-comment-env' + APP_VERSION: 'v01100600' + jobs: deployment: runs-on: ubuntu-latest @@ -15,3 +19,5 @@ jobs: - name: deploy run: | echo '..deploy...' + echo ${{ env.APP_VERSION }} + echo ${{ env.COMMENT }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..86141a706 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: Test + +on: + push: + branches: + - NDybnov/hw21 + +env: + COMMENT: 'my-comment-env' + APP_VERSION: 'v01100600' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: | + docker compose build + docker compose up --detach + - uses: actions/checkout@v3 + - name: Copy .env + run: docker compose exec deploy-php-cli php -r "file_exists('.env') || copy('.env.example', '.env');" + #update values + - name: Install Dependencies + run: docker compose exec deploy-php-cli composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Execute tests (Unit and Feature tests) via PHPUnit + run: docker compose exec deploy-php-cli vendor/phpunit/phpunit/phpunit tests + - name: Test run vie Curl + run: docker compose exec deploy-php-cli curl 0.0.0.0:8000 diff --git a/app/.env.example b/app/.env.example index bdec6a882..c01891296 100644 --- a/app/.env.example +++ b/app/.env.example @@ -1,2 +1,3 @@ -APP_VERSION=3a4cdb6 OWN_NGINX_PORT=80 +APP_VERSION=123 +COMMENT='last comment' diff --git a/app/composer.json b/app/composer.json index 8bb769df5..6caf6d808 100644 --- a/app/composer.json +++ b/app/composer.json @@ -1,6 +1,8 @@ { "name": "hw/app-deploy", + "description": "nothing", "type": "project", + "license": "proprietary", "require": { "ndybnov-hw03/cnf-read": "^1.1" }, diff --git a/app/docker-compose.yml b/app/docker-compose.yml index 57d94c26c..33bacf409 100644 --- a/app/docker-compose.yml +++ b/app/docker-compose.yml @@ -2,7 +2,6 @@ version: '3' services: deploy-php-cli: -# image: php:8.3.1-cli-alpine build: context: ./.docker/php-cli/ dockerfile: Dockerfile @@ -12,4 +11,3 @@ services: - ./:/app ports: - ${OWN_NGINX_PORT}:8000 -# command: php -S 0.0.0.0:8000 -t /app diff --git a/app/index.php b/app/index.php index dde00f4b6..87060ec78 100644 --- a/app/index.php +++ b/app/index.php @@ -1,22 +1,39 @@ '; -print_r($_ENV); -echo '
'; -var_export($_SERVER); -echo '
'; +use NdybnovHw03\CnfRead\ConfigStorage; -print_r(getenv()); -echo '
'; -putenv('app_version=c3224e0'); +$config = (new ConfigStorage()) + ->fromDotEnvFile([__DIR__, '.env']); -echo '
'; +$version = $config->get('APP_VERSION'); +$comment = $config->get('COMMENT'); -print_r(getenv()); -echo '
'; +putenv('app_version=' . $version); +putenv('comment=' . $comment); + +$version = sprintf( + '%s:%s:%s', + PHP_VERSION, + getenv('app_version'), + getenv('comment'), +); +echo $version; + +var_dump($_ENV); + + +function dddddd(): int +{ + return 0; +} + + +class Dd { + public function ddd(): int + { + return 0; + } +} \ No newline at end of file diff --git a/app/tests/DefaultTest.php b/app/tests/DefaultTest.php new file mode 100644 index 000000000..1bb56aede --- /dev/null +++ b/app/tests/DefaultTest.php @@ -0,0 +1,12 @@ +assertTrue(true); + } +}