Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Migrate CI for Travis to GitHub Actions #76

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on:
push:
pull_request:

permissions:
contents: read

jobs:
check_composer:
name: Check composer.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.0'
- run: composer validate --strict --no-check-lock

phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '7.4'
- name: Install dependencies
run: composer update --ansi --no-progress --prefer-dist --no-interaction
- run: vendor/bin/phpstan analyze -l 5 src

psalm:
name: Psalm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '7.4'
- name: Install dependencies
run: composer update --ansi --no-progress --prefer-dist --no-interaction
- run: vendor/bin/psalm

tests:
name: "Tests on PHP ${{ matrix.php }}"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]

steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "${{ matrix.php }}"

- name: Install dependencies
run: composer update --ansi --no-progress --prefer-dist --no-interaction

- name: Run tests
run: vendor/bin/phpunit --colors=always
24 changes: 24 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Automatic update

on:
schedule:
- cron: '13 10 * * *' # Update once a day at 10:13 (chosen arbitrarily)

jobs:
update:
name: "Update regexes"
runs-on: ubuntu-latest
# Don't run it on forks that might enable Actions
if: github.repository == 'ua-parser/uap-php'

steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "7.4"

- name: Install dependencies
run: composer update --ansi --no-progress --prefer-dist --no-interaction

- run: ./ci/update.sh
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ua-parser PHP Library #

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ua-parser/uap-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/ua-parser/uap-php.svg?branch=master)](https://travis-ci.org/ua-parser/uap-php) [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/ua-parser/uap-php.svg)](http://isitmaintained.com/project/ua-parser/uap-php "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/ua-parser/uap-php.svg)](http://isitmaintained.com/project/ua-parser/uap-php "Percentage of issues still open")
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ua-parser/uap-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://github.com/ua-parser/uap-php/actions/workflows/ci.yml/badge.svg)](https://github.com/ua-parser/uap-php/actions/workflows/ci.yml) [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/ua-parser/uap-php.svg)](http://isitmaintained.com/project/ua-parser/uap-php "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/ua-parser/uap-php.svg)](http://isitmaintained.com/project/ua-parser/uap-php "Percentage of issues still open")
[![Latest Stable Version](https://poser.pugx.org/ua-parser/uap-php/v/stable)](https://packagist.org/packages/ua-parser/uap-php)
[![Total Downloads](https://poser.pugx.org/ua-parser/uap-php/downloads)](https://packagist.org/packages/ua-parser/uap-php)
[![License](https://poser.pugx.org/ua-parser/uap-php/license)](https://packagist.org/packages/ua-parser/uap-php)
Expand Down
23 changes: 6 additions & 17 deletions ci/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
set -x
set -e

if [ "$UPDATE_RESOURCES" != "true" ]; then
echo "Skip updating resources. UPDATE_RESOURCES not set to true"
exit 0
fi

test_prefix=""
if [ "$TRAVIS_BRANCH" != "master" ]; then
test_prefix=test-
fi

git submodule foreach git pull origin master --ff-only
bin/uaparser ua-parser:convert uap-core/regexes.yaml

Expand All @@ -20,21 +10,20 @@ if [[ ! `git status --porcelain` ]]; then
else
./vendor/bin/phpunit

git config --global user.email [email protected]
git config --global user.name "Travis CI"
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global user.name "github-actions[bot]"

git remote add upstream https://${GITHUB_TOKEN}@github.com/ua-parser/uap-php.git
git fetch upstream --tags
git fetch --tags

git status

git commit -m "Automatic resource update" uap-core resources/regexes.php
git push upstream ${TRAVIS_BRANCH}
git push

new_version=$test_prefix`git tag | sort --version-sort | tail -n 1 | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}'`
new_version=`git tag | sort --version-sort | tail -n 1 | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}'`

git tag $new_version
git push upstream $new_version
git push --tags

echo "$new_version published"
fi