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 for testing, and automatic phar creation #46

Merged
merged 3 commits into from
Mar 27, 2021
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
115 changes: 115 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build and test phar

on:
push:
tags:
- 'v*'

jobs:
bundle:
name: Bundle binary
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 5.4
extensions: exif, phar, openssl
coverage: false
ini-values: phar.readonly=Off

- name: Install Box from GitHub
run: |
curl -LSs https://box-project.github.io/box2/installer.php | php
test -f ./box.phar
test -d ~/bin || mkdir ~/bin
mv ./box.phar ~/bin/box
~/bin/box -V
echo "$HOME/bin" >> $GITHUB_PATH

- name: Install Composer dependencies
uses: ramsey/composer-install@v1

- name: Building binary...
run: box build -v

- uses: actions/upload-artifact@v2
with:
name: parallel-lint-phar
path: ./parallel-lint.phar

verify:
name: Validate binary on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental == true }}
needs:
- bundle

strategy:
matrix:
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'

include:
- php: '8.1'
experimental: true

steps:
- name: Checkout code
uses: actions/checkout@v2

- uses: actions/download-artifact@v2
with:
name: parallel-lint-phar

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

- name: Run linter against codebase
run: php ./parallel-lint.phar src/

publish:
name: Add binary to release
runs-on: ubuntu-latest
needs:
- bundle
- verify

steps:
- uses: actions/download-artifact@v2
with:
name: parallel-lint-phar

- name: Draft Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false

- name: Upload Phar as Release Asset
id: upload-release-asset
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: parallel-lint.phar
127 changes: 127 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Run unit and style tests

on:
pull_request:
push:
branches:
- develop
- master

jobs:
lint:
name: Run style linter
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: json
coverage: none

- name: Checkout code
uses: actions/checkout@v2

- name: Install Composer dependencies
uses: ramsey/composer-install@v1

- name: Run code sniffer
run: vendor/bin/phpcs

test:
name: Run unit tests
runs-on: ubuntu-latest

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 5.4
extensions: json, tokenizer

- name: Checkout code
uses: actions/checkout@v2

- name: Install Composer dependencies
uses: ramsey/composer-install@v1

- name: Run tests
run: composer test

bundle:
name: Bundle binary
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 5.4
extensions: exif, phar, openssl
coverage: false
ini-values: phar.readonly=Off

- name: Install Box from GitHub
run: |
curl -LSs https://box-project.github.io/box2/installer.php | php
test -f ./box.phar
test -d ~/bin || mkdir ~/bin
mv ./box.phar ~/bin/box
~/bin/box -V
echo "$HOME/bin" >> $GITHUB_PATH

- name: Install Composer dependencies
uses: ramsey/composer-install@v1

- name: Building binary...
run: box build -v

- uses: actions/upload-artifact@v2
with:
name: parallel-lint-phar
path: ./parallel-lint.phar

verify-bundle:
name: Validate binary on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental == true }}
needs:
- bundle

strategy:
matrix:
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'

include:
- php: '8.1'
experimental: true

steps:
- name: Checkout code
uses: actions/checkout@v2

- uses: actions/download-artifact@v2
with:
name: parallel-lint-phar

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

- name: Run linter against codebase
run: php ./parallel-lint.phar src/
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"Herrera\\Box\\Compactor\\Php"
],
"extract": false,
"main": "parallel-lint.php",
"main": "parallel-lint",
"files": [
"LICENSE"
],
Expand Down