Skip to content

Commit 3b8b80e

Browse files
authored
Merge pull request #12 from cicirello/fix-bug-0-results
Prevent action from updating badge JSON file for count of 0
2 parents 6d35b22 + 3ef440e commit 3b8b80e

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

ActionUserCounter.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ def executeQuery(owner, actionName, failOnError) :
7676
exit(exitCode if failOnError else 0)
7777
result = json.loads(result)
7878
if "total_count" in result :
79-
return result["total_count"]
79+
count = result["total_count"]
80+
if count == 0 :
81+
print("WARNING: Code query returned 0 results for action:", actionName)
82+
print("Query result:")
83+
print(result)
84+
print("If you think this is a bug in the count-action-users action,")
85+
print("please include the above in your issue report.")
86+
return count
8087
else :
8188
print("Error: total_count missing from GitHub API query result")
8289
exitCode = 1
@@ -97,7 +104,8 @@ def collectRepoCounts(actionList, failOnError, queryDelay) :
97104
for i, action in enumerate(actionList) :
98105
owner, actionName = splitActionOwnerName(action)
99106
count = executeQuery(owner, actionName, failOnError)
100-
countMap[actionName] = formatCount(count)
107+
if count > 0 :
108+
countMap[actionName] = formatCount(count)
101109
if i+1 < len(actionList) :
102110
time.sleep(queryDelay)
103111
return countMap

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased] - 2021-09-30
7+
## [Unreleased] - 2021-12-13
88

99
### Added
1010

@@ -17,6 +17,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
### Fixed
1818

1919

20+
## [1.0.4] - 2021-12-13
21+
22+
### Changed
23+
* The base Docker image is now set to a specific version tag of pyaction,
24+
specifically 4.0.0.
25+
26+
### Fixed
27+
* Query results should never be 0 since the workflow running the action is
28+
referencing the name of the workflow whose users are to be counted. GitHub
29+
code search API periodically returns 0 results, typically correcting itself next
30+
run. This patch prevents the badge JSON file from being written if result is 0.
31+
32+
2033
## [1.0.3] - 2021-09-30
2134

2235
### Fixed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://www.cicirello.org/
33
# Licensed under the MIT License.
44

5-
FROM ghcr.io/cicirello/pyaction:4
5+
FROM ghcr.io/cicirello/pyaction:4.0.0
66

77
COPY ActionUserCounter.py /ActionUserCounter.py
88
ENTRYPOINT ["/ActionUserCounter.py"]

0 commit comments

Comments
 (0)