Skip to content

Move validation test suite, phpstan to GitHub Workflows #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ tests/output
**/.*.swp
**/.*.swo
**/Dockerfile
ci/*_dockerized.sh
.dockerignore
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
# NOTE: If this is not quoted, the yaml parser will convert numbers such as 8.0 to the number 8,
# and the docker image `php:8` is the latest minor version of php 8.x (8.1).
- PHP_VERSION: '7.2'
STATIC_ANALYSIS: true
- PHP_VERSION: '7.3'
- PHP_VERSION: '7.4'
- PHP_VERSION: '8.0'
Expand All @@ -38,6 +39,13 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Clone submodules
- name: Checkout submodules for validation tests
run: git submodule update --init --recursive --depth 1

# Runs a single command using the runners shell
- name: Build and test in docker
run: bash ci/run_tests_dockerized.sh ${{ matrix.PHP_VERSION }}

- name: Run static analysis (PHP 7.2 only)
run: if [[ "${{ matrix.STATIC_ANALYSIS }}" == true ]]; then bash ci/run_phpstan_dockerized.sh ${{ matrix.PHP_VERSION }}; fi
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tolerant PHP Parser
[![Build Status](https://travis-ci.org/Microsoft/tolerant-php-parser.svg?branch=master)](https://travis-ci.org/Microsoft/tolerant-php-parser)
[![Build Status](https://github.com/microsoft/tolerant-php-parser/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/microsoft/tolerant-php-parser/actions/workflows/main.yml?query=branch%3Amain)

This is an early-stage PHP parser designed, from the beginning, for IDE usage scenarios (see [Design Goals](#design-goals) for more details). There is
still a ton of work to be done, so at this point, this repo mostly serves as
Expand Down
11 changes: 11 additions & 0 deletions ci/run_phpstan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
# -x Exit immediately if any command fails
# -e Echo all commands being executed.
# -u Fail for undefined variables
set -xeu
# This installs and runs phpstan
# TODO: Remove separate phpstan install step after https://github.com/microsoft/tolerant-php-parser/pull/385 is merged
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've merged 385 and removed a merge conflict with main, do you want to remove this now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This separate step can be removed now though right?

if [ ! -d vendor/phpstan/phpstan ]; then
composer.phar require --dev phpstan/phpstan=^1.8
fi
./vendor/bin/phpstan analyze
17 changes: 17 additions & 0 deletions ci/run_phpstan_dockerized.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
if [ $# != 1 ]; then
echo "Usage: $0 PHP_VERSION" 1>&2
echo "e.g. $0 8.0" 1>&2
echo "The PHP_VERSION is the version of the php docker image to use to run phpstan (static analysis)" 1>&2
exit 1
fi
# -x Exit immediately if any command fails
# -e Echo all commands being executed.
# -u fail for undefined variables
set -xeu
PHP_VERSION=$1

# This is the same image name, Dockerfile and build arguments as ci/run_tests_dockerized.sh
DOCKER_IMAGE="tolerant-php-parser-test-runner:$PHP_VERSION"
docker build --build-arg="PHP_VERSION=$PHP_VERSION" --tag="$DOCKER_IMAGE" -f ci/Dockerfile .
docker run --rm $DOCKER_IMAGE ci/run_phpstan.sh
1 change: 1 addition & 0 deletions ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ set -xe
php -d short_open_tag=0 ./vendor/bin/phpunit --testsuite invariants
php -d short_open_tag=0 ./vendor/bin/phpunit --testsuite grammar
php -d short_open_tag=0 ./vendor/bin/phpunit --testsuite api
php -d short_open_tag=0 ./vendor/bin/phpunit --testsuite validation
12 changes: 5 additions & 7 deletions ci/run_tests_dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ fi
# -u fail for undefined variables
set -xeu
PHP_VERSION=$1
COMPOSER_OPTIONS=""
# lexicographic comparison
if [ "$PHP_VERSION" > "8.1" ]; then
COMPOSER_OPTIONS="--ignore-platform-reqs"
fi

DOCKER_IMAGE="tolerant-php-parser-test-runner:$PHP_VERSION"
docker build --build-arg="PHP_VERSION=$PHP_VERSION" --build-arg="COMPOSER_OPTIONS=$COMPOSER_OPTIONS" --tag="$DOCKER_IMAGE" -f ci/Dockerfile .
docker run --rm $DOCKER_IMAGE ci/run_tests.sh
docker build --build-arg="PHP_VERSION=$PHP_VERSION" --tag="$DOCKER_IMAGE" -f ci/Dockerfile .
# Run all of the phpunit test suites in CI.
# - Add the validation folder as a read-only volume for running "phpunit --testsuite validation"
# (This is around 180MB, so it is not added to the docker image)
docker run --volume="$PWD/validation:/tolerant-php-parser/validation:ro" --rm $DOCKER_IMAGE ci/run_tests.sh
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"php": ">=7.2"
},
"require-dev": {
"phpunit/phpunit": "^8.5.15",
"phpunit/phpunit": "^8.5.36",
"phpstan/phpstan": "^1.8"
},
"license": "MIT",
Expand Down