-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
name: Sanitizers | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "docs/**" | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "docs/**" | ||
permissions: | ||
contents: read | ||
jobs: | ||
# Adapted from https://github.com/beberlei/hdrhistogram-php | ||
sanitizers: | ||
runs-on: ubuntu-latest | ||
env: | ||
CFLAGS: -g -fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC | ||
LDFLAGS: -fsanitize=undefined,address | ||
CC: clang-18 | ||
CXX: clang++-18 | ||
steps: | ||
- | ||
uses: actions/checkout@v4 | ||
- | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.22" | ||
cache-dependency-path: | | ||
go.sum | ||
caddy/go.sum | ||
- | ||
name: Install LLVM | ||
run: sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" | ||
- | ||
name: Determine PHP version | ||
id: determine-php-version | ||
run: | | ||
curl -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=8.3' -o version.json | ||
echo version="$(jq -r 'keys[0]') version.json" >> $GITHUB_OUTPUT | ||
echo archive="$(jq -r '.[] .source[] | select(.filename |endswith(".xz")) | "https://www.php.net/distributions/" + .filename' version.json)" >> $GITHUB_OUTPUT | ||
- | ||
name: Cache PHP | ||
id: cache-php | ||
uses: actions/cache@v4 | ||
with: | ||
path: php/target/ | ||
key: php-sanitizers-${{ runner.arch }}-${{ steps.determine-php-version.outputs.version }} | ||
- | ||
if: steps.cache-php.outputs.cache-hit != 'true' | ||
run: | | ||
sudo apt-get remove --purge --autoremove 'php*-*' 'libmemcached*' | ||
mkdir php/ | ||
curl -fsSL "${{ steps.determine-php-version.outputs.archive }}" | tar xz -C php --strip-components=1 | ||
cd php/ | ||
./configure \ | ||
--enable-debug \ | ||
--enable-embed \ | ||
--enable-zts \ | ||
--disable-zend-signals \ | ||
--prefix=$(pwd)/target/ | ||
make -j"$(getconf _NPROCESSORS_ONLN)" | ||
make install | ||
ls $(pwd)/target/lib/ | ||
- | ||
name: Add PHP to the PATH | ||
run: | | ||
echo "$(pwd)/php/target/bin" >> $GITHUB_PATH | ||
- | ||
name: Set CGO flags | ||
run: | | ||
php-config | ||
echo "LDFLAGS=$LDFLAGS -L$(pwd)/php/target/lib/" >> "$GITHUB_ENV" | ||
echo "CGO_CFLAGS=$CFLAGS $(php-config --includes)" >> "$GITHUB_ENV" | ||
echo "CGO_LDLAGS=$LDFLAGS $(php-config --ldflags || true) $(php-config --libs || true)" >> "$GITHUB_ENV" | ||
- | ||
name: Run library tests with sanitizers | ||
run: go test -asan -v ./... |