Skip to content

Commit

Permalink
Post GitHub comment with statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
daohoangson committed Sep 21, 2023
1 parent 6202ac7 commit b31922c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/osm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ jobs:
- name: Build demo/parser CLI
run: bun install && npm run bun:build
working-directory: demo/parser
- run: php transformers/osm/split.php
- run: php transformers/osm/split.php | tee split.log

- name: Prepare GitHub comment
id: comment
run: printf 'BODY<<EOF\n%s\nEOF\n' "$(cat split.log)" >> $GITHUB_OUTPUT
- name: Post GitHub comment
uses: daohoangson/comment-on-github@35b21121fdbadf807678bec8210cdd7f22a934fe # v2.2.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: |
${{ github.sha }}
```
${{ steps.comment.outputs.BODY }}
```
fingerprint: "### Statistics"
8 changes: 5 additions & 3 deletions transformers/osm/split.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ function main()
$array[$item['id']] = $item;
}

fwrite(STDOUT, sprintf("Paths: %d -> items: %d\n", $pathCount, count($array)));
fwrite(STDERR, sprintf("Paths: %d -> items: %d\n", $pathCount, count($array)));

$i = $j = 0;
foreach ($array as $item) {
$j++;
if (isset($workingWrittenPaths[$item['path']])) {
statisticsTrack($outDir, $item['path'], $workingWrittenPaths[$item['path']]);
fwrite(STDOUT, 'w'); // already written
fwrite(STDERR, ++$i % 50 > 0 ? 'w' : sprintf(" %.2f%%\n", $j / count($array) * 100));
continue;
}

Expand All @@ -84,7 +86,7 @@ function main()
$workingWrittenPaths[$item['path']] = $jsonFullPath;
statisticsTrack($outDir, $item['path'], $jsonFullPath);
file_put_contents($workingFilePath, json_encode(compact('workingWrittenPaths')));
fwrite(STDOUT, '.');
fwrite(STDERR, ++$i % 50 > 0 ? '.' : sprintf("%.2f%%\n", $j / count($array) * 100));
continue;
}

Expand Down

0 comments on commit b31922c

Please sign in to comment.