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

lifeofguenter / terratalk / 13626017535

03 Mar 2025 07:59AM UTC coverage: 63.037% (-0.9%) from 63.92%
13626017535

push

github

web-flow
Remove hard dependencies (#31)

1 of 5 new or added lines in 2 files covered. (20.0%)

1 existing line in 1 file now uncovered.

220 of 349 relevant lines covered (63.04%)

0.63 hits per line

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

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

4
import click
1✔
5

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

9

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

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

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

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

33
        if not tf_out.does_nothing():
×
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