Skip to content

Commit d8bac07

Browse files
committed
Move CI to GitHubActions
- Move CI to GitHub Actions - Cleaned up install-re2c.sh script - Add macOS support
1 parent 5310b49 commit d8bac07

File tree

2 files changed

+215
-24
lines changed

2 files changed

+215
-24
lines changed

.ci/install-re2c.sh

Lines changed: 64 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,95 @@ if [ "${RE2C_VERSION}" == "system" ]; then
1717
exit 0
1818
fi
1919

20+
# From https://stackoverflow.com/a/4025065
21+
vercomp () {
22+
if [[ $1 == $2 ]]
23+
then
24+
return 0
25+
fi
26+
local IFS=.
27+
local i ver1=($1) ver2=($2)
28+
# fill empty fields in ver1 with zeros
29+
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
30+
do
31+
ver1[i]=0
32+
done
33+
for ((i=0; i<${#ver1[@]}; i++))
34+
do
35+
if [[ -z ${ver2[i]} ]]
36+
then
37+
# fill empty fields in ver2 with zeros
38+
ver2[i]=0
39+
fi
40+
if ((10#${ver1[i]} > 10#${ver2[i]}))
41+
then
42+
return 1
43+
fi
44+
if ((10#${ver1[i]} < 10#${ver2[i]}))
45+
then
46+
return 2
47+
fi
48+
done
49+
return 0
50+
}
51+
52+
ext='tar.xz'
53+
vercomp "$RE2C_VERSION" '1.2'
54+
55+
case $? in
56+
2) ext='tar.gz';;
57+
esac
58+
2059
pkgname=re2c
21-
source="https://github.com/skvadrik/${pkgname}/releases/download/${RE2C_VERSION}/${pkgname}-${RE2C_VERSION}.tar.xz"
22-
downloaddir="${HOME}/.cache/${pkgname}/${pkgname}-${RE2C_VERSION}"
60+
source="https://github.com/skvadrik/${pkgname}/releases/download/${RE2C_VERSION}/${pkgname}-${RE2C_VERSION}.${ext}"
61+
downloadfile="${pkgname}-${RE2C_VERSION}.${ext}"
2362
prefix="${HOME}/.local/opt/${pkgname}/${pkgname}-${RE2C_VERSION}"
2463
bindir="${prefix}/bin"
2564

26-
if [ ! -f "${bindir}/re2c" ]; then
27-
if [ ! -d `dirname ${downloaddir}` ]; then
28-
mkdir -p `dirname ${downloaddir}`
65+
if [ ! -f "$bindir/re2c" ]; then
66+
if [ ! -d "$(dirname "$HOME/.cache/$pkgname")" ]; then
67+
mkdir -p "$(dirname "$HOME/.cache/$pkgname")"
2968
fi
30-
cd "$(dirname "$downloaddir")" || exit 1
3169

32-
if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.xz" ]; then
33-
curl -sSL "$source" -o "${pkgname}-${RE2C_VERSION}.tar.xz"
70+
cd "$(dirname "$HOME/.cache/$pkgname")" || exit 1
71+
72+
if [ ! -f "$downloadfile" ]; then
73+
echo "curl -sSL --fail-early '$source' -o '${pkgname}-${RE2C_VERSION}.${ext}'"
74+
curl -sSL --fail-early "$source" -o "${pkgname}-${RE2C_VERSION}.${ext}"
3475
fi
3576

36-
if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.xz" ]; then
37-
>&2 echo "Unable to locate ${pkgname}-${RE2C_VERSION}.tar.xz file. Stop."
77+
if [ ! -f "$downloadfile" ]; then
78+
>&2 echo "Unable to locate $downloadfile file. Abort..."
3879
exit 1
80+
else
81+
file "$downloadfile"
3982
fi
4083

41-
if [ ! -d "${downloaddir}" ]; then
42-
mkdir -p "${downloaddir}"
43-
tar -xf "${pkgname}-${RE2C_VERSION}.tar.xz" || exit 1
44-
fi
84+
tar -xf "$downloadfile" || exit 1
4585

46-
if [ ! -d "${downloaddir}" ]; then
47-
>&2 echo "Unable to locate re2c source. Stop."
86+
if [ ! -d "${pkgname}-${RE2C_VERSION}" ]; then
87+
>&2 echo "Unable to locate re2c source files. Abort..."
4888
exit 1
4989
fi
5090

51-
if [ ! -d "${prefix}" ]; then
52-
mkdir -p "${prefix}"
91+
if [ ! -d "$prefix" ]; then
92+
mkdir -p "$prefix"
5393
fi
5494

55-
cd "${downloaddir}" || exit 1
56-
./configure --prefix="${prefix}"
95+
cd "${pkgname}-${RE2C_VERSION}" || exit 1
96+
./configure --prefix="$prefix"
5797

5898
make -j"$(getconf _NPROCESSORS_ONLN)"
5999
make install
60100
fi
61101

62-
if [ ! -x "${bindir}/re2c" ]; then
63-
>&2 echo "Unable to locate re2c executable. Stop."
102+
if [ ! -x "$bindir/re2c" ]; then
103+
>&2 echo "Unable to locate re2c executable. Abort..."
64104
exit 1
65105
fi
66106

67-
mkdir -p "${HOME}/bin"
68-
ln -s "${bindir}/re2c" "${HOME}/bin/re2c"
107+
mkdir -p "$HOME/bin"
108+
ln -s "$bindir/re2c" "$HOME/bin/re2c"
69109

70110
re2c --version
71111
exit 0

.github/workflows/main.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'wip-*'
7+
paths-ignore:
8+
- '*.md'
9+
pull_request:
10+
branches:
11+
- 'master'
12+
- 'development'
13+
schedule:
14+
- cron: '0 11 * * *'
15+
16+
jobs:
17+
ci:
18+
strategy:
19+
fail-fast: false
20+
21+
matrix:
22+
re2c:
23+
- '0.13.6'
24+
- '1.2.1'
25+
php:
26+
- '7.0'
27+
- '7.1'
28+
- '7.3'
29+
- '7.4'
30+
name:
31+
- 'Ubuntu'
32+
- 'macOS X'
33+
34+
include:
35+
- name: 'Ubuntu'
36+
os: ubuntu-latest
37+
ccov: ON
38+
- name: 'macOS X'
39+
os: macOS-latest
40+
ccov: ON
41+
42+
name: "${{ matrix.name }}: PHP ${{ matrix.php }}, re2c ${{ matrix.re2c }}"
43+
runs-on: ${{ matrix.os }}
44+
45+
env:
46+
ZEND_DONT_UNLOAD_MODULES: 1
47+
USE_ZEND_ALLOC: 0
48+
49+
steps:
50+
- uses: actions/checkout@v2-beta
51+
with:
52+
fetch-depth: 5
53+
54+
- name: Install PHP ${{ matrix.php }}
55+
uses: shivammathur/setup-php@v1
56+
with:
57+
php-version: '${{ matrix.php }}'
58+
coverage: none
59+
60+
- name: Setup Prerequisites (Linux)
61+
if: runner.os == 'Linux'
62+
run: |
63+
sudo apt-get update --quiet --yes 1>/dev/null
64+
sudo apt-get install --no-install-recommends --quiet --yes lcov
65+
66+
- name: Setup Prerequisites (macOS)
67+
if: runner.os == 'macOS'
68+
run: |
69+
brew install lcov
70+
sudo xcode-select -switch /Applications/Xcode.app
71+
72+
- name: Setup Build System (Generic)
73+
if: runner.os != 'Windows'
74+
run: |
75+
ulimit -c unlimited -S || true
76+
77+
mkdir -p $HOME/.cache/re2c
78+
mkdir -p $HOME/.local/opt/re2c
79+
80+
echo "::set-env name=RE2C_VERSION::${{ matrix.re2c }}"
81+
echo "::set-env name=PHP_VERNUM::$(php-config --vernum)"
82+
echo "::set-env name=PHP_VERSION_MAJOR::$(php-config --version | cut -d'.' -f1,2)"
83+
echo "::set-env name=PHP_VERSION_SHORT::$(php-config --version | cut -d'.' -f1,2,3)"
84+
echo "::set-env name=PATH::$PATH:$HOME/bin:$(brew --prefix lcov)/bin"
85+
86+
- name: Setup Core Dump (Linux)
87+
if: runner.os == 'Linux'
88+
run: echo '/tmp/core.%e.%p.%t' | sudo tee /proc/sys/kernel/core_pattern
89+
90+
- uses: actions/cache@v1
91+
if: runner.os != 'Windows'
92+
name: Setup re2c source cache
93+
id: re2c-source-cache
94+
with:
95+
path: ~/.cache/re2c
96+
key: ${{ runner.os }}-re2c-source-cache-${{ hashFiles('**/.ci/install-re2c.sh') }}
97+
restore-keys: |
98+
${{ runner.os }}-re2c-source-cache-
99+
100+
- uses: actions/cache@v1
101+
if: runner.os != 'Windows'
102+
name: Setup re2c binary cache
103+
id: re2c-binary-cache
104+
with:
105+
path: ~/.local/opt/re2c
106+
key: ${{ runner.os }}-re2c-binary-cache-${{ hashFiles('**/.ci/install-re2c.sh') }}
107+
restore-keys: |
108+
${{ runner.os }}-re2c-binary-cache-
109+
110+
- name: Install re2c ${{ matrix.re2c }}
111+
if: runner.os != 'Windows'
112+
run: .ci/install-re2c.sh
113+
114+
- name: Build extensions (Linux)
115+
if: runner.os != 'Windows'
116+
run: |
117+
phpize
118+
./configure \
119+
--enable-zephir-parser \
120+
--enable-zephir-parser-debug \
121+
--enable-coverage
122+
make -j$(getconf _NPROCESSORS_ONLN)
123+
124+
- name: Preparing to collect coverage data
125+
if: matrix.ccov == 'ON'
126+
run: make coverage-initial
127+
128+
- name: Run Tests
129+
if: runner.os != 'Windows'
130+
run: make -j$(getconf _NPROCESSORS_ONLN) test NO_INTERACTION=1 REPORT_EXIT_STATUS=1 TEST_PHP_ARGS=${{ matrix.test-args }}
131+
132+
- name: Print failures
133+
if: failure()
134+
run: |
135+
re2c --version
136+
php -v
137+
php -m
138+
.ci/after-failure.sh
139+
140+
- name: Capture coverage data
141+
if: success() && matrix.ccov == 'ON'
142+
run: make coverage-capture
143+
144+
- name: Upload code coverage report
145+
if: matrix.ccov == 'ON'
146+
uses: codecov/codecov-action@v1
147+
with:
148+
token: ${{secrets.CODECOV_TOKEN}}
149+
file: ./lcov.info
150+
flags: unittests
151+
fail_ci_if_error: false

0 commit comments

Comments
 (0)