Skip to content

Commit 1442404

Browse files
committed
Enable code coverage
1 parent 44780b5 commit 1442404

File tree

3 files changed

+58
-28
lines changed

3 files changed

+58
-28
lines changed

.github/actions/build-linux/action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runs:
77
- name: Install RE2C Lexer Generator
88
shell: bash
99
run: |
10-
sudo apt-get install re2c
10+
sudo apt-get install re2c lcov
1111
1212
- name: Build Zephir Parser for Linux
1313
shell: bash
@@ -20,13 +20,19 @@ runs:
2020
echo "::group::Run configure"
2121
./configure \
2222
--enable-zephir-parser \
23-
--enable-zephir-parser-debug
23+
--enable-zephir-parser-debug \
24+
${{ env.CONFIGURE_COVERAGE }}
2425
echo "::endgroup::"
2526
2627
echo "::group::Compile"
2728
make -j$(getconf _NPROCESSORS_ONLN)
2829
echo "::endgroup::"
2930
31+
- name: Preparing to collect coverage data
32+
if: matrix.ccov == 'ON'
33+
shell: bash
34+
run: make coverage-initial
35+
3036
- name: Enable Zephir Parser
3137
shell: bash
3238
run: |

.github/actions/build-mac/action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runs:
77
- name: Install RE2C Lexer Generator
88
shell: bash
99
run: |
10-
brew install re2c
10+
brew install re2c lcov
1111
env:
1212
HOMEBREW_NO_INSTALL_CLEANUP: 1
1313

@@ -22,13 +22,19 @@ runs:
2222
echo "::group::Run configure"
2323
./configure \
2424
--enable-zephir-parser \
25-
--enable-zephir-parser-debug
25+
--enable-zephir-parser-debug \
26+
${{ env.CONFIGURE_COVERAGE }}
2627
echo "::endgroup::"
2728
2829
echo "::group::Compile"
2930
make -j$(getconf _NPROCESSORS_ONLN)
3031
echo "::endgroup::"
3132
33+
- name: Preparing to collect coverage data
34+
if: matrix.ccov == 'ON'
35+
shell: bash
36+
run: make coverage-initial
37+
3238
- name: Enable Zephir Parser
3339
shell: bash
3440
run: |

.github/workflows/ci.yml

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ on:
1818

1919
env:
2020
RE2C_VERSION: 2.2
21-
PHP_SDK_VERSION: 2.2.0
22-
PHP_DEVPACK: C:\tools\php-devpack
23-
PHP_SDK_PATH: C:\tools\php-sdk
21+
CONFIGURE_COVERAGE: '' # Configure options for overage is empty by default
2422

2523
jobs:
2624
builds:
@@ -42,17 +40,17 @@ jobs:
4240
# {php}-{ts}-{os.name}-{compiler}-{arch}
4341
include:
4442
# Linux
45-
- { name: ubuntu-gcc, os: ubuntu-18.04, compiler: gcc }
43+
- { name: ubuntu-gcc, os: ubuntu-18.04, compiler: gcc, ccov: 'ON' }
4644
# macOS
47-
- { name: macos-clang, os: macos-10.15, compiler: clang }
45+
- { name: macos-clang, os: macos-10.15, compiler: clang, ccov: 'ON' }
4846
# Windows
49-
- { php: '7.0', ts: 'nts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14' }
50-
- { php: '7.1', ts: 'nts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14' }
51-
- { php: '7.2', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15' }
52-
- { php: '7.3', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15' }
53-
- { php: '7.4', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15' }
54-
- { php: '8.0', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
55-
- { php: '8.1', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
47+
- { php: '7.0', ts: 'nts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
48+
- { php: '7.1', ts: 'nts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
49+
- { php: '7.2', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
50+
- { php: '7.3', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
51+
- { php: '7.4', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
52+
- { php: '8.0', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
53+
- { php: '8.1', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
5654

5755
steps:
5856
- uses: actions/checkout@v2
@@ -65,6 +63,23 @@ jobs:
6563
env:
6664
PHPTS: ${{ matrix.ts }}
6765

66+
- name: Setup Build System
67+
shell: bash
68+
run: |
69+
echo "::group::Enable Code Coverage Capture"
70+
if [ "${{ matrix.ccov }}" = "ON" ]; then
71+
echo "CONFIGURE_COVERAGE=--enable-coverage" >> $GITHUB_ENV
72+
fi
73+
echo "::endgroup::"
74+
75+
echo "::group::Setup PHP executable for tests"
76+
if [ "${{ runner.os }}" = "Windows" ]; then
77+
echo "TEST_PHP_EXECUTABLE=C:\tools\php\php.exe" >> $GITHUB_ENV
78+
else
79+
echo "TEST_PHP_EXECUTABLE=$(which php)" >> $GITHUB_ENV
80+
fi
81+
echo "::endgroup::"
82+
6883
- name: Build Zephir Parser Extension (Linux)
6984
uses: ./.github/actions/build-linux
7085
if: runner.os == 'Linux'
@@ -85,15 +100,6 @@ jobs:
85100
CACHE_DIR: 'C:\Downloads'
86101
TOOLS_DIR: 'C:\tools'
87102

88-
- name: Setup Tests
89-
shell: bash
90-
run: |
91-
if [ "${{ runner.os }}" = "Windows" ]; then
92-
echo "TEST_PHP_EXECUTABLE=C:\tools\php\php.exe" >> $GITHUB_ENV
93-
else
94-
echo "TEST_PHP_EXECUTABLE=$(which php)" >> $GITHUB_ENV
95-
fi
96-
97103
- name: Run Tests for Zephir Parser
98104
shell: bash
99105
run: |
@@ -113,14 +119,14 @@ jobs:
113119
EXTENSION="$(find ./modules -type f -name 'zephir_parser.so')"
114120
fi
115121
116-
zip -rvj zephir-parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.arch }}.zip \
122+
zip -rvj zephir-parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}.zip \
117123
$EXTENSION VERSION LICENSE CREDITS NO_WARRANTY CHANGELOG.md
118124
echo "::endgroup::"
119125
120126
- name: Upload Zephir Parser
121127
uses: actions/upload-artifact@v2
122128
with:
123-
name: zephir-parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.arch }}.zip
129+
name: zephir-parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}.zip
124130
path: |
125131
${{ github.workspace }}/zephir-parser-*.zip
126132
@@ -136,12 +142,24 @@ jobs:
136142
Write-Output "::endgroup::"
137143
}
138144
145+
- name: Capture Coverage Data
146+
if: success() && matrix.ccov == 'ON'
147+
run: make coverage-capture
148+
149+
- name: Upload Code Coverage Report
150+
if: matrix.ccov == 'ON'
151+
uses: codecov/codecov-action@v2
152+
with:
153+
token: ${{ secrets.CODECOV_TOKEN }}
154+
files: ./lcov.info
155+
flags: unittests,${{ matrix.os }}
156+
139157
- name: Upload Info for Debug on Fail
140158
if: failure()
141159
uses: actions/upload-artifact@v2
142160
with:
143161
retention-days: 2
144-
name: errors-zephir-parser-php-zephir-parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.arch }}
162+
name: errors-zephir-parser-php-zephir-parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
145163
path: |
146164
${{ github.workspace }}/tests
147165
${{ github.workspace }}/parser

0 commit comments

Comments
 (0)