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

Refactor for SSP 2.0.x bis #8

Open
wants to merge 8 commits 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
243 changes: 243 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
---

name: CI

on: # yamllint disable-line rule:truthy
push:
branches: ['**']
paths-ignore:
- '**.md'
pull_request:
branches: [master, release-*]
paths-ignore:
- '**.md'
workflow_dispatch:

jobs:
linter:
name: Linter
runs-on: ['ubuntu-latest']

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter/slim@v4
env:
LOG_LEVEL: NOTICE
VALIDATE_ALL_CODEBASE: true
LINTER_RULES_PATH: 'tools/linters'
VALIDATE_CSS: true
VALIDATE_JAVASCRIPT_ES: true
VALIDATE_JSON: true
VALIDATE_PHP_BUILTIN: true
VALIDATE_YAML: true
VALIDATE_XML: true
VALIDATE_GITHUB_ACTIONS: true

quality:
name: Quality control
runs-on: [ubuntu-latest]

steps:
- name: Setup PHP, with composer and extensions
id: setup-php
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
# Should be the higest supported version, so we can use the newest tools
php-version: '8.2'
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
# optional performance gain for psalm: opcache
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, posix, spl, xml

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- uses: actions/checkout@v3

- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Check code for hard dependencies missing in composer.json
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json

- name: Check code for unused dependencies in composer.json
run: composer-unused

- name: PHP Code Sniffer
run: phpcs

- name: Psalm
continue-on-error: true
run: |
psalm -c psalm.xml \
--show-info=true \
--shepherd \
--php-version=${{ steps.setup-php.outputs.php-version }}

- name: Psalm (testsuite)
run: |
psalm -c psalm-dev.xml \
--show-info=true \
--shepherd \
--php-version=${{ steps.setup-php.outputs.php-version }}

- name: Psalter
run: |
psalm --alter \
--issues=UnnecessaryVarAnnotation \
--dry-run \
--php-version=${{ steps.setup-php.outputs.php-version }}

security:
name: Security checks
runs-on: [ubuntu-latest]
steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
# Should be the lowest supported version
php-version: '8.0'
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
tools: composer
coverage: none

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- uses: actions/checkout@v3

- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Security check for locked dependencies
run: composer audit

- name: Update Composer dependencies
run: composer update --no-progress --prefer-dist --optimize-autoloader

- name: Security check for updated dependencies
run: composer audit

unit-tests-linux:
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
runs-on: ${{ matrix.operating-system }}
needs: [linter, quality, security]
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.0', '8.1', '8.2']

steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
tools: composer
ini-values: error_reporting=E_ALL
coverage: pcov

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v3

- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run unit tests with coverage
if: ${{ matrix.php-versions == '8.2' }}
run: vendor/bin/phpunit

- name: Run unit tests (no coverage)
if: ${{ matrix.php-versions != '8.2' }}
run: vendor/bin/phpunit --no-coverage

- name: Save coverage data
if: ${{ matrix.php-versions == '8.2' }}
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: ${{ github.workspace }}/build

coverage:
name: Code coverage
runs-on: [ubuntu-latest]
needs: [unit-tests-linux]
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: coverage-data
path: ${{ github.workspace }}/build

# requires codecov.io account
# - name: Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true
# verbose: true

cleanup:
name: Cleanup artifacts
needs: [unit-tests-linux, coverage]
runs-on: [ubuntu-latest]
if: |
always() &&
needs.coverage.result == 'success' &&
(needs.unit-tests-linux == 'success' || needs.coverage == 'skipped')

steps:
- uses: geekyeggo/delete-artifact@v2
with:
name: coverage-data
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
*~
vendor
.phpunit.result.cache
.phpunit.cache
composer.lock
composer.phar
/vendor/
/build/
.idea
*~

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
15 changes: 15 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
;
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'@PSR4' => true,
'@PSR5' => true,
])
->setFinder($finder)
;
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ php:
- 5.5
- 5.6
- 7.0
- 7.4
- 8.1
- hhvm
matrix:
allow_failures:
Expand Down
25 changes: 19 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@
"description": "Filter to remove attribute values which are not properly scoped.",
"keywords": [ "simplesamlphp", "scope", "sp", "module", "filter" ],
"type": "simplesamlphp-module",
"autoload": {
"psr-4": {
"SimpleSAML\\Module\\attributescope\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"SimpleSAML\\Test\\Utils\\": "vendor/simplesamlphp/simplesamlphp/tests/Utils"
}
},
"require": {
"simplesamlphp/composer-module-installer": "^1.1"
"php": ">=7.4 || ^8.0",
"simplesamlphp/simplesamlphp": "^2.0.0",
"simplesamlphp/composer-module-installer": "^1.3.2"
},
"require-dev": {
"simplesamlphp/simplesamlphp": "1.14",
"phpunit/phpunit": "~4.8.35"
},
"autoload-dev": {
"files": ["tests/_autoload_modules.php"]
"simplesamlphp/simplesamlphp-test-framework": "^1.2.1"
},
"support": {
"issues": "https://github.com/NIIF/simplesamlphp-module-attributescope/issues",
"source": "https://github.com/NIIF/simplesamlphp-module-attributescope"
},
"config": {
"allow-plugins": {
"simplesamlphp/composer-module-installer": true
}
}
}
Loading