Skip to content

Commit a82e010

Browse files
authored
PHAR prefix diff job
1 parent 803aacd commit a82e010

File tree

8 files changed

+593
-124
lines changed

8 files changed

+593
-124
lines changed

.github/scripts/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.github/scripts/find-artifact.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import * as core from "@actions/core";
2+
import * as github from "@actions/github";
3+
4+
interface Inputs {
5+
github: ReturnType<typeof github.getOctokit>;
6+
context: typeof github.context;
7+
core: typeof core;
8+
}
9+
10+
module.exports = async ({github, context, core}: Inputs) => {
11+
const commitSha = process.env.BASE_SHA;
12+
const artifactName = process.env.ARTIFACT_NAME;
13+
const workflowName = process.env.WORKFLOW_NAME;
14+
15+
// Get all workflow runs for this commit
16+
const runs = await github.rest.actions.listWorkflowRunsForRepo({
17+
owner: context.repo.owner,
18+
repo: context.repo.repo,
19+
per_page: 20,
20+
event: "push",
21+
head_sha: commitSha
22+
});
23+
24+
if (runs.data.workflow_runs.length === 0) {
25+
core.setFailed(`No workflow runs found for commit ${commitSha}`);
26+
return;
27+
}
28+
29+
const workflowRuns = runs.data.workflow_runs;
30+
if (workflowRuns.length === 0) {
31+
core.setFailed(`No workflow runs found for commit ${commitSha}`);
32+
return;
33+
}
34+
35+
let found = false;
36+
for (const run of workflowRuns) {
37+
if (run.status !== "completed" || run.conclusion !== "success") {
38+
continue;
39+
}
40+
41+
if (run.name !== workflowName) {
42+
continue;
43+
}
44+
45+
const artifactsResp = await github.rest.actions.listWorkflowRunArtifacts({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
run_id: run.id,
49+
});
50+
51+
const artifact = artifactsResp.data.artifacts.find(a => a.name === artifactName);
52+
if (artifact) {
53+
core.setOutput("artifact_id", artifact.id.toString());
54+
core.setOutput("run_id", run.id.toString());
55+
found = true;
56+
break;
57+
}
58+
}
59+
60+
if (!found) {
61+
core.setFailed(`No artifact named '${artifactName}' found for commit ${commitSha}`);
62+
}
63+
}

.github/scripts/listPrefix.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types = 1);
2+
3+
require_once __DIR__ . '/../../vendor/autoload.php';
4+
5+
$dir = $argv[1] ?? __DIR__;
6+
$iterator = new RecursiveDirectoryIterator($dir);
7+
$iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
8+
$files = new RecursiveIteratorIterator($iterator);
9+
10+
$locations = [];
11+
foreach ($files as $file) {
12+
$path = $file->getPathname();
13+
if ($file->getExtension() !== 'php') {
14+
continue;
15+
}
16+
$contents = file_get_contents($path);
17+
$lines = explode("\n", $contents);
18+
foreach ($lines as $i => $line) {
19+
if (!str_contains($line, '_PHPStan_checksum')) {
20+
continue;
21+
}
22+
23+
$trimmedPath = substr($path, strlen($dir) + 1);
24+
if (str_starts_with($trimmedPath, 'vendor/composer/autoload_')) {
25+
continue;
26+
}
27+
$locations[] = $trimmedPath . ':' . ($i + 1);
28+
}
29+
}
30+
sort($locations);
31+
echo implode("\n", $locations);
32+
echo "\n";

0 commit comments

Comments
 (0)