Skip to content

Commit

Permalink
Enhancement: Run end-to-end test asserting HTTP response status code
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 15, 2023
1 parent b95f3e7 commit bd9fde7
Show file tree
Hide file tree
Showing 7 changed files with 873 additions and 6 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "none, json, mbstring, tokenizer"
extensions: "none, curl, json, mbstring, tokenizer"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand Down Expand Up @@ -64,6 +64,9 @@ jobs:
php-version:
- "8.2"

env:
HTTP_HOST: "localhost:8080"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"
Expand All @@ -72,11 +75,30 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "none"
extensions: "none, curl, mbstring, tokenizer"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""

- name: "Validate composer.json and composer.lock"
run: "composer validate --ansi --strict"

- name: "Determine composer cache directory"
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v3"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-"

- name: "Install dependencies with composer"
run: "composer install --ansi --no-interaction --no-progress"

- name: "Start built-in web server for PHP"
run: "php -S ${{ env.HTTP_HOST }} .router.php &"

- name: "Run tests"
run: "php tests/run-tests.php -j3 -q --show-diff"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ vendor/
.idea
.DS_Store
.DS_Store?
tests/server.log
tests/server.pid
.php-cs-fixer.cache
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.EXPORT_ALL_VARIABLES:

HTTP_HOST:=localhost:8080

.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
Expand All @@ -7,8 +11,8 @@ coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fix
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose

.PHONY: tests
tests: ## Runs tests
php tests/run-tests.php -j3 -q
tests: vendor ## Runs tests
tests/server start; php tests/run-tests.php -j3 -q; tests/server stop

vendor: composer.json composer.lock
composer validate --strict
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"php": "~8.2.0"
},
"require-dev": {
"ext-curl": "*",
"friendsofphp/php-cs-fixer": "^3.40.2"
},
"autoload": {
Expand Down
6 changes: 4 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bd9fde7

Please sign in to comment.