Skip to content

Commit

Permalink
Merge pull request #19 from cs278/polyfill-nightmare-redux
Browse files Browse the repository at this point in the history
Workaround polyfill not being loaded
  • Loading branch information
cs278 authored Jul 27, 2021
2 parents 6a1c261 + 27c5d57 commit b09e0b4
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 7 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/smokes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Smoke Tests

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
php:
- '7.4'
- '8.0'
deps:
- highest
- lowest
fail-fast: true
name: PHP ${{ matrix.php }} / ${{ matrix.deps }}
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@4067ce8b814db5bfc731c8906aa3034f28911e9f
with:
php-version: ${{ matrix.php }}
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Enable assertions
run: echo 'zend.assertions=1' | sudo tee /etc/php/${{ matrix.php }}/cli/conf.d/assert.ini >/dev/null
- name: "Issue #18"
run: |
export COMPOSER_CACHE_DIR="$(composer global config cache-dir)"
export COMPOSER_HOME="$(mktemp -d)"
composer global config repositories.0 path "$(pwd)"
composer global require cs278/composer-audit:@dev
cd "$(mktemp -d)"
composer require --no-install cs278/mktemp
composer audit -vvv
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"symfony/phpunit-bridge": "^5.2",
"symfony/process": "^4.4 || ^5"
},
"conflict": {
"symfony/yaml": "~4.4.27 || ~5.2.12 || ~5.3.4"
},
"autoload": {
"psr-4": {
"Cs278\\ComposerAudit\\": "src"
Expand Down
17 changes: 15 additions & 2 deletions src/AuditCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(sprintf(
'Checking <info>%s</info> (<info>%s</info>) for advisories...',
$name,
$name !== 'cs278/composer-audit' ? $version : 'N/A'
!self::isUnderTest() ? $version : 'N/A'
), OutputInterface::VERBOSITY_DEBUG);

foreach ($advisoriesManager->findByPackageNameAndVersion($name, $version) as $advisory) {
Expand All @@ -139,7 +139,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'Found %u advisories for <info>%s</info> (<info>%s</info>)',
\count($advisories[$name]),
$name,
$name !== 'cs278/composer-audit' ? $version : 'N/A'
!self::isUnderTest() ? $version : 'N/A'
), OutputInterface::VERBOSITY_VERY_VERBOSE);
}
}
Expand Down Expand Up @@ -300,4 +300,17 @@ private static function clearLine(OutputInterface $output): void
$output->writeln('');
}
}

/**
* Check if the command is being run by the test suite.
*
* This is used to hide version information which will go stale as new packages
* are published.
*/
private static function isUnderTest(): bool
{
$value = filter_var(getenv('COMPOSER_AUDIT_TEST'), \FILTER_VALIDATE_BOOLEAN);

return $value !== null ? $value : false;
}
}
1 change: 1 addition & 0 deletions tests/integration/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function testRun(int $expectedExit, string $expectedOutput, string $condi
return new Process($args, $workingDir, [
'COMPOSER_HOME' => $workingDir.'/.composer',
'COMPOSER_CACHE_DIR' => self::$cacheDir,
'COMPOSER_AUDIT_TEST' => 1,
]);
};

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ignore--broken-show-warnings.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ true
Ignoring invalid ignore rule: `{"type":"package","value":"foo\/bar"}`
Ignoring invalid ignore rule: `{"type":"cve","value":""}`
Ignoring invalid ignore rule: `{"type":"","value":"test"}`
Found 9 advisories for symfony/http-foundation (2.0.4)
Found 9 advisories for symfony/http-foundation (N/A)
Found 9 advisories affecting 1 package(s).

composer://symfony/http-foundation (2.0.4)
Expand Down
7 changes: 3 additions & 4 deletions tests/integration/verbose_debug_no_errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ true
0
--EXPECT-OUTPUT--
Checking cs278/composer-audit (N/A) for advisories...
Checking symfony/deprecation-contracts (v2.4.0) for advisories...
Checking symfony/polyfill-ctype (v1.23.0) for advisories...
Checking symfony/polyfill-php80 (v1.23.0) for advisories...
Checking symfony/yaml (v5.3.4) for advisories...
Checking symfony/deprecation-contracts (N/A) for advisories...
Checking symfony/polyfill-ctype (N/A) for advisories...
Checking symfony/yaml (N/A) for advisories...
No advisories found for any packages.

0 comments on commit b09e0b4

Please sign in to comment.