Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ghalse committed May 20, 2024
1 parent b288736 commit 532fbe9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 55 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4']
php-versions: ['8.1']

steps:
- name: Setup PHP, with composer and extensions
Expand All @@ -36,19 +36,18 @@ jobs:
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: create local config
run: cp local/config.inc.php-sample local/config.inc.php

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

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

Expand All @@ -59,7 +58,7 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Decide whether to run code coverage or not
if: ${{ matrix.php-versions != '7.4' || matrix.operating-system != 'ubuntu-latest' }}
if: ${{ matrix.php-versions != '8.1' || matrix.operating-system != 'ubuntu-latest' }}
run: |
echo "NO_COVERAGE=--no-coverage" >> $GITHUB_ENV
Expand All @@ -69,8 +68,8 @@ jobs:
./vendor/bin/phpunit $NO_COVERAGE
- name: Save coverage data
if: ${{ matrix.php-versions == '7.4' && matrix.operating-system == 'ubuntu-latest' }}
uses: actions/upload-artifact@v1
if: ${{ matrix.php-versions == '8.1' && matrix.operating-system == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: build-data
path: ${{ github.workspace }}/build
Expand All @@ -84,36 +83,39 @@ jobs:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '7.4'
php-version: '8.1'
tools: composer:v2
extensions: ldap, mbstring, xml

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

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

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

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
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

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

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

- name: PHP Code Sniffer
continue-on-error: true
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ local/config.inc.php
composer.lock
build/
vendor/
.phpunit.result.cache
.phpunit.cache/
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@
"config": {
"preferred-install": {
"*": "dist"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"require": {
"php": ">=7.4 | ^8.0",
"php": "^8.1",
"ext-xml": "*",
"ext-dom": "*",
"ext-pcre": "*",
"ext-json": "*",
"jeremykendall/php-domain-parser": "~6.0.0"
"jeremykendall/php-domain-parser": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.27",
"squizlabs/php_codesniffer": "^3.7"
"vimeo/psalm": "^5.23",
"slevomat/coding-standard": "^8.15"
},
"support": {
"issues": "https://github.com/tenet-ac-za/metadata-validator/issues",
Expand Down
15 changes: 15 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<ruleset name="metadata-validator ruleset">
<description>
By default it is less stringent about long lines than other coding standards
</description>

<file>.</file>
<!-- Use this to exclude paths. You can have multiple patterns -->
<exclude-pattern>*/*\.(css|js)$</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/local/config.inc.php</exclude-pattern>

<!-- This is the rule we inherit from. If you want to exclude some specific rules, see the docs on how to do that -->
<rule ref="PSR12"/>
</ruleset>
24 changes: 13 additions & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="false">
<include>
<directory suffix=".php">.</directory>
</include>
<exclude>
<directory suffix=".php">vendor</directory>
<directory suffix=".php">tests</directory>
<file>local/config.inc.php</file>
</exclude>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/>
Expand All @@ -22,6 +14,16 @@
</testsuites>
<logging/>
<php>
<env name="TZ" value="UTC" force="true" />
<env name="TZ" value="UTC" force="true"/>
</php>
<source>
<include>
<directory suffix=".php">.</directory>
</include>
<exclude>
<directory suffix=".php">vendor</directory>
<directory suffix=".php">tests</directory>
<file>local/config.inc.php</file>
</exclude>
</source>
</phpunit>
29 changes: 8 additions & 21 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
<?xml version="1.0"?>
<psalm
name="metadata-validator"
name="metadata validator"
useDocblockTypes="true"
totallyTyped="false"
hideExternalErrors="true"
allowStringToStandInForClass="true"
errorLevel="2"
reportMixedIssues="false"
>
<projectFiles>
<directory name="." />
<ignoreFiles>
<directory name="vendor" />
<directory name="vendor/" />
<file name="local/config.inc.php" />
</ignoreFiles>
</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" />
Expand All @@ -34,14 +28,7 @@
<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>

0 comments on commit 532fbe9

Please sign in to comment.