Skip to content

Commit

Permalink
Move validation test suite, phpstan to GitHub Workflows
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
TysonAndre committed Oct 8, 2022
1 parent 3eccfd2 commit 89f263b
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 55 deletions.
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
10 changes: 9 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,25 @@ 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'
- PHP_VERSION: '8.1'
- PHP_VERSION: '8.2.0beta2'
- PHP_VERSION: '8.2.0RC3'

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# 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
45 changes: 0 additions & 45 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
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.30"
},
"license": "MIT",
"authors": [
Expand Down

0 comments on commit 89f263b

Please sign in to comment.