Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ghalse committed Oct 10, 2022
1 parent 8fd3128 commit d858f54
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 46 deletions.
50 changes: 28 additions & 22 deletions .github/workflows/php.yml
Expand Up @@ -3,8 +3,12 @@ name: CI
on:
push:
branches: [ '**' ]
paths-ignore:
- '**.md'
pull_request:
branches: [ master, development, release-* ]
branches: [ master, release-* ]
paths-ignore:
- '**.md'

jobs:
basic-tests:
Expand All @@ -13,17 +17,18 @@ jobs:
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest]
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.0']

steps:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
coverage: pcov
extensions: intl, mbstring, xml
ini-values: error_reporting=E_ALL
php-version: ${{ matrix.php-versions }}
extensions: ldap, mbstring, xml
tools: composer:v2
coverage: pcov

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
Expand All @@ -36,14 +41,14 @@ jobs:
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -70,7 +75,7 @@ jobs:
- name: Save coverage data
if: ${{ matrix.php-versions == '7.4' && matrix.operating-system == 'ubuntu-latest' }}
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v3
with:
name: build-data
path: ${{ github.workspace }}/build
Expand All @@ -83,21 +88,21 @@ jobs:
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '7.4'
extensions: mbstring, xml
tools: composer:v2
extensions: ldap, mbstring, xml
coverage: none

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

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -107,13 +112,13 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Security check for locked dependencies
uses: symfonycorp/security-checker-action@v2
uses: symfonycorp/security-checker-action@v3

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

- name: Security check for updated dependencies
uses: symfonycorp/security-checker-action@v2
uses: symfonycorp/security-checker-action@v3

sanity-check:
name: Sanity checks
Expand All @@ -124,21 +129,21 @@ jobs:
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '7.4'
extensions: mbstring, xml
tools: composer:v2
extensions: ldap, mbstring, xml
coverage: none

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

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -160,23 +165,24 @@ jobs:

steps:
- name: Setup PHP, with composer and extensions
id: setup-php
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '7.4'
tools: composer:v2
extensions: ldap, mbstring, xml
extensions: mbstring, xml

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

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -185,22 +191,22 @@ jobs:
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

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

- name: Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3

- name: PHP Code Sniffer
continue-on-error: true
run: php vendor/bin/phpcs

- name: Psalm
continue-on-error: true
run: php vendor/bin/psalm --show-info=true
run: php vendor/bin/psalm --show-info=true --shepherd --php-version=${{ steps.setup-php.outputs.php-version }}

- name: Psalter
continue-on-error: true
run: php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run
run: php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run --php-version=${{ steps.setup-php.outputs.php-version }}
15 changes: 15 additions & 0 deletions .php_cs.dist
@@ -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)
;
17 changes: 17 additions & 0 deletions codecov.yml
@@ -0,0 +1,17 @@
coverage:
status:
project:
default:
target: 0%
threshold: 2%
patch: off
comment:
layout: "diff"
behavior: once
require_changes: true
require_base: no
require_head: yes
branches: null

github_checks:
annotations: false
5 changes: 4 additions & 1 deletion composer.json
Expand Up @@ -12,10 +12,12 @@
],
"config": {
"preferred-install": {
"simplesamlphp/simplesamlphp": "source",
"*": "dist"
},
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"simplesamlphp/composer-module-installer": true
}
},
Expand All @@ -25,8 +27,9 @@
},
"require-dev": {
"simplesamlphp/simplesamlphp": ">=1.19",
"simplesamlphp/simplesamlphp-test-framework": "~0.1.0"
"simplesamlphp/simplesamlphp-test-framework": "~1.1.4"
},

"autoload": {
"psr-4": {
"SimpleSAML\\Module\\genuniqueid\\": "lib/"
Expand Down
18 changes: 18 additions & 0 deletions phpcs.xml
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<ruleset name="SimpleSAMLphp module ruleset">
<config name="ignore_warnings_on_exit" value="1"/>

<description>
By default it is less stringent about long lines than other coding standards
</description>

<file>lib</file>
<file>tests</file>

<!-- Use this to exclude paths. You can have multiple patterns -->
<!--<exclude-pattern>*/tests/*</exclude-pattern>-->
<!--<exclude-pattern>*/other/*</exclude-pattern>-->

<!-- This is the rule we inherit from. If you want to exlude some specific rules, see the docs on how to do that -->
<rule ref="PSR12"/>
</ruleset>
31 changes: 9 additions & 22 deletions psalm.xml
@@ -1,47 +1,34 @@
<?xml version="1.0"?>
<psalm
name="simplesaml-module-safire"
name="SimpleSAMLphp module"
useDocblockTypes="true"
totallyTyped="false"
hideExternalErrors="true"
allowStringToStandInForClass="true"
>
<projectFiles>
<!-- <directory name="config-templates" /> -->
<directory name="hooks" />
<directory name="lib" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
<directory name="templates" />
<directory name="www" />
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<!-- level 3 issues - slightly lazy code writing, but probably low false-negatives -->
<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />

<RawObjectIteration errorLevel="info" />
<UnusedClass errorLevel="info" />
<PossiblyUnusedMethod errorLevel="info" />
</issueHandlers>
</psalm>
5 changes: 4 additions & 1 deletion tests/bootstrap.php
@@ -1,9 +1,12 @@
<?php

declare(strict_types=1);

$projectRoot = dirname(__DIR__);
require_once($projectRoot . '/vendor/autoload.php');

// Symlink module into ssp vendor lib so that templates and urls can resolve correctly
$linkPath = $projectRoot . '/vendor/simplesamlphp/simplesamlphp/modules/consent';
$linkPath = $projectRoot . '/vendor/simplesamlphp/simplesamlphp/modules/genuniqueid';
if (file_exists($linkPath) === false) {
echo "Linking '$linkPath' to '$projectRoot'\n";
symlink($projectRoot, $linkPath);
Expand Down

0 comments on commit d858f54

Please sign in to comment.