Skip to content

Commit ef8c917

Browse files
committed
Add CI for unit tests
1 parent a799dba commit ef8c917

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: ./configure (unit tests)
2+
description: Configure PHP with minimal settings for unit testing
3+
runs:
4+
using: composite
5+
steps:
6+
- shell: bash
7+
run: |
8+
set -x
9+
./buildconf --force
10+
./configure --disable-all --enable-embed=static

.github/workflows/unit-tests.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Unit Tests
2+
on:
3+
push:
4+
paths:
5+
- 'main/network.c'
6+
- 'tests/unit/**'
7+
- '.github/workflows/unit-tests.yml'
8+
branches:
9+
- master
10+
pull_request:
11+
paths:
12+
- 'main/network.c'
13+
- 'tests/unit/**'
14+
- '.github/workflows/unit-tests.yml'
15+
branches:
16+
- '**'
17+
workflow_dispatch: ~
18+
19+
permissions:
20+
contents: read
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.event.pull_request.url || github.run_id }}
24+
cancel-in-progress: true
25+
26+
env:
27+
CC: ccache gcc
28+
CXX: ccache g++
29+
30+
jobs:
31+
UNIT_TESTS:
32+
if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
33+
name: UNIT_TESTS_LINUX_X64
34+
runs-on: ubuntu-24.04
35+
timeout-minutes: 20
36+
steps:
37+
- name: git checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Install dependencies
41+
run: |
42+
set -x
43+
sudo apt-get update
44+
sudo apt-get install -y \
45+
libcmocka-dev \
46+
autoconf \
47+
gcc \
48+
make \
49+
unzip \
50+
bison \
51+
re2c \
52+
locales \
53+
ccache
54+
55+
- name: ccache
56+
uses: hendrikmuhs/ccache-action@v1.2
57+
with:
58+
key: "unit-tests-${{hashFiles('main/php_version.h')}}"
59+
append-timestamp: false
60+
save: ${{ github.event_name != 'pull_request' }}
61+
62+
- name: ./configure (minimal build)
63+
uses: ./.github/actions/configure-unit-tests
64+
65+
- name: make libphp.a
66+
run: |
67+
set -x
68+
make -j$(/usr/bin/nproc)
69+
70+
- name: Run unit tests
71+
run: |
72+
set -x
73+
cd tests/unit
74+
make test

0 commit comments

Comments
 (0)