mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Add CI for unit tests
This commit is contained in:
10
.github/actions/configure-unit-tests/action.yml
vendored
Normal file
10
.github/actions/configure-unit-tests/action.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
name: ./configure (unit tests)
|
||||
description: Configure PHP with minimal settings for unit testing
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- shell: bash
|
||||
run: |
|
||||
set -x
|
||||
./buildconf --force
|
||||
./configure --disable-all --enable-embed=static
|
||||
75
.github/workflows/unit-tests.yml
vendored
Normal file
75
.github/workflows/unit-tests.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
name: Unit Tests
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'main/network.c'
|
||||
- 'tests/unit/**'
|
||||
- '.github/workflows/unit-tests.yml'
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
paths:
|
||||
- 'main/network.c'
|
||||
- 'tests/unit/**'
|
||||
- '.github/workflows/unit-tests.yml'
|
||||
branches:
|
||||
- '**'
|
||||
workflow_dispatch: ~
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.url || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
CC: ccache gcc
|
||||
CXX: ccache g++
|
||||
|
||||
jobs:
|
||||
UNIT_TESTS:
|
||||
if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
|
||||
name: UNIT_TESTS_LINUX_X64
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: git checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
set -x
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libcmocka-dev \
|
||||
autoconf \
|
||||
gcc \
|
||||
make \
|
||||
unzip \
|
||||
bison \
|
||||
re2c \
|
||||
locales \
|
||||
ccache
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: "unit-tests-${{hashFiles('main/php_version.h')}}"
|
||||
append-timestamp: false
|
||||
save: ${{ github.event_name != 'pull_request' }}
|
||||
|
||||
- name: ./configure (minimal build)
|
||||
uses: ./.github/actions/configure-unit-tests
|
||||
|
||||
- name: make libphp.a
|
||||
run: |
|
||||
set -x
|
||||
make -j$(/usr/bin/nproc) >/dev/null
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
set -x
|
||||
cd tests/unit
|
||||
make test
|
||||
|
||||
@@ -2,6 +2,7 @@ CC = gcc
|
||||
CFLAGS = -g -Wall -I../../ -I../../Zend -I../../main -I../../TSRM -I. -I..
|
||||
COMMON_LDFLAGS = ../../.libs/libphp.a -lcmocka -lpthread -lm -ldl -lresolv -lutil
|
||||
|
||||
# Update paths in .github/workflows/unit-tests.yml when adding new test to make it run in PR when such file changes
|
||||
TESTS = main/test_network
|
||||
main/test_network_SRC = main/test_network.c
|
||||
main/test_network_LDFLAGS = $(COMMON_LDFLAGS) -Wl,--wrap=connect,--wrap=poll,--wrap=getsockopt,--wrap=gettimeofday
|
||||
|
||||
@@ -251,4 +251,4 @@ int main(void) {
|
||||
cmocka_unit_test(test_php_network_connect_socket_connect_error),
|
||||
};
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user