Skip to content

Commit 89f263b

Browse files
committed
Move validation test suite, phpstan to GitHub Workflows
- Perform a shallow clone of submodules analyzed in validation test suite in GitHub workflows (should take around 30 seconds) - Switch badge in README.md to GitHub Workflows and update default branch for badge. - Remove travis config - After #385 is merged run_phpstan.sh can remove the separate install step (as a followup PR) - Require a newer phpunit patch version in devDependencies Make it harder for contributors to have any inconsistencies with CI when running tests (e.g. php version support, fixed phpunit bugs, etc)
1 parent 3eccfd2 commit 89f263b

9 files changed

+46
-55
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ tests/output
1313
**/.*.swp
1414
**/.*.swo
1515
**/Dockerfile
16+
ci/*_dockerized.sh
1617
.dockerignore

.github/workflows/main.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,25 @@ jobs:
2727
# NOTE: If this is not quoted, the yaml parser will convert numbers such as 8.0 to the number 8,
2828
# and the docker image `php:8` is the latest minor version of php 8.x (8.1).
2929
- PHP_VERSION: '7.2'
30+
STATIC_ANALYSIS: true
3031
- PHP_VERSION: '7.3'
3132
- PHP_VERSION: '7.4'
3233
- PHP_VERSION: '8.0'
3334
- PHP_VERSION: '8.1'
34-
- PHP_VERSION: '8.2.0beta2'
35+
- PHP_VERSION: '8.2.0RC3'
3536

3637
# Steps represent a sequence of tasks that will be executed as part of the job
3738
steps:
3839
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
3940
- uses: actions/checkout@v2
4041

42+
# Clone submodules
43+
- name: Checkout submodules for validation tests
44+
run: git submodule update --init --recursive --depth 1
45+
4146
# Runs a single command using the runners shell
4247
- name: Build and test in docker
4348
run: bash ci/run_tests_dockerized.sh ${{ matrix.PHP_VERSION }}
49+
50+
- name: Run static analysis (PHP 7.2 only)
51+
run: if [[ "${{ matrix.STATIC_ANALYSIS }}" == true ]]; then bash ci/run_phpstan_dockerized.sh ${{ matrix.PHP_VERSION }}; fi

.travis.yml

-45
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Tolerant PHP Parser
2-
[![Build Status](https://travis-ci.org/Microsoft/tolerant-php-parser.svg?branch=master)](https://travis-ci.org/Microsoft/tolerant-php-parser)
2+
[![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)
33

44
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
55
still a ton of work to be done, so at this point, this repo mostly serves as

ci/run_phpstan.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
# -x Exit immediately if any command fails
3+
# -e Echo all commands being executed.
4+
# -u Fail for undefined variables
5+
set -xeu
6+
# This installs and runs phpstan
7+
# TODO: Remove separate phpstan install step after https://github.com/microsoft/tolerant-php-parser/pull/385 is merged
8+
if [ ! -d vendor/phpstan/phpstan ]; then
9+
composer.phar require --dev phpstan/phpstan=^1.8
10+
fi
11+
./vendor/bin/phpstan analyze

ci/run_phpstan_dockerized.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
if [ $# != 1 ]; then
3+
echo "Usage: $0 PHP_VERSION" 1>&2
4+
echo "e.g. $0 8.0" 1>&2
5+
echo "The PHP_VERSION is the version of the php docker image to use to run phpstan (static analysis)" 1>&2
6+
exit 1
7+
fi
8+
# -x Exit immediately if any command fails
9+
# -e Echo all commands being executed.
10+
# -u fail for undefined variables
11+
set -xeu
12+
PHP_VERSION=$1
13+
14+
# This is the same image name, Dockerfile and build arguments as ci/run_tests_dockerized.sh
15+
DOCKER_IMAGE="tolerant-php-parser-test-runner:$PHP_VERSION"
16+
docker build --build-arg="PHP_VERSION=$PHP_VERSION" --tag="$DOCKER_IMAGE" -f ci/Dockerfile .
17+
docker run --rm $DOCKER_IMAGE ci/run_phpstan.sh

ci/run_tests.sh

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ set -xe
77
php -d short_open_tag=0 ./vendor/bin/phpunit --testsuite invariants
88
php -d short_open_tag=0 ./vendor/bin/phpunit --testsuite grammar
99
php -d short_open_tag=0 ./vendor/bin/phpunit --testsuite api
10+
php -d short_open_tag=0 ./vendor/bin/phpunit --testsuite validation

ci/run_tests_dockerized.sh

+5-7
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ fi
1111
# -u fail for undefined variables
1212
set -xeu
1313
PHP_VERSION=$1
14-
COMPOSER_OPTIONS=""
15-
# lexicographic comparison
16-
if [ "$PHP_VERSION" > "8.1" ]; then
17-
COMPOSER_OPTIONS="--ignore-platform-reqs"
18-
fi
1914

2015
DOCKER_IMAGE="tolerant-php-parser-test-runner:$PHP_VERSION"
21-
docker build --build-arg="PHP_VERSION=$PHP_VERSION" --build-arg="COMPOSER_OPTIONS=$COMPOSER_OPTIONS" --tag="$DOCKER_IMAGE" -f ci/Dockerfile .
22-
docker run --rm $DOCKER_IMAGE ci/run_tests.sh
16+
docker build --build-arg="PHP_VERSION=$PHP_VERSION" --tag="$DOCKER_IMAGE" -f ci/Dockerfile .
17+
# Run all of the phpunit test suites in CI.
18+
# - Add the validation folder as a read-only volume for running "phpunit --testsuite validation"
19+
# (This is around 180MB, so it is not added to the docker image)
20+
docker run --volume="$PWD/validation:/tolerant-php-parser/validation:ro" --rm $DOCKER_IMAGE ci/run_tests.sh

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"php": ">=7.2"
77
},
88
"require-dev": {
9-
"phpunit/phpunit": "^8.5.15"
9+
"phpunit/phpunit": "^8.5.30"
1010
},
1111
"license": "MIT",
1212
"authors": [

0 commit comments

Comments
 (0)