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

use github workflow #500

Merged
merged 2 commits into from
Dec 21, 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
208 changes: 208 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
name: CI

on:
push:
branches:
- master
pull_request:

env:
VARNISH_VERSION: '6.6'
VARNISH_MODULES_VERSION: '0.18.0'
DEPENDENCIES: 'toflar/psr6-symfony-http-cache-store:^2.2.0|^3.0.0'
SYMFONY_DEPRECATIONS_HELPER: 'max[self]=0'
SYMFONY_PHPUNIT_VERSION: '8'

jobs:
latest:
name: PHP ${{ matrix.php }} Varnish 6
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- php: '7.2'
- php: '7.3'
- php: '7.4'
env:
DEPENDENCIES: 'symfony/lts:^3 toflar/psr6-symfony-http-cache-store:^2.2.0\|^3.0.0'
- php: '7.4'
env:
DEPENDENCIES: 'symfony/flex'
SYMFONY_VERSION: '^4'
- php: '8.0'
- php: '8.1'

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

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

- name: Setup Varnish and Nginx
run: |
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-varnish.sh
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-nginx.sh

- name: Install composer dependencies
run: |
composer require --no-update ${DEPENDENCIES}
composer update --prefer-dist --no-interaction --no-progress
vendor/bin/simple-phpunit install

- name: Execute tests
run: vendor/bin/simple-phpunit -v

# spent hours trying to make this work
# unfortunately, the installation always picks the varnish 5 from ubuntu instead of the specified one
# installing with `apt-get install varnish=${VARNISH_VERSION}.*` reports that the version is not found
Copy link
Contributor Author

@dbu dbu Dec 21, 2021

Choose a reason for hiding this comment

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

i gave up on this for now, to move forward => #510

#
# varnish5:
# name: PHP ${{ matrix.php }} Legacy Varnish 5
# runs-on: ubuntu-18.04
# env:
# VARNISH_VERSION: '5.1'
# VARNISH_MODULES_VERSION: '0.14.0'
#
# strategy:
# fail-fast: false
# matrix:
# include:
# - php: '7.4'
#
# steps:
# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: ${{ matrix.php }}
# tools: composer:v2
# coverage: none
#
# - name: Checkout code
# uses: actions/checkout@v2
#
# - name: Setup Varnish and Nginx
# run: |
# sh ${GITHUB_WORKSPACE}/.github/workflows/setup-varnish-legacy.sh
# sh ${GITHUB_WORKSPACE}/.github/workflows/setup-nginx.sh
#
# - name: Install composer dependencies
# run: |
# composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
# vendor/bin/simple-phpunit install
#
# - name: Execute tests
# run: vendor/bin/simple-phpunit -v
#
# varnish4:
# name: PHP ${{ matrix.php }} Legacy Varnish 4
# runs-on: ubuntu-18.04
# env:
# VARNISH_VERSION: '4.1'
# VARNISH_MODULES_VERSION: '0.9.1'
#
# strategy:
# fail-fast: false
# matrix:
# include:
# - php: '7.4'
#
# steps:
# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: ${{ matrix.php }}
# tools: composer:v2
# coverage: none
#
# - name: Checkout code
# uses: actions/checkout@v2
#
# - name: Setup Varnish and Nginx
# run: |
# sh ${GITHUB_WORKSPACE}/.github/workflows/setup-varnish-legacy.sh
# sh ${GITHUB_WORKSPACE}/.github/workflows/setup-nginx.sh
#
# - name: Install composer dependencies
# run: |
# composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
# vendor/bin/simple-phpunit install
#
# - name: Execute tests
# run: vendor/bin/simple-phpunit -v
#
# lowest:
# name: PHP ${{ matrix.php }} Lowest, Varnish 3
# runs-on: ubuntu-18.04
# env:
# VARNISH_VERSION: '3.0'
# VARNISH_MODULES_VERSION: ''
# DEPENDENCIES: ''
#
# strategy:
# fail-fast: false
# matrix:
# php: ['7.2']
#
# steps:
# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: ${{ matrix.php }}
# tools: composer:v2
# coverage: none
#
# - name: Checkout code
# uses: actions/checkout@v2
#
# - name: Setup Varnish and Nginx
# run: |
# sh ${GITHUB_WORKSPACE}/.github/workflows/setup-varnish-legacy.sh
# sh ${GITHUB_WORKSPACE}/.github/workflows/setup-nginx.sh
#
# - name: Install composer dependencies
# run: |
# composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
# vendor/bin/simple-phpunit install
#
# - name: Execute tests
# run: vendor/bin/simple-phpunit -v

coverage:
name: Code Coverage
runs-on: ubuntu-20.04

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2
coverage: xdebug

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

- name: Setup Varnish and Nginx
run: |
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-varnish.sh
sh ${GITHUB_WORKSPACE}/.github/workflows/setup-nginx.sh

- name: Install dependencies
run: |
composer require "friends-of-phpspec/phpspec-code-coverage:^4.3.2" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-progress
vendor/bin/simple-phpunit install

- name: Execute tests
run: vendor/bin/simple-phpunit -v --coverage-text

- name: Upload coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml
7 changes: 7 additions & 0 deletions .github/workflows/setup-nginx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e
# Install NGINX
sudo apt-get remove nginx
sudo rm /usr/sbin/nginx
sh "${GITHUB_WORKSPACE}/tests/install-nginx.sh"
8 changes: 8 additions & 0 deletions .github/workflows/setup-varnish-legacy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e
echo "### Installing Legacy Varnish $VARNISH_VERSION ###"
VARNISH_VERSION=$VARNISH_VERSION bash -c 'curl -s https://packagecloud.io/install/repositories/varnishcache/varnish${VARNISH_VERSION//./}/script.deb.sh' | sudo bash
# this is broken: we don't find the version. when not specifying the version, we end up with varnish 5 from the regular ubuntu distribution
VARNISH_VERSION=$VARNISH_VERSION bash -c 'sudo apt-get install varnish=${VARNISH_VERSION}.*'
if [ "$VARNISH_MODULES_VERSION" != "" ]; then sh "${GITHUB_WORKSPACE}/tests/install-varnish-modules-legacy.sh"; fi
7 changes: 7 additions & 0 deletions .github/workflows/setup-varnish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e
echo "### Installing Varnish $VARNISH_VERSION ###"
VARNISH_VERSION=$VARNISH_VERSION bash -c 'curl -s https://packagecloud.io/install/repositories/varnishcache/varnish${VARNISH_VERSION//./}/script.deb.sh' | sudo bash
sudo apt-get install -t focal varnish
if [ "$VARNISH_MODULES_VERSION" != "" ]; then sh "${GITHUB_WORKSPACE}/tests/install-varnish-modules.sh"; fi
94 changes: 0 additions & 94 deletions .travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions phpstan.tests.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@ parameters:
level: 1
paths:
- tests
ignoreErrors:
# we can add the return type declaration when dropping support for PHP < 7.4
- '#Method FOS\\HttpCache\\Tests\\Unit\\SymfonyCache\\AppCache::fetch\(\) should return Symfony\\Component\\HttpFoundation\\Response but return statement is missing.#'
- '#Method FOS\\HttpCache\\Tests\\Functional\\Symfony\\AppCache::fetch\(\) should return Symfony\\Component\\HttpFoundation\\Response but return statement is missing.#'
2 changes: 1 addition & 1 deletion src/EventListener/LogListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(LoggerInterface $logger)
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
Events::PROXY_UNREACHABLE_ERROR => 'onProxyUnreachableError',
Expand Down
5 changes: 3 additions & 2 deletions src/ResponseTagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,16 @@ public function hasTags()
*
* This must be called before any HTTP response is sent to the client.
*
* @param array $tags List of tags to add
* @param string[] $tags List of tags to add
*
* @throws InvalidTagException
*
* @return $this
*/
public function addTags(array $tags)
{
$filtered = array_filter($tags, 'strlen');
$filtered = array_filter($tags, 'is_string');
$filtered = array_filter($filtered, 'strlen');

if ($this->options['strict'] && array_diff($tags, $filtered)) {
throw new InvalidTagException('Empty tags are not allowed');
Expand Down
2 changes: 1 addition & 1 deletion src/SymfonyCache/CleanupCacheTagsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function removeTagsHeader(CacheEvent $e)
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
Events::POST_HANDLE => 'removeTagsHeader',
Expand Down
2 changes: 1 addition & 1 deletion src/SymfonyCache/CustomTtlListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function cleanResponse(CacheEvent $e)
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
Events::PRE_STORE => 'useCustomTtl',
Expand Down
2 changes: 1 addition & 1 deletion src/SymfonyCache/DebugListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DebugListener implements EventSubscriberInterface
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
Events::POST_HANDLE => 'handleDebug',
Expand Down
Loading