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

Fix missing env in CI #178

Merged
merged 4 commits into from
May 28, 2020
Merged
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
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
env:
SCOUT_APM_KEY: ${{ secrets.SCOUT_APM_KEY }}
steps:
- uses: actions/checkout@v2
- name: "Install PHP"
uses: "shivammathur/setup-php@1.8.2"
uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
Expand All @@ -45,7 +47,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: "Install PHP"
uses: "shivammathur/setup-php@1.8.2"
uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "7.4"
Expand All @@ -60,7 +62,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: "Install PHP"
uses: "shivammathur/setup-php@1.8.2"
uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "7.4"
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 4.4.0 - 2020-05-27

### Added

- Nothing.

### Changed

- [#178](https://github.com/scoutapp/scout-apm-php/pull/178) Make GitLab Actions work for CI with SCOUT_APM_KEY
- [#177](https://github.com/scoutapp/scout-apm-php/pull/177) Updated dependencies (and allow ramsey/uuid ^4.0)

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.

## 4.3.0 - 2020-04-01

### Added
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@
<directory>./src/</directory>
</whitelist>
</filter>
<listeners>
<listener class="Scoutapm\IntegrationTests\CheckScoutApmKeyListener"></listener>
</listeners>
</phpunit>
2 changes: 1 addition & 1 deletion tests/Integration/AgentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function setUp() : void
// Note, env var name is intentionally inconsistent (i.e. not `SCOUT_KEY`) as we only want to affect this test
$this->scoutApmKey = getenv('SCOUT_APM_KEY');

if ($this->scoutApmKey === false) {
if ($this->scoutApmKey === false || $this->scoutApmKey === '') {
self::markTestSkipped('Set the environment variable SCOUT_APM_KEY to enable this test.');

return;
Expand Down
46 changes: 46 additions & 0 deletions tests/Integration/CheckScoutApmKeyListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace Scoutapm\IntegrationTests;

use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestListenerDefaultImplementation;
use PHPUnit\Framework\TestSuite;
use function getenv;
use function sprintf;
use function str_repeat;
use function strlen;
use function substr;

final class CheckScoutApmKeyListener implements TestListener
{
/** @var bool */
private $hasOutput = false;

private const SHOW_CHARACTERS_OF_KEY = 2;
use TestListenerDefaultImplementation;

public function startTestSuite(TestSuite $suite) : void
{
if ($this->hasOutput) {
return;
}

$scoutApmKey = getenv('SCOUT_APM_KEY');

if ($scoutApmKey === false || $scoutApmKey === '') {
echo "Running without SCOUT_APM_KEY configured, some tests will be skipped.\n\n";
$this->hasOutput = true;

return;
}

echo sprintf(
"Running with SCOUT_APM_KEY set %s%s\n\n",
substr($scoutApmKey, 0, self::SHOW_CHARACTERS_OF_KEY),
str_repeat('*', strlen($scoutApmKey) - self::SHOW_CHARACTERS_OF_KEY)
);
$this->hasOutput = true;
}
}
2 changes: 1 addition & 1 deletion tests/isolated-memory-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$scoutApmKey = getenv('SCOUT_APM_KEY');
$runCount = (int) getenv('RUN_COUNT');

if ($scoutApmKey === false || $runCount <= 0) {
if ($scoutApmKey === false || $scoutApmKey === '' || $runCount <= 0) {
echo "Try running: \n\n SCOUT_APM_KEY=abc123 RUN_COUNT=100 php tests/isolated-memory-test.php\n\n";
throw new RuntimeException('Set the environment variable SCOUT_APM_KEY to enable this test.');
}
Expand Down