Skip to content

Commit 25f390b

Browse files
authored
Start testing with github actions (#202)
The script `ci/test_dockerized.sh 8.0` can be used to run the exact same tests locally. Closes #198 Change the comment text to avoid -Wimplicit-fallthrough to avoid noise https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
1 parent b09570d commit 25f390b

File tree

7 files changed

+129
-5
lines changed

7 files changed

+129
-5
lines changed

.dockerignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
*.dll
2+
*.tgz
3+
.deps
4+
*.o
5+
*.lo
6+
*.la
7+
*.swp
8+
.github
9+
.libs
10+
acinclude.m4
11+
aclocal.m4
12+
autom4te.cache
13+
build
14+
config.guess
15+
config.h
16+
config.h.in
17+
config.log
18+
config.nice
19+
config.status
20+
config.sub
21+
configure
22+
configure.in
23+
include
24+
install-sh
25+
libtool
26+
ltmain.sh
27+
Makefile
28+
Makefile.fragments
29+
Makefile.global
30+
Makefile.objects
31+
missing
32+
mkinstalldirs
33+
modules
34+
run-tests.php
35+
tests/*.diff
36+
tests/*.out
37+
# tests/*.php php files are used as helpers
38+
tests/*.exp
39+
tests/*.log
40+
tests/*.sh

.github/workflows/main.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Runs php-ast's tests and verifies that the package can be built.
2+
3+
name: CI
4+
5+
# Controls when the action will run.
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the master branch
8+
push:
9+
branches: [ master ]
10+
pull_request:
11+
branches: [ master ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
build:
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
23+
# See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-environment-variables-in-a-matrix
24+
strategy:
25+
matrix:
26+
include:
27+
# NOTE: If this is not quoted, the yaml parser will convert 7.0 to the number 7,
28+
# and the docker image `php:7` is the latest minor version of php 7.x (7.4).
29+
- PHP_VERSION: '7.0'
30+
- PHP_VERSION: '7.1'
31+
- PHP_VERSION: '7.2'
32+
- PHP_VERSION: '7.3'
33+
- PHP_VERSION: '7.4'
34+
- PHP_VERSION: '8.0'
35+
36+
# Steps represent a sequence of tasks that will be executed as part of the job
37+
steps:
38+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
39+
- uses: actions/checkout@v2
40+
41+
# Runs a single command using the runners shell
42+
- name: Build and test in docker
43+
run: bash ci/test_dockerized.sh ${{ matrix.PHP_VERSION }}

ast.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,22 +1331,22 @@ PHP_METHOD(ast_Node, __construct) {
13311331
if (!linenoNull) {
13321332
ast_update_property_long(zv, AST_STR(str_lineno), lineno, AST_CACHE_SLOT_LINENO);
13331333
}
1334-
/* break missing intentionally */
1334+
/* Falls through - break missing intentionally */
13351335
case 3:
13361336
if (children != NULL) {
13371337
ast_update_property(zv, AST_STR(str_children), children, AST_CACHE_SLOT_CHILDREN);
13381338
}
1339-
/* break missing intentionally */
1339+
/* Falls through - break missing intentionally */
13401340
case 2:
13411341
if (!flagsNull) {
13421342
ast_update_property_long(zv, AST_STR(str_flags), flags, AST_CACHE_SLOT_FLAGS);
13431343
}
1344-
/* break missing intentionally */
1344+
/* Falls through - break missing intentionally */
13451345
case 1:
13461346
if (!kindNull) {
13471347
ast_update_property_long(zv, AST_STR(str_kind), kind, AST_CACHE_SLOT_KIND);
13481348
}
1349-
/* break missing intentionally */
1349+
/* Falls through - break missing intentionally */
13501350
case 0:
13511351
break;
13521352
}

ci/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG PHP_VERSION
2+
FROM php:$PHP_VERSION
3+
WORKDIR /php-ast
4+
ADD *.c *.h *.php config.m4 config.w32 package.xml LICENSE README.md ./
5+
6+
# Assume compilation will be the time consuming step.
7+
# Add tests after compiling so that it's faster to update tests and re-run them locally.
8+
#
9+
# Use the same CFLAGS used to build the docker image but also check for warnings (this will emit warnings but not fail the build)
10+
RUN phpize && EXTRA_CFLAGS='-Wall -Wextra -Wno-unused-parameter' ./configure && make -j2 && make install
11+
RUN docker-php-ext-enable ast
12+
ADD tests ./tests
13+
ADD ci ./ci

ci/test_dockerized.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
if [ $# != 1 ]; then
3+
echo "Usage: $0 PHP_VERSION" 1>&2
4+
echo "e.g. $0 8.0 or $0 8.0-alpine" 1>&2
5+
echo "The PHP_VERSION is the version of the php docker image to use" 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+
DOCKER_IMAGE=php-ast-$PHP_VERSION-test-runner
14+
docker build --build-arg="PHP_VERSION=$PHP_VERSION" --tag="$DOCKER_IMAGE" -f ci/Dockerfile .
15+
docker run --rm $DOCKER_IMAGE ci/test_inner.sh

ci/test_inner.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
echo "Run tests in docker"
7+
REPORT_EXIT_STATUS=1 php ./run-tests.php -P -q --show-diff
8+
echo "Test that package.xml is valid"
9+
pecl package

package.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<file name="array_destructuring_old.phpt" role="test" />
5252
<file name="array_destructuring.phpt" role="test" />
5353
<file name="assign_ops.phpt" role="test" />
54+
<file name="ast_dump_with_exclude_doc.phpt" role="test" />
5455
<file name="ast_dump_with_linenos.phpt" role="test" />
5556
<file name="attributes_01.phpt" role="test" />
5657
<file name="attributes_02.phpt" role="test" />
@@ -62,6 +63,7 @@
6263
<file name="class_name_version_70.phpt" role="test" />
6364
<file name="class_on_objects.phpt" role="test" />
6465
<file name="class.phpt" role="test" />
66+
<file name="class_type_85.phpt" role="test" />
6567
<file name="class_types.phpt" role="test" />
6668
<file name="closure_use_vars.phpt" role="test" />
6769
<file name="coalesce.phpt" role="test" />
@@ -86,6 +88,7 @@
8688
<file name="named_children.phpt" role="test" />
8789
<file name="name_node.phpt" role="test" />
8890
<file name="nested_stmt_lists.phpt" role="test" />
91+
<file name="never_return_type.phpt" role="test" />
8992
<file name="node_constructor_throw.phpt" role="test" />
9093
<file name="nop_statements.phpt" role="test" />
9194
<file name="nullable_types.phpt" role="test" />
@@ -105,9 +108,10 @@
105108
<file name="php80_nullsafe_operator.phpt" role="test" />
106109
<file name="php80_promotion.phpt" role="test" />
107110
<file name="php80_static_type.phpt" role="test" />
108-
<file name="php80_union_types.phpt" role="test" />
109111
<file name="php80_union_types_false.phpt" role="test" />
110112
<file name="php80_union_types_nullable.phpt" role="test" />
113+
<file name="php80_union_types.phpt" role="test" />
114+
<file name="php81_enums.phpt" role="test" />
111115
<file name="prop_doc_comments.phpt" role="test" />
112116
<file name="short_arrow_function.phpt" role="test" />
113117
<file name="short_arrow_function_return.phpt" role="test" />

0 commit comments

Comments
 (0)