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

Update internal testing scripts #1435

Merged
merged 8 commits into from
Nov 8, 2023
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
19 changes: 2 additions & 17 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ jobs:
psalm:
name: Run Analysis
runs-on: ubuntu-latest
continue-on-error: true
outputs:
exit-code: ${{ steps.analysis.outputs.EXIT_CODE }}
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -21,20 +18,8 @@ jobs:

- name: Run Psalm
id: analysis
run: vendor/bin/psalm > psalmout.txt || echo EXIT_CODE=$? >> $GITHUB_OUTPUT || exit 0
run: vendor/bin/psalm > psalmout.txt || exit 0

# Send the reports to the CI server to calculate type coverage and send back commit status checks
- name: Ping CI server with type coverage results
run: php monorepo/scripts/ping-ci-server-with-type-coverage.php ${{ secrets.CI_SERVER_TOKEN }} ${{ github.event.pull_request.head.sha }} ${{ github.head_ref }}


# Since GitHub Actions for some reason doesn't support exiting with warnings, we work around this by
# adding a second job. If the first job fails, this one won't run, thus resulting with a skipped status.
# TODO refactor to use CI server to report status if there are new issues encountered compared to the base branch
report-psalm:
name: Psalm Static Analysis
runs-on: ubuntu-latest
needs: psalm
if: needs.psalm.outputs.exit-code == 0
steps:
- name: Report analysis passed
run: echo "Got code ${{ needs.psalm.outputs.exit-code }}" && exit 0;
7 changes: 7 additions & 0 deletions monorepo/scripts/ping-ci-server-with-type-coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
$commit = $argv[2] ?? exit(400);
$branch = $argv[3] ?? 'master';

if (file_exists('psalmout.txt')) {
// Count the number of errors in the output
$psalmErrors = substr_count(file_get_contents('psalmout.txt'), 'ERROR: ');
}

$data = [
'commit' => $commit,
'report' => file_get_contents('type-coverage.json') ?? exit(404),
'branch' => $branch,
'psalmErrors' => $psalmErrors ?? null,
];

$url = 'https://ci.hydephp.com/api/github/actions/type-coverage';
Expand Down
3 changes: 2 additions & 1 deletion monorepo/scripts/ping-openanalytics-testrunner.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @internal This script is used to ping the OpenAnalytics server with the test results.
* @internal This script is used to ping the OpenAnalytics/CI server with the test results.
*
* @example php ping.php 'Monorepo Smoke Tests' ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }}
*
Expand All @@ -23,6 +23,7 @@
exit(404);
}

// Shared database with the CI server
$url = 'https://analytics.hydephp.com/api/test_runs';
$data = [
'runner' => json_encode($runner),
Expand Down
Loading