Skip to content
Merged
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
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.git/
.github/
validation/
vendor/
docs/
tools/
**/.DS_Store
**/.idea
**/composer.lock
tests/output
.phpunit.result.cache
**/*.ast
**/.*.swp
**/.*.swo
**/Dockerfile
.dockerignore
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/tests/cases/**/*.php text eol=lf

/.vscode export-ignore
/ci export-ignore
/docs export-ignore
/experiments export-ignore
/php-langspec export-ignore
Expand All @@ -17,3 +18,4 @@
/Contributing.md export-ignore
/README.md export-ignore
/phpunit.xml export-ignore
/.dockerignore export-ignore
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Runs tolerant-php-parser's tests
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-environment-variables-in-a-matrix
strategy:
fail-fast: false
matrix:
include:
# 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'
- PHP_VERSION: '7.3'
- PHP_VERSION: '7.4'
- PHP_VERSION: '8.0'
- PHP_VERSION: '8.1'
- PHP_VERSION: '8.2.0beta2'

# 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

# Runs a single command using the runners shell
- name: Build and test in docker
run: bash ci/run_tests_dockerized.sh ${{ matrix.PHP_VERSION }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tests/output
*.ast
.*.swp
.*.swo
.phpunit.result.cache
12 changes: 12 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG PHP_VERSION
FROM php:$PHP_VERSION
RUN curl https://getcomposer.org/download/latest-2.x/composer.phar -o /usr/bin/composer.phar && chmod a+x /usr/bin/composer.phar
WORKDIR /tolerant-php-parser
RUN apt-get update && apt-get install -y unzip && apt-get clean
ARG COMPOSER_OPTIONS
ENV COMPOSER_OPTIONS=$COMPOSER_OPTIONS

ADD composer.json ./
RUN composer.phar install $COMPOSER_OPTIONS && composer.phar clear-cache

ADD . .
9 changes: 9 additions & 0 deletions ci/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# This runs the tests that have been set up in GitHub Workflows so far

# -x Exit immediately if any command fails
# -e Echo all commands being executed.
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
22 changes: 22 additions & 0 deletions ci/run_tests_dockerized.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/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" 1>&2
echo "This runs the tests that have been set up in GitHub Workflows so far" 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
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