5 Commits
v1.0.0 ... v1

Author SHA1 Message Date
Rustem Khusnutdinov
45456c4a56 + 2024-11-29 01:01:59 +03:00
Rustem Khusnutdinov
df86803bc8 + 2024-11-29 00:44:40 +03:00
Rustem Khusnutdinov
e2dbab855f + 2024-11-28 23:25:30 +03:00
Rustem Khusnutdinov
cd05fb00d8 + 2024-11-28 22:26:52 +03:00
Rustem Khusnutdinov
74b6edcf5c + 2024-11-28 22:21:51 +03:00
4 changed files with 21 additions and 14 deletions

View File

@@ -14,10 +14,12 @@ COPY src/requirements.txt ./
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
COPY src/entrypoint /usr/local/bin/ COPY src/entrypoint /usr/local/bin/
COPY src/docker-entrypoint.sh /usr/local/bin/ COPY src/docker-entrypoint.sh /
COPY src/add-to-wiki /usr/local/bin/ COPY src/add-to-wiki /usr/local/bin/
COPY src/default.md.j2 /var/ COPY src/default.md.j2 /var/
RUN chmod +x /docker-entrypoint.sh
WORKDIR /workdir WORKDIR /workdir
ENTRYPOINT [ "docker-entrypoint.sh" ] ENTRYPOINT [ "/docker-entrypoint.sh" ]

View File

@@ -23,6 +23,10 @@ inputs:
A GitHub token to write comments and write the badge to the wiki A GitHub token to write comments and write the badge to the wiki
(``github.token``) (``github.token``)
required: true required: true
GITHUB_WIKI:
description: >
Wiki repository clone url
required: true
COVERAGE_FILE: COVERAGE_FILE:
description: > description: >
Path and filename of the coverage XML file to analyze. Path and filename of the coverage XML file to analyze.
@@ -61,9 +65,10 @@ inputs:
required: false required: false
runs: runs:
using: docker using: docker
image: docker://ghcr.io/getflow/coverage-comment-action:v1 image: Dockerfile
env: env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
GITHUB_WIKI: ${{ inputs.GITHUB_WIKI }}
COVERAGE_FILE: ${{ inputs.COVERAGE_FILE }} COVERAGE_FILE: ${{ inputs.COVERAGE_FILE }}
COMMENT_TEMPLATE: ${{ inputs.COMMENT_TEMPLATE }} COMMENT_TEMPLATE: ${{ inputs.COMMENT_TEMPLATE }}
DIFF_COVER_ARGS: ${{ inputs.DIFF_COVER_ARGS }} DIFF_COVER_ARGS: ${{ inputs.DIFF_COVER_ARGS }}

View File

@@ -2,7 +2,7 @@
# Usage $0 {owner/repo} {filename} {commit_message} # Usage $0 {owner/repo} {filename} {commit_message}
# Stores the content of stdin in a file named {filename} in the wiki of # Stores the content of stdin in a file named {filename} in the wiki of
# the provided repo # the provided repo
# Reads envvar GITHUB_TOKEN # Reads envvar GITHUB_WIKI
set -eux set -eux
@@ -13,7 +13,7 @@ commit_message="${3}"
dir="$(mktemp -d)" dir="$(mktemp -d)"
cd $dir cd $dir
git clone "https://x-access-token:${GITHUB_TOKEN}@github.com/${repo_name}.wiki.git" . git clone "${GITHUB_WIKI}" .
echo $stdin > "${filename}" echo $stdin > "${filename}"
git add "${filename}" git add "${filename}"

View File

@@ -17,7 +17,7 @@ import xmltodict
MARKER = """<!-- This comment was produced by coverage-comment-action -->""" MARKER = """<!-- This comment was produced by coverage-comment-action -->"""
SHIELD_URL = "https://img.shields.io/endpoint?url={url}" SHIELD_URL = "https://img.shields.io/endpoint?url={url}"
JSON_URL = "https://raw.githubusercontent.com/wiki/{repo_name}/{filename}" JSON_URL = os.getenv("JSON_URL", "https://raw.githubusercontent.com/wiki/{repo_name}/{filename}")
def main(): def main():
@@ -218,14 +218,14 @@ def post_comment(body: str, gh: github.Github, config: Config) -> None:
repo = gh.get_repo(config.GITHUB_REPOSITORY) repo = gh.get_repo(config.GITHUB_REPOSITORY)
assert config.GITHUB_PR_NUMBER assert config.GITHUB_PR_NUMBER
issue = repo.get_issue(config.GITHUB_PR_NUMBER) issue = repo.get_issue(config.GITHUB_PR_NUMBER)
for comment in issue.get_comments(): # for comment in issue.get_comments():
if comment.user.login == me and MARKER in comment.body: # if comment.user.login == me and MARKER in comment.body:
print("Update previous comment") # print("Update previous comment")
comment.edit(body=body) # comment.edit(body=body)
break # break
else: # else:
print("Adding new comment") print("Adding new comment")
issue.create_comment(body=body) issue.create_comment(body=body)
def compute_badge(coverage_info: dict, config: Config) -> str: def compute_badge(coverage_info: dict, config: Config) -> str: