mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Add some tracing when using GitHub Actions in CI
This commit is contained in:
parent
f0c30763d4
commit
0bc6d71173
13
.github/workflows/main.yml
vendored
13
.github/workflows/main.yml
vendored
@ -1,13 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
psalm:
|
||||
name: Psalm
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Psalm
|
||||
uses: docker://muglug/psalm-github-actions
|
||||
with:
|
||||
args: --shepherd
|
@ -45,7 +45,8 @@ class BuildInfoCollector
|
||||
->fillCircleCi()
|
||||
->fillAppVeyor()
|
||||
->fillJenkins()
|
||||
->fillScrutinizer();
|
||||
->fillScrutinizer()
|
||||
->fillGithubActions();
|
||||
|
||||
return $this->readEnv;
|
||||
}
|
||||
@ -235,4 +236,44 @@ class BuildInfoCollector
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Github Actions environment variables.
|
||||
*
|
||||
* @return $this
|
||||
* @psalm-suppress PossiblyUndefinedStringArrayOffset
|
||||
*/
|
||||
protected function fillGithubActions()
|
||||
{
|
||||
if (isset($this->env['GITHUB_ACTIONS'])) {
|
||||
$this->env['CI_NAME'] = 'github-actions';
|
||||
$this->env['CI_JOB_ID'] = $this->env['GITHUB_ACTIONS'];
|
||||
|
||||
$githubRef = (string) $this->env['GITHUB_REF'];
|
||||
if (\strpos($githubRef, 'refs/heads/') !== false) {
|
||||
$githubRef = \str_replace('refs/heads/', '', $githubRef);
|
||||
} elseif (strpos($githubRef, 'refs/tags/') !== false) {
|
||||
$githubRef = \str_replace('refs/tags/', '', $githubRef);
|
||||
}
|
||||
|
||||
$this->env['CI_BRANCH'] = $githubRef;
|
||||
|
||||
$this->readEnv['GITHUB_ACTIONS'] = $this->env['GITHUB_ACTIONS'];
|
||||
$this->readEnv['GITHUB_REF'] = $this->env['GITHUB_REF'];
|
||||
$this->readEnv['CI_NAME'] = $this->env['CI_NAME'];
|
||||
|
||||
if (isset($this->env['GITHUB_EVENT_PATH'])) {
|
||||
$event_json = \file_get_contents((string) $this->env['GITHUB_EVENT_PATH']);
|
||||
/** @var array */
|
||||
$event_data = \json_decode($event_json, true);
|
||||
/** @psalm-suppress ForbiddenCode */
|
||||
\var_dump($event_data);
|
||||
|
||||
if ($this->env['GITHUB_EVENT_PATH'] === 'pull_request') {
|
||||
$this->readEnv['CI_PR_NUMBER'] = $event_data['number'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user