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 9b5087d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 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"
4 changes: 2 additions & 2 deletions downloader/03_osm.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ func (s *pbfScanner) appendRelationIfTypeBoundaryAdministrative(relation *osm.Re
}

func (s *pbfScanner) printDot(format string, a ...any) {
if s.i%25000 == 0 {
if s.i%50000 == 0 {
fmt.Printf("%d: %s\n", s.i, fmt.Sprintf(format, a...))
} else if s.i%500 == 0 {
} else if s.i%1000 == 0 {
fmt.Print(".")
}
}
Expand Down
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 9b5087d

Please sign in to comment.