Skip to content

Commit

Permalink
MNT Resolve CI problems
Browse files Browse the repository at this point in the history
- Tell phpcs what to sniff
- Throw a hard error if we can't bootstrap tests correctly
- Force Tokens.php to be run for constant declarations
  • Loading branch information
GuySartorelli committed Nov 13, 2023
1 parent 47f0c4d commit a125d4d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SS_DATABASE_CLASS="MySQLDatabase"
SS_DATABASE_PORT="3380"
SS_DATABASE_SERVER="127.0.0.1"
SS_DATABASE_USERNAME="root"
SS_DATABASE_PASSWORD="root"
SS_ENVIRONMENT_TYPE="dev"
SS_DATABASE_NAME="SS_mysite"
SS_DEFAULT_ADMIN_USERNAME="admin"
SS_DEFAULT_ADMIN_PASSWORD="password"
SS_TRUSTED_PROXY_IPS="*"
SS_MFA_SECRET_KEY="1234567894175b99966561e1efe237e4"
SS_BASE_URL="http://localhost"
11 changes: 7 additions & 4 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0"?>
<ruleset name="PSR12">
<rule ref="PSR12"/>
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>tests/bootstrap\.php</exclude-pattern>
</rule>
<rule ref="PSR12"/>
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>tests/bootstrap\.php</exclude-pattern>
</rule>

<file>./src</file>
<file>./tests</file>
</ruleset>
10 changes: 10 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

// php_codesniffer autoloader

use PHP_CodeSniffer\Util\Tokens;

$autoloadCandidates = [
// running from package itself as root
__DIR__ . '/../vendor/squizlabs/php_codesniffer/autoload.php',
Expand All @@ -17,6 +20,13 @@
}
}

if (!$autoloaded) {
throw new RuntimeException("Couldn't find autoloader");
}

// Required to correctly run constant definitions in CI, though not needed locally for some reason.
Tokens::$operators;

if (!defined('PHP_CODESNIFFER_VERBOSITY')) {
define('PHP_CODESNIFFER_VERBOSITY', 0);
}
Expand Down

0 comments on commit a125d4d

Please sign in to comment.