• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lifeofguenter / terratalk / 13610464635

02 Mar 2025 12:49AM UTC coverage: 63.92% (+14.9%) from 48.98%
13610464635

push

github

web-flow
Add gitea support (#30)

* Add gitea support

* fix cognitive load

* test

* fix bin

* fix bin

* pip install

132 of 191 new or added lines in 7 files covered. (69.11%)

225 of 352 relevant lines covered (63.92%)

0.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.86
/terratalk/drivers/github_comment.py
1
import re
1✔
2
from os import getenv
1✔
3

4
import click
1✔
5
from github import Github
1✔
6

7
from .base import CommentDriver
1✔
8
from ..terraform_out import TerraformOut
1✔
9

10

11
class GithubComment(CommentDriver):
1✔
12
    DETECT_REGEX = re.compile(
1✔
13
        r"\Ahttps://(github\.com)/([^/]+)/([^/]+)/pull/(\d+)\Z",
14
        re.IGNORECASE,
15
    )
16

17
    def add(self, workspace: str, tf_out: TerraformOut):
1✔
NEW
18
        gh = Github(getenv('GITHUB_TOKEN'))
×
19

NEW
20
        repo = gh.get_repo(
×
21
            f"{self.project_key}/{self.repository_slug}"
22
        )
NEW
23
        issue = repo.get_issue(self.pull_request_id)
×
24

25
        # delete any older comments
NEW
26
        for c in issue.get_comments():
×
NEW
27
            if c.body.lstrip().startswith(f'<!-- terratalk: {workspace} -->'):
×
NEW
28
                click.echo(
×
29
                    f'[tf-comment-plan] deleting previous comment: {c.id}'
30
                )
NEW
31
                c.delete()
×
32

NEW
33
        if not tf_out.does_nothing():
×
NEW
34
            issue.create_comment(f'''
×
35
<!-- terratalk: {workspace} -->
36
### tf plan output: {workspace}
37
```diff
38
{tf_out.show()}
39
```
40
''')
41

42
    def detect(self) -> bool:
1✔
43
        m = self.DETECT_REGEX.search(getenv('CHANGE_URL', ''))
1✔
44
        if m:
1✔
45
            self.server = m.group(1)
1✔
46
            self.type = 'github'
1✔
47
            self.project_key = m.group(2)
1✔
48
            self.repository_slug = m.group(3)
1✔
49
            self.pull_request_id = int(m.group(4))
1✔
50
            return True
1✔
51

52
        return False
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc