Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub actions #190

Merged
merged 24 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/release-notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# -e Exit immediately if a command exits with a non-zero status.
# -u Treat unset variables as an error when substituting.

set -eu
set -o pipefail

# Get Release notes for the latest release from CHANGELOG.md
# How to use:
# release-notes.sh CHANGELOG.md > ReleaseNotes.md

startline=$(($(cat "$1" | grep -nE '^## \[v[0-9]+' | head -n 1 | tail -n 1 | cut -d ":" -f 1) + 1))
finishline=$(($(cat "$1" | grep -nE '^## \[v[0-9]+' | head -n 2 | tail -n 1 | cut -d ":" -f 1) - 1))
changelog=$(sed -n "${startline},${finishline}p" "$1");

echo "${changelog}"
146 changes: 146 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: CI

on:
push:
paths-ignore:
- '**.md'
- '**.txt'
pull_request:

jobs:
build:
name: build / php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]

name:
- linux
- mac

include:
# Linux
- { name: linux, ts: 'nts', compiler: 'gcc', os: ubuntu-20.04 }
# macOS
- { name: mac, ts: 'nts', compiler: 'clang', os: macos-11 }

steps:
- uses: actions/checkout@v2

# configure spx artifact name in next format:
# {php}-{ts}-{os.name}-{compiler}
# spx-php-8.1-nts-Linux-gcc
- name: Set artifact name
id: setup-artifact
run: |
echo "::set-output name=spx_file_name::spx-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}"

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Install dependencies
if: runner.os == 'macOS'
run: brew install zlib

- name: phpize
run: phpize

- name: Configure
run: |
if [ "${{ runner.os }}" = "macOS" ]; then
./configure --with-zlib-dir=$(brew --prefix)/opt/zlib
else
./configure
fi

- name: Compile
run: |
make -j"$(getconf _NPROCESSORS_ONLN)"
sudo make install

- name: Extension Info
run: |
php --ini
php -d extension=./modules/spx.so --ri spx

- name: Run Tests
run: make test
env:
NO_INTERACTION: 1
REPORT_EXIT_STATUS: 1
TEST_PHP_ARGS: "--show-diff"

- name: Upload build artifacts after Failure
if: failure()
uses: actions/upload-artifact@v2
with:
name: debug-${{ steps.setup-artifact.outputs.spx_file_name }}
path: |
${{ github.workspace }}/*.log
${{ github.workspace }}/tests/*.log
retention-days: 7

- name: Create ZIP archive with build artifact
run: |
zip -rvj ${{ steps.setup-artifact.outputs.spx_file_name }}.zip \
./modules/spx.so LICENSE $ZIP_EXCLUDE
zip -rv ${{ steps.setup-artifact.outputs.spx_file_name }}.zip \
./assets $ZIP_EXCLUDE
env:
ZIP_EXCLUDE: -x ".*" -x "__MACOSX" -x "*.DS_Store"

- name: Check Release notes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of this step in this context ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, to check that the script do not fail before entering the release process.

run: |
echo "-- Parsing Release Notes from CHANGELOG"
./.github/release-notes.sh ./CHANGELOG.md

- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.setup-artifact.outputs.spx_file_name }}
path: ${{ steps.setup-artifact.outputs.spx_file_name }}.zip

release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')

needs: [ build ]
name: Create Release
runs-on: ubuntu-20.04

steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Get the release version
id: get-version
run: |
echo ::set-output name=version::${GITHUB_REF#refs/tags/}

- name: Download SPX build artifacts
id: download
uses: actions/download-artifact@v2
with:
path: ./build-artifacts

- name: Prepare Release notes
run: |
echo "-- Creating Release Notes"
./.github/release-notes.sh ./CHANGELOG.md > ./release-notes.md

- name: Create Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.get-version.outputs.version }}
tag: ${{ steps.get-version.outputs.version }}
bodyFile: "./release-notes.md"
allowUpdates: true
artifacts: "./build-artifacts/*.zip"
artifactContentType: application/octet-stream
75 changes: 75 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased](https://github.com/NoiseByNorthwest/php-spx/compare/0.4.0...HEAD)

### Added
- Github Actions workflow ([#180](https://github.com/NoiseByNorthwest/php-spx/issues/180))

### Removed
- Travis CI


## [v0.4.0](https://github.com/NoiseByNorthwest/php-spx/compare/0.3.0...0.4.0)

### Added
- Analysis screen: fix the NaNs in time grid when time goes above 1000s (fixes [#65](https://github.com/NoiseByNorthwest/php-spx/issues/65))
- Add sampling profiling mode ([#69](https://github.com/NoiseByNorthwest/php-spx/pull/69))
- Add memory allocator related metrics ([#70](https://github.com/NoiseByNorthwest/php-spx/pull/70))
- CLI: Add color scheme to flat profile ([#77](https://github.com/NoiseByNorthwest/php-spx/pull/77))
- Add PHP 7.3 support ([#80](https://github.com/NoiseByNorthwest/php-spx/pull/80))

### Changed
- Web UI: remove request-URI based routing ([#76](https://github.com/NoiseByNorthwest/php-spx/pull/76))

### Fixed
- Fix build on macOS 10.11- (fixes [#78](https://github.com/NoiseByNorthwest/php-spx/pull/78))


## [v0.3.0](https://github.com/NoiseByNorthwest/php-spx/compare/0.2.0...0.3.0)

### Added
- Improve documentation around web UI requirements (fixes [#54](https://github.com/NoiseByNorthwest/php-spx/issues/54))
- Web UI: Add custom color scheme management (@orls [#46](https://github.com/NoiseByNorthwest/php-spx/pull/46))
- Control panel: output command line prefix according to current setup
- Analysis screen: improve loading performance a bit
- Analysis screen: improve loading progress dialog
- Analysis screen: add cumulative cost computation and fix flat profile
- percentage columns (fixes [#41](https://github.com/NoiseByNorthwest/php-spx/issues/41))
- Analysis screen: display bars in flat profile percentage columns (fixes [#40](https://github.com/NoiseByNorthwest/php-spx/issues/40))
- Add request shutdown tracing
- Add script compilation tracing
- Metrics: add GC run count
- Metrics: add GC collected cycles count
- Metrics: add included file count
- Metrics: add included line count
- Metrics: add user class count
- Metrics: add user function count
- Metrics: add user opcode count

### Fixed
- Fix ownership issue (to stick to PHP coding standard)
- Fix call of non reentrant `exit()` function in a signal handler (fixes [#42](https://github.com/NoiseByNorthwest/php-spx/issues/42))
- Web UI / analysis screen: improved layout


## [v0.2.0](https://github.com/NoiseByNorthwest/php-spx/compare/0.1.2...0.2.0)

### Added
- Add web UI ([#14](https://github.com/NoiseByNorthwest/php-spx/pull/14))
- Add cookie based settings ([#3](https://github.com/NoiseByNorthwest/php-spx/issues/3))
- Improve Linux timer precision (1us -> 1ns)
- Improve accuracy by evaluating and then substracting probes overhead

## Changed
- Remove Google Trace Event report type ([#10](https://github.com/NoiseByNorthwest/php-spx/issues/10))
- Remove Callgrind report type ([#11](https://github.com/NoiseByNorthwest/php-spx/issues/11))


## [v0.1.2](https://github.com/NoiseByNorthwest/php-spx/compare/0.1.2...0.1.2)

### Added
- Add macOS support ([orls](https://github.com/orls) in [#13](https://github.com/NoiseByNorthwest/php-spx/pull/13))
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# SPX - A simple profiler for PHP

[![Build Status](https://api.travis-ci.com/NoiseByNorthwest/php-spx.svg?branch=master)](https://app.travis-ci.com/github/NoiseByNorthwest/php-spx) ![Supported PHP versions: 5.6 .. 8.x](https://img.shields.io/badge/php-5.6--8.1-blue.svg) ![Supported platforms: GNU/Linux, macOS & FreeBSD](https://img.shields.io/badge/platform-GNU/Linux%20|%20macOS%20|%20FreeBSD%20-yellow) ![Supported architectures: x86-64 or ARM64](https://img.shields.io/badge/architecture-x86--64%20|%20ARM64%20-silver)
[![Build Status][:badge-ci:]][:link-ci:]
![Supported PHP versions: 5.6 .. 8.x][:badge-php-versions:]
![Supported platforms: GNU/Linux, macOS & FreeBSD][:badge-supported-platforms:]
![Supported architectures: x86-64 or ARM64][:badge-supported-arch:]
[![License][:badge-license:]][:link-license:]


<a href="https://www.buymeacoffee.com/noisebynw" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
Expand Down Expand Up @@ -427,3 +431,19 @@ I have found lot of inspiration and hints reading:
- [XHProf](https://github.com/phacility/xhprof)
- [Xdebug](https://github.com/xdebug/xdebug)
- [PHP](https://github.com/php/php-src)

## License

**SPX** is open source software licensed under the GNU General Public License (GPL-3).
See the [LICENSE][:link-license:] file for more information.

<!-- All external links should be here to avoid duplication and long lines with links -->
[:badge-ci:]: https://github.com/NoiseByNorthwest/php-spx/actions/workflows/main.yml/badge.svg
[:link-ci:]: https://github.com/NoiseByNorthwest/php-spx/actions/workflows/main.yml

[:badge-php-versions:]: https://img.shields.io/badge/php-5.6--8.1-blue.svg
[:badge-supported-platforms:]: https://img.shields.io/badge/platform-GNU/Linux%20|%20macOS%20|%20FreeBSD%20-yellow
[:badge-supported-arch:]: https://img.shields.io/badge/architecture-x86--64%20|%20ARM64%20-silver

[:badge-license:]: https://img.shields.io/github/license/NoiseByNorthwest/php-spx
[:link-license:]: https://github.com/NoiseByNorthwest/php-spx/blob/master/LICENSE