Skip to content

Commit 6aa1ed2

Browse files
Poc stat generation
1 parent 194296f commit 6aa1ed2

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Description
2+
# ===========
3+
# This workflow is triggered each time
4+
# commits are pushed to GitHub or a pull request is opened.
5+
# It launches three jobs in parallel : a build with java 8,
6+
# a build with java 11 and a SonarCloud analysis.
7+
---
8+
name: Stats generation
9+
10+
on: [push, pull_request]
11+
12+
jobs:
13+
14+
build:
15+
runs-on: ubuntu-22.04
16+
name: Stats for cnes report
17+
steps:
18+
- name: Check out repository code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- name: Test cnes-report
23+
run: |
24+
pip install request tabulate
25+
echo "# Downloads for sonar-cnes-report" > stats.md
26+
python ci_tools/stats_dl.py >> stats.md
27+
cat stats.md

ci_tools/stats_dl.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import requests
2+
from tabulate import tabulate
3+
4+
REPO = "cnescatlab/sonar-cnes-report"
5+
6+
7+
if __name__ == "__main__":
8+
releases = requests.get(url = "https://api.github.com/repos/%s/releases"%REPO)
9+
releases_list = releases.json()
10+
11+
dl_count = 0
12+
downloads = []
13+
14+
for rel in releases_list:
15+
assets = rel["assets"]
16+
for asset in assets:
17+
if asset['name'][-3:] == "jar":
18+
downloads.append(
19+
[
20+
"[%s](%s)"%(rel["tag_name"], asset["url"]),
21+
asset["name"],
22+
asset["download_count"]
23+
]
24+
)
25+
dl_count += asset["download_count"]
26+
27+
28+
print(tabulate(downloads, ["Tag", "File", "Downloads"], tablefmt="github"))
29+
print("TOTAL: %d" % dl_count)

stats_template.md

Whitespace-only changes.

0 commit comments

Comments
 (0)