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

mindersec / minder / 24148357217

08 Apr 2026 05:07PM UTC coverage: 58.772% (+0.2%) from 58.616%
24148357217

Pull #6306

github

web-flow
Merge 07b8afae9 into 2a7db6a70
Pull Request #6306: Handle GitHub rate limits with specialized error and Prometheus metrics

80 of 125 new or added lines in 3 files covered. (64.0%)

2 existing lines in 2 files now uncovered.

19450 of 33094 relevant lines covered (58.77%)

36.42 hits per line

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

62.9
/internal/providers/github/common.go
1
// SPDX-FileCopyrightText: Copyright 2023 The Minder Authors
2
// SPDX-License-Identifier: Apache-2.0
3

4
// Package github provides a client for interacting with the GitHub API
5
package github
6

7
import (
8
        "bytes"
9
        "context"
10
        "errors"
11
        "fmt"
12
        "io"
13
        "net/http"
14
        "net/url"
15
        "sort"
16
        "strings"
17
        "time"
18

19
        backoffv4 "github.com/cenkalti/backoff/v4"
20
        "github.com/go-git/go-git/v5"
21
        "github.com/google/go-github/v63/github"
22
        "github.com/rs/zerolog"
23
        "golang.org/x/oauth2"
24
        "google.golang.org/protobuf/types/known/timestamppb"
25

26
        "github.com/mindersec/minder/internal/db"
27
        gitclient "github.com/mindersec/minder/internal/providers/git"
28
        "github.com/mindersec/minder/internal/providers/github/ghcr"
29
        "github.com/mindersec/minder/internal/providers/github/properties"
30
        "github.com/mindersec/minder/internal/providers/ratecache"
31
        minderv1 "github.com/mindersec/minder/pkg/api/protobuf/go/minder/v1"
32
        config "github.com/mindersec/minder/pkg/config/server"
33
        engerrors "github.com/mindersec/minder/pkg/engine/errors"
34
        provifv1 "github.com/mindersec/minder/pkg/providers/v1"
35
)
36

37
//go:generate go run go.uber.org/mock/mockgen -package mock_$GOPACKAGE -destination=./mock/$GOFILE -source=./$GOFILE
38

39
const (
40
        // ExpensiveRestCallTimeout is the timeout for expensive REST calls
41
        ExpensiveRestCallTimeout = 15 * time.Second
42
        // MaxRateLimitWait is the maximum time to wait for a rate limit to reset
43
        MaxRateLimitWait = 5 * time.Minute
44
        // MaxRateLimitRetries is the maximum number of retries for rate limit errors after waiting
45
        MaxRateLimitRetries = 1
46
        // DefaultRateLimitWaitTime is the default time to wait for a rate limit to reset
47
        DefaultRateLimitWaitTime = 1 * time.Minute
48

49
        githubBranchNotFoundMsg = "Branch not found"
50
)
51

52
var (
53
        // ErrNotFound denotes if the call returned a 404
54
        ErrNotFound = errors.New("not found")
55
        // ErrBranchNotFound denotes if the branch was not found
56
        ErrBranchNotFound = errors.New("branch not found")
57
        // ErrNoPackageListingClient denotes if there is no package listing client available
58
        ErrNoPackageListingClient = errors.New("no package listing client available")
59
        // ErroNoCheckPermissions is a fixed error returned when the credentialed
60
        // identity has not been authorized to use the checks API
61
        ErroNoCheckPermissions = errors.New("missing permissions: check")
62
        // ErrBranchNameEmpty is a fixed error returned when the branch name is empty
63
        ErrBranchNameEmpty = errors.New("branch name cannot be empty")
64
)
65

66
// GitHub is the struct that contains the shared GitHub client operations
67
type GitHub struct {
68
        client               *github.Client
69
        packageListingClient *github.Client
70
        cache                ratecache.RestClientCache
71
        delegate             Delegate
72
        ghcrwrap             *ghcr.ImageLister
73
        gitConfig            config.GitConfig
74
        webhookConfig        *config.WebhookConfig
75
        propertyFetchers     properties.GhPropertyFetcherFactory
76
}
77

78
// Ensure that the GitHub client implements the GitHub interface
79
var _ provifv1.GitHub = (*GitHub)(nil)
80

81
// ClientService is an interface for GitHub operations
82
// It is used to mock GitHub operations in tests, but in order to generate
83
// mocks, the interface must be exported
84
type ClientService interface {
85
        GetInstallation(ctx context.Context, id int64, jwt string) (*github.Installation, *github.Response, error)
86
        GetUserIdFromToken(ctx context.Context, token *oauth2.Token) (*int64, error)
87
        ListUserInstallations(ctx context.Context, token *oauth2.Token) ([]*github.Installation, error)
88
        DeleteInstallation(ctx context.Context, id int64, jwt string) (*github.Response, error)
89
        GetOrgMembership(ctx context.Context, token *oauth2.Token, org string) (*github.Membership, *github.Response, error)
90
}
91

92
var _ ClientService = (*ClientServiceImplementation)(nil)
93

94
// ClientServiceImplementation is the implementation of the ClientService interface
95
type ClientServiceImplementation struct{}
96

97
// GetInstallation is a wrapper for the GitHub API to get an installation
98
func (ClientServiceImplementation) GetInstallation(
99
        ctx context.Context,
100
        installationID int64,
101
        jwt string,
102
) (*github.Installation, *github.Response, error) {
×
103
        ghClient := github.NewClient(nil).WithAuthToken(jwt)
×
104
        return ghClient.Apps.GetInstallation(ctx, installationID)
×
105
}
×
106

107
// GetUserIdFromToken is a wrapper for the GitHub API to get the user id from a token
108
func (ClientServiceImplementation) GetUserIdFromToken(ctx context.Context, token *oauth2.Token) (*int64, error) {
×
109
        ghClient := github.NewClient(nil).WithAuthToken(token.AccessToken)
×
110

×
111
        user, _, err := ghClient.Users.Get(ctx, "")
×
112
        if err != nil {
×
113
                return nil, err
×
114
        }
×
115

116
        return user.ID, nil
×
117
}
118

119
// ListUserInstallations is a wrapper for the GitHub API to list user installations
120
func (ClientServiceImplementation) ListUserInstallations(
121
        ctx context.Context, token *oauth2.Token,
122
) ([]*github.Installation, error) {
×
123
        ghClient := github.NewClient(nil).WithAuthToken(token.AccessToken)
×
124

×
125
        installations, _, err := ghClient.Apps.ListUserInstallations(ctx, nil)
×
126
        return installations, err
×
127
}
×
128

129
// DeleteInstallation is a wrapper for the GitHub API to delete an installation
130
func (ClientServiceImplementation) DeleteInstallation(ctx context.Context, id int64, jwt string) (*github.Response, error) {
×
131
        ghClient := github.NewClient(nil).WithAuthToken(jwt)
×
132
        return ghClient.Apps.DeleteInstallation(ctx, id)
×
133
}
×
134

135
// GetOrgMembership is a wrapper for the GitHub API to get users' organization membership
136
func (ClientServiceImplementation) GetOrgMembership(
137
        ctx context.Context, token *oauth2.Token, org string,
138
) (*github.Membership, *github.Response, error) {
×
139
        ghClient := github.NewClient(nil).WithAuthToken(token.AccessToken)
×
140
        return ghClient.Organizations.GetOrgMembership(ctx, "", org)
×
141
}
×
142

143
// Delegate is the interface that contains operations that differ between different GitHub actors (user vs app)
144
type Delegate interface {
145
        GetCredential() provifv1.GitHubCredential
146
        ListAllRepositories(context.Context) ([]*minderv1.Repository, error)
147
        GetUserId(ctx context.Context) (int64, error)
148
        GetName(ctx context.Context) (string, error)
149
        GetLogin(ctx context.Context) (string, error)
150
        GetPrimaryEmail(ctx context.Context) (string, error)
151
        GetOwner() string
152
        IsOrg() bool
153
}
154

155
// NewGitHub creates a new GitHub client
156
func NewGitHub(
157
        client *github.Client,
158
        packageListingClient *github.Client,
159
        cache ratecache.RestClientCache,
160
        delegate Delegate,
161
        cfg *config.ProviderConfig,
162
        whcfg *config.WebhookConfig,
163
        propertyFetchers properties.GhPropertyFetcherFactory,
164
) *GitHub {
50✔
165
        var gitConfig config.GitConfig
50✔
166
        if cfg != nil {
59✔
167
                gitConfig = cfg.Git
9✔
168
        }
9✔
169
        return &GitHub{
50✔
170
                client:               client,
50✔
171
                packageListingClient: packageListingClient,
50✔
172
                cache:                cache,
50✔
173
                delegate:             delegate,
50✔
174
                ghcrwrap:             ghcr.FromGitHubClient(client, delegate.GetOwner()),
50✔
175
                gitConfig:            gitConfig,
50✔
176
                webhookConfig:        whcfg,
50✔
177
                propertyFetchers:     propertyFetchers,
50✔
178
        }
50✔
179
}
180

181
// CanImplement returns true/false depending on whether the Provider
182
// can implement the specified trait
183
func (*GitHub) CanImplement(trait minderv1.ProviderType) bool {
×
184
        return trait == minderv1.ProviderType_PROVIDER_TYPE_GITHUB ||
×
185
                trait == minderv1.ProviderType_PROVIDER_TYPE_GIT ||
×
186
                trait == minderv1.ProviderType_PROVIDER_TYPE_REST ||
×
187
                trait == minderv1.ProviderType_PROVIDER_TYPE_REPO_LISTER
×
188
}
×
189

190
// ListPackagesByRepository returns a list of all packages for a specific repository
191
func (c *GitHub) ListPackagesByRepository(
192
        ctx context.Context,
193
        owner string,
194
        artifactType string,
195
        repositoryId int64,
196
        pageNumber int,
197
        itemsPerPage int,
198
) ([]*github.Package, error) {
4✔
199
        opt := &github.PackageListOptions{
4✔
200
                PackageType: &artifactType,
4✔
201
                ListOptions: github.ListOptions{
4✔
202
                        Page:    pageNumber,
4✔
203
                        PerPage: itemsPerPage,
4✔
204
                },
4✔
205
        }
4✔
206
        // create a slice to hold the containers
4✔
207
        var allContainers []*github.Package
4✔
208

4✔
209
        if c.packageListingClient == nil {
5✔
210
                zerolog.Ctx(ctx).Error().Msg("No client available for listing packages")
1✔
211
                return allContainers, ErrNoPackageListingClient
1✔
212
        }
1✔
213

214
        type listPackagesRespWrapper struct {
3✔
215
                artifacts []*github.Package
3✔
216
                resp      *github.Response
3✔
217
        }
3✔
218
        op := func() (listPackagesRespWrapper, error) {
6✔
219
                var artifacts []*github.Package
3✔
220
                var resp *github.Response
3✔
221
                var err error
3✔
222

3✔
223
                if c.IsOrg() {
6✔
224
                        artifacts, resp, err = c.packageListingClient.Organizations.ListPackages(ctx, owner, opt)
3✔
225
                } else {
3✔
226
                        artifacts, resp, err = c.packageListingClient.Users.ListPackages(ctx, owner, opt)
×
227
                }
×
228

229
                listPackagesResp := listPackagesRespWrapper{
3✔
230
                        artifacts: artifacts,
3✔
231
                        resp:      resp,
3✔
232
                }
3✔
233

3✔
234
                if isRateLimitError(err) {
3✔
235
                        waitErr := c.waitForRateLimitReset(ctx, err)
×
236
                        if waitErr == nil {
×
237
                                return listPackagesResp, err
×
238
                        }
×
239
                        return listPackagesResp, backoffv4.Permanent(err)
×
240
                }
241

242
                return listPackagesResp, backoffv4.Permanent(err)
3✔
243
        }
244

245
        for {
6✔
246
                result, err := performWithRetry(ctx, op)
3✔
247
                if err != nil {
3✔
248
                        if result.resp != nil && result.resp.StatusCode == http.StatusNotFound {
×
249
                                return allContainers, fmt.Errorf("packages not found for repository %d: %w", repositoryId, ErrNotFound)
×
250
                        }
×
251

252
                        return allContainers, err
×
253
                }
254

255
                // now just append the ones belonging to the repository
256
                for _, artifact := range result.artifacts {
7✔
257
                        if artifact.Repository.GetID() == repositoryId {
7✔
258
                                allContainers = append(allContainers, artifact)
3✔
259
                        }
3✔
260
                }
261

262
                if result.resp.NextPage == 0 {
6✔
263
                        break
3✔
264
                }
265
                opt.Page = result.resp.NextPage
×
266
        }
267

268
        return allContainers, nil
3✔
269
}
270

271
// getPackageVersions returns a list of all package versions for the authenticated user or org
272
func (c *GitHub) getPackageVersions(ctx context.Context, owner string, package_type string, package_name string,
273
) ([]*github.PackageVersion, error) {
4✔
274
        state := "active"
4✔
275

4✔
276
        // since the GH API sometimes returns container and sometimes CONTAINER as the type, let's just lowercase it
4✔
277
        package_type = strings.ToLower(package_type)
4✔
278

4✔
279
        opt := &github.PackageListOptions{
4✔
280
                PackageType: &package_type,
4✔
281
                State:       &state,
4✔
282
                ListOptions: github.ListOptions{
4✔
283
                        Page:    1,
4✔
284
                        PerPage: 100,
4✔
285
                },
4✔
286
        }
4✔
287

4✔
288
        // create a slice to hold the versions
4✔
289
        var allVersions []*github.PackageVersion
4✔
290

4✔
291
        // loop until we get all package versions
4✔
292
        for {
8✔
293
                var v []*github.PackageVersion
4✔
294
                var resp *github.Response
4✔
295
                var err error
4✔
296
                if c.IsOrg() {
8✔
297
                        v, resp, err = c.client.Organizations.PackageGetAllVersions(ctx, owner, package_type, package_name, opt)
4✔
298
                } else {
4✔
299
                        package_name = url.PathEscape(package_name)
×
300
                        v, resp, err = c.client.Users.PackageGetAllVersions(ctx, owner, package_type, package_name, opt)
×
301
                }
×
302
                if err != nil {
5✔
303
                        return nil, err
1✔
304
                }
1✔
305

306
                // append to the slice
307
                allVersions = append(allVersions, v...)
3✔
308

3✔
309
                // if there is no next page, break
3✔
310
                if resp.NextPage == 0 {
6✔
311
                        break
3✔
312
                }
313

314
                // update the page
315
                opt.Page = resp.NextPage
×
316
        }
317

318
        // return the slice
319
        return allVersions, nil
3✔
320
}
321

322
// GetPackageByName returns a single package for the authenticated user or for the org
323
func (c *GitHub) GetPackageByName(ctx context.Context, owner string, package_type string, package_name string,
324
) (*github.Package, error) {
2✔
325
        var pkg *github.Package
2✔
326
        var err error
2✔
327

2✔
328
        // since the GH API sometimes returns container and sometimes CONTAINER as the type, let's just lowercase it
2✔
329
        package_type = strings.ToLower(package_type)
2✔
330

2✔
331
        if c.IsOrg() {
4✔
332
                pkg, _, err = c.client.Organizations.GetPackage(ctx, owner, package_type, package_name)
2✔
333
                if err != nil {
2✔
334
                        return nil, err
×
335
                }
×
336
        } else {
×
337
                pkg, _, err = c.client.Users.GetPackage(ctx, "", package_type, package_name)
×
338
                if err != nil {
×
339
                        return nil, err
×
340
                }
×
341
        }
342
        return pkg, nil
2✔
343
}
344

345
// GetPackageVersionById returns a single package version for the specific id
346
func (c *GitHub) GetPackageVersionById(ctx context.Context, owner string, packageType string, packageName string,
347
        version int64) (*github.PackageVersion, error) {
2✔
348
        var pkgVersion *github.PackageVersion
2✔
349
        var err error
2✔
350

2✔
351
        if c.IsOrg() {
4✔
352
                pkgVersion, _, err = c.client.Organizations.PackageGetVersion(ctx, owner, packageType, packageName, version)
2✔
353
                if err != nil {
2✔
354
                        return nil, err
×
355
                }
×
356
        } else {
×
357
                packageName = url.PathEscape(packageName)
×
358
                pkgVersion, _, err = c.client.Users.PackageGetVersion(ctx, owner, packageType, packageName, version)
×
359
                if err != nil {
×
360
                        return nil, err
×
361
                }
×
362
        }
363

364
        return pkgVersion, nil
2✔
365
}
366

367
// GetPullRequest is a wrapper for the GitHub API to get a pull request
368
func (c *GitHub) GetPullRequest(
369
        ctx context.Context,
370
        owner string,
371
        repo string,
372
        number int,
373
) (*github.PullRequest, error) {
×
374
        pr, _, err := c.client.PullRequests.Get(ctx, owner, repo, number)
×
375
        if err != nil {
×
376
                return nil, err
×
377
        }
×
378
        return pr, nil
×
379
}
380

381
// ListFiles is a wrapper for the GitHub API to list files in a pull request
382
func (c *GitHub) ListFiles(
383
        ctx context.Context,
384
        owner string,
385
        repo string,
386
        prNumber int,
387
        perPage int,
388
        pageNumber int,
389
) ([]*github.CommitFile, *github.Response, error) {
3✔
390
        type listFilesRespWrapper struct {
3✔
391
                files []*github.CommitFile
3✔
392
                resp  *github.Response
3✔
393
        }
3✔
394

3✔
395
        op := func() (listFilesRespWrapper, error) {
7✔
396
                opt := &github.ListOptions{
4✔
397
                        Page:    pageNumber,
4✔
398
                        PerPage: perPage,
4✔
399
                }
4✔
400
                files, resp, err := c.client.PullRequests.ListFiles(ctx, owner, repo, prNumber, opt)
4✔
401

4✔
402
                listFileResp := listFilesRespWrapper{
4✔
403
                        files: files,
4✔
404
                        resp:  resp,
4✔
405
                }
4✔
406

4✔
407
                if isRateLimitError(err) {
5✔
408
                        waitErr := c.waitForRateLimitReset(ctx, err)
1✔
409
                        if waitErr == nil {
2✔
410
                                return listFileResp, err
1✔
411
                        }
1✔
412
                        return listFileResp, backoffv4.Permanent(err)
×
413
                }
414

415
                return listFileResp, backoffv4.Permanent(err)
3✔
416
        }
417

418
        resp, err := performWithRetry(ctx, op)
3✔
419
        return resp.files, resp.resp, err
3✔
420
}
421

422
// CreateReview is a wrapper for the GitHub API to create a review
423
func (c *GitHub) CreateReview(
424
        ctx context.Context, owner, repo string, number int, reviewRequest *github.PullRequestReviewRequest,
425
) (*github.PullRequestReview, error) {
×
426
        review, _, err := c.client.PullRequests.CreateReview(ctx, owner, repo, number, reviewRequest)
×
427
        if err != nil {
×
428
                return nil, fmt.Errorf("error creating review: %w", err)
×
429
        }
×
430
        return review, nil
×
431
}
432

433
// UpdateReview is a wrapper for the GitHub API to update a review
434
func (c *GitHub) UpdateReview(
435
        ctx context.Context, owner, repo string, number int, reviewId int64, body string,
436
) (*github.PullRequestReview, error) {
×
437
        review, _, err := c.client.PullRequests.UpdateReview(ctx, owner, repo, number, reviewId, body)
×
438
        if err != nil {
×
439
                return nil, fmt.Errorf("error updating review: %w", err)
×
440
        }
×
441
        return review, nil
×
442
}
443

444
// ListIssueComments is a wrapper for the GitHub API to get all comments in a review
445
func (c *GitHub) ListIssueComments(
446
        ctx context.Context, owner, repo string, number int, opts *github.IssueListCommentsOptions,
447
) ([]*github.IssueComment, error) {
×
448
        comments, _, err := c.client.Issues.ListComments(ctx, owner, repo, number, opts)
×
449
        if err != nil {
×
450
                return nil, fmt.Errorf("error getting list of comments: %w", err)
×
451
        }
×
452
        return comments, nil
×
453
}
454

455
// ListReviews is a wrapper for the GitHub API to list reviews
456
func (c *GitHub) ListReviews(
457
        ctx context.Context,
458
        owner, repo string,
459
        number int,
460
        opt *github.ListOptions,
461
) ([]*github.PullRequestReview, error) {
×
462
        reviews, _, err := c.client.PullRequests.ListReviews(ctx, owner, repo, number, opt)
×
463
        if err != nil {
×
464
                return nil, fmt.Errorf("error listing reviews for PR %s/%s/%d: %w", owner, repo, number, err)
×
465
        }
×
466
        return reviews, nil
×
467
}
468

469
// DismissReview is a wrapper for the GitHub API to dismiss a review
470
func (c *GitHub) DismissReview(
471
        ctx context.Context,
472
        owner, repo string,
473
        prId int,
474
        reviewId int64,
475
        dismissalRequest *github.PullRequestReviewDismissalRequest,
476
) (*github.PullRequestReview, error) {
×
477
        review, _, err := c.client.PullRequests.DismissReview(ctx, owner, repo, prId, reviewId, dismissalRequest)
×
478
        if err != nil {
×
479
                return nil, fmt.Errorf("error dismissing review %d for PR %s/%s/%d: %w", reviewId, owner, repo, prId, err)
×
480
        }
×
481
        return review, nil
×
482
}
483

484
// SetCommitStatus is a wrapper for the GitHub API to set a commit status
485
func (c *GitHub) SetCommitStatus(
486
        ctx context.Context, owner, repo, ref string, status *github.RepoStatus,
487
) (*github.RepoStatus, error) {
×
488
        status, _, err := c.client.Repositories.CreateStatus(ctx, owner, repo, ref, status)
×
489
        if err != nil {
×
490
                return nil, fmt.Errorf("error creating commit status: %w", err)
×
491
        }
×
492
        return status, nil
×
493
}
494

495
// GetRepository returns a single repository for the authenticated user
496
func (c *GitHub) GetRepository(ctx context.Context, owner string, name string) (*github.Repository, error) {
×
497
        // create a slice to hold the repositories
×
498
        repo, _, err := c.client.Repositories.Get(ctx, owner, name)
×
499
        if err != nil {
×
500
                return nil, fmt.Errorf("error getting repository: %w", err)
×
501
        }
×
502

503
        return repo, nil
×
504
}
505

506
// GetBranchProtection returns the branch protection for a given branch
507
func (c *GitHub) GetBranchProtection(ctx context.Context, owner string,
508
        repo_name string, branch_name string) (*github.Protection, error) {
×
509
        var respErr *github.ErrorResponse
×
510
        if branch_name == "" {
×
511
                return nil, ErrBranchNameEmpty
×
512
        }
×
513

514
        protection, _, err := c.client.Repositories.GetBranchProtection(ctx, owner, repo_name, branch_name)
×
515
        if errors.As(err, &respErr) {
×
516
                if respErr.Message == githubBranchNotFoundMsg {
×
517
                        return nil, ErrBranchNotFound
×
518
                }
×
519

520
                return nil, fmt.Errorf("error getting branch protection: %w", err)
×
521
        } else if err != nil {
×
522
                return nil, err
×
523
        }
×
524
        return protection, nil
×
525
}
526

527
// UpdateBranchProtection updates the branch protection for a given branch
528
func (c *GitHub) UpdateBranchProtection(
529
        ctx context.Context, owner, repo, branch string, preq *github.ProtectionRequest,
530
) error {
×
531
        if branch == "" {
×
532
                return ErrBranchNameEmpty
×
533
        }
×
534
        _, _, err := c.client.Repositories.UpdateBranchProtection(ctx, owner, repo, branch, preq)
×
535
        return err
×
536
}
537

538
// GetBaseURL returns the base URL for the REST API.
539
func (c *GitHub) GetBaseURL() string {
1✔
540
        return c.client.BaseURL.String()
1✔
541
}
1✔
542

543
// NewRequest creates an API request. A relative URL can be provided in urlStr,
544
// which will be resolved to the BaseURL of the Client. Relative URLS should
545
// always be specified without a preceding slash. If specified, the value
546
// pointed to by body is JSON encoded and included as the request body.
547
func (c *GitHub) NewRequest(method, requestUrl string, body any) (*http.Request, error) {
9✔
548
        return c.client.NewRequest(method, requestUrl, body)
9✔
549
}
9✔
550

551
// Do sends an API request and returns the API response.
552
func (c *GitHub) Do(ctx context.Context, req *http.Request) (*http.Response, error) {
9✔
553
        var buf bytes.Buffer
9✔
554

9✔
555
        // The GitHub client closes the response body, so we need to capture it
9✔
556
        // in a buffer so that we can return it to the caller
9✔
557
        resp, err := c.client.Do(ctx, req, &buf)
9✔
558
        if err != nil && resp == nil {
9✔
559
                return nil, err
×
560
        }
×
561

562
        if resp.Response != nil {
18✔
563
                resp.Body = io.NopCloser(&buf)
9✔
564
        }
9✔
565
        return resp.Response, err
9✔
566
}
567

568
// GetCredential returns the credential used to authenticate with the GitHub API
569
func (c *GitHub) GetCredential() provifv1.GitHubCredential {
×
570
        return c.delegate.GetCredential()
×
571
}
×
572

573
// IsOrg returns true if the owner is an organization
574
func (c *GitHub) IsOrg() bool {
11✔
575
        return c.delegate.IsOrg()
11✔
576
}
11✔
577

578
// ListHooks lists all Hooks for the specified repository.
579
func (c *GitHub) ListHooks(ctx context.Context, owner, repo string) ([]*github.Hook, error) {
×
580
        list, resp, err := c.client.Repositories.ListHooks(ctx, owner, repo, nil)
×
581
        if err != nil && resp.StatusCode == http.StatusNotFound {
×
582
                // return empty list so that the caller can ignore the error and iterate over the empty list
×
583
                return []*github.Hook{}, fmt.Errorf("hooks not found for repository %s/%s: %w", owner, repo, ErrNotFound)
×
584
        }
×
585
        return list, err
×
586
}
587

588
// DeleteHook deletes a specified Hook.
589
func (c *GitHub) DeleteHook(ctx context.Context, owner, repo string, id int64) error {
×
590
        resp, err := c.client.Repositories.DeleteHook(ctx, owner, repo, id)
×
NEW
591
        if err != nil {
×
NEW
592
                if isRateLimitError(err) {
×
NEW
593
                        return c.waitForRateLimitReset(ctx, err)
×
NEW
594
                }
×
NEW
595
                if resp != nil && (resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusForbidden) {
×
NEW
596
                        // If the hook is not found, we can ignore the
×
NEW
597
                        // error, user might have deleted it manually.
×
NEW
598
                        // We also ignore deleting webhooks that we're not
×
NEW
599
                        // allowed to touch. This is usually the case
×
NEW
600
                        // with repository transfer.
×
NEW
601
                        return nil
×
NEW
602
                }
×
NEW
603
                return err
×
604
        }
NEW
605
        return nil
×
606
}
607

608
// CreateHook creates a new Hook.
609
func (c *GitHub) CreateHook(ctx context.Context, owner, repo string, hook *github.Hook) (*github.Hook, error) {
4✔
610
        h, _, err := c.client.Repositories.CreateHook(ctx, owner, repo, hook)
4✔
611
        if isRateLimitError(err) {
5✔
612
                if waitErr := c.waitForRateLimitReset(ctx, err); waitErr != nil {
2✔
613
                        return nil, waitErr
1✔
614
                }
1✔
615
        }
616
        return h, err
3✔
617
}
618

619
// EditHook edits an existing Hook.
620
func (c *GitHub) EditHook(ctx context.Context, owner, repo string, id int64, hook *github.Hook) (*github.Hook, error) {
×
621
        h, _, err := c.client.Repositories.EditHook(ctx, owner, repo, id, hook)
×
NEW
622
        if isRateLimitError(err) {
×
NEW
623
                if waitErr := c.waitForRateLimitReset(ctx, err); waitErr != nil {
×
NEW
624
                        return nil, waitErr
×
NEW
625
                }
×
626
        }
627
        return h, err
×
628
}
629

630
// CreateSecurityAdvisory creates a new security advisory
631
func (c *GitHub) CreateSecurityAdvisory(ctx context.Context, owner, repo, severity, summary, description string,
632
        v []*github.AdvisoryVulnerability) (string, error) {
3✔
633
        u := fmt.Sprintf("repos/%v/%v/security-advisories", owner, repo)
3✔
634

3✔
635
        payload := &struct {
3✔
636
                Summary         string                          `json:"summary"`
3✔
637
                Description     string                          `json:"description"`
3✔
638
                Severity        string                          `json:"severity"`
3✔
639
                Vulnerabilities []*github.AdvisoryVulnerability `json:"vulnerabilities"`
3✔
640
        }{
3✔
641
                Summary:         summary,
3✔
642
                Description:     description,
3✔
643
                Severity:        severity,
3✔
644
                Vulnerabilities: v,
3✔
645
        }
3✔
646
        req, err := c.client.NewRequest("POST", u, payload)
3✔
647
        if err != nil {
3✔
648
                return "", err
×
649
        }
×
650

651
        res := &struct {
3✔
652
                ID string `json:"ghsa_id"`
3✔
653
        }{}
3✔
654

3✔
655
        resp, err := c.client.Do(ctx, req, res)
3✔
656
        if err != nil {
5✔
657
                return "", err
2✔
658
        }
2✔
659

660
        if resp.StatusCode != http.StatusCreated {
1✔
661
                return "", fmt.Errorf("error creating security advisory: %v", resp.Status)
×
662
        }
×
663
        return res.ID, nil
1✔
664
}
665

666
// CloseSecurityAdvisory closes a security advisory
667
func (c *GitHub) CloseSecurityAdvisory(ctx context.Context, owner, repo, id string) error {
4✔
668
        u := fmt.Sprintf("repos/%v/%v/security-advisories/%v", owner, repo, id)
4✔
669

4✔
670
        payload := &struct {
4✔
671
                State string `json:"state"`
4✔
672
        }{
4✔
673
                State: "closed",
4✔
674
        }
4✔
675

4✔
676
        req, err := c.client.NewRequest("PATCH", u, payload)
4✔
677
        if err != nil {
4✔
678
                return err
×
679
        }
×
680

681
        resp, err := c.client.Do(ctx, req, nil)
4✔
682
        if err != nil {
7✔
683
                return err
3✔
684
        }
3✔
685
        // Translate the HTTP status code to an error, nil if between 200 and 299
686
        return engerrors.HTTPErrorCodeToErr(resp.StatusCode)
1✔
687
}
688

689
// CreatePullRequest creates a pull request in a repository.
690
func (c *GitHub) CreatePullRequest(
691
        ctx context.Context,
692
        owner, repo, title, body, head, base string,
693
) (*github.PullRequest, error) {
×
694
        pr, _, err := c.client.PullRequests.Create(ctx, owner, repo, &github.NewPullRequest{
×
695
                Title:               github.String(title),
×
696
                Body:                github.String(body),
×
697
                Head:                github.String(head),
×
698
                Base:                github.String(base),
×
699
                MaintainerCanModify: github.Bool(true),
×
700
        })
×
701
        if err != nil {
×
702
                return nil, err
×
703
        }
×
704

705
        return pr, nil
×
706
}
707

708
// ClosePullRequest closes a pull request in a repository.
709
func (c *GitHub) ClosePullRequest(ctx context.Context, owner, repo string, number int) (*github.PullRequest, error) {
×
710
        pr, _, err := c.client.PullRequests.Edit(ctx, owner, repo, number, &github.PullRequest{
×
711
                State: github.String("closed"),
×
712
        })
×
713
        if err != nil {
×
714
                return nil, err
×
715
        }
×
716
        return pr, nil
×
717
}
718

719
// ListPullRequests lists all pull requests in a repository.
720
func (c *GitHub) ListPullRequests(
721
        ctx context.Context,
722
        owner, repo string,
723
        opt *github.PullRequestListOptions,
724
) ([]*github.PullRequest, error) {
×
725
        prs, _, err := c.client.PullRequests.List(ctx, owner, repo, opt)
×
726
        if err != nil {
×
727
                return nil, err
×
728
        }
×
729

730
        return prs, nil
×
731
}
732

733
// CreateIssueComment creates a comment on a pull request or an issue
734
func (c *GitHub) CreateIssueComment(
735
        ctx context.Context, owner, repo string, number int, comment string,
736
) (*github.IssueComment, error) {
14✔
737
        var issueComment *github.IssueComment
14✔
738

14✔
739
        op := func() (any, error) {
30✔
740
                var err error
16✔
741

16✔
742
                issueComment, _, err = c.client.Issues.CreateComment(ctx, owner, repo, number, &github.IssueComment{
16✔
743
                        Body: &comment,
16✔
744
                })
16✔
745

16✔
746
                if isRateLimitError(err) {
30✔
747
                        waitWrr := c.waitForRateLimitReset(ctx, err)
14✔
748
                        if waitWrr == nil {
16✔
749
                                return nil, err
2✔
750
                        }
2✔
751
                        return nil, backoffv4.Permanent(err)
12✔
752
                }
753

754
                return nil, backoffv4.Permanent(err)
2✔
755
        }
756
        _, retryErr := performWithRetry(ctx, op)
14✔
757
        return issueComment, retryErr
14✔
758
}
759

760
// UpdateIssueComment updates a comment on a pull request or an issue
761
func (c *GitHub) UpdateIssueComment(ctx context.Context, owner, repo string, number int64, comment string) error {
×
762
        _, _, err := c.client.Issues.EditComment(ctx, owner, repo, number, &github.IssueComment{
×
763
                Body: &comment,
×
764
        })
×
765
        return err
×
766
}
×
767

768
// Clone clones a GitHub repository
769
func (c *GitHub) Clone(ctx context.Context, cloneUrl string, branch string) (*git.Repository, error) {
×
770
        delegator := gitclient.NewGit(c.delegate.GetCredential(), gitclient.WithConfig(c.gitConfig))
×
771
        return delegator.Clone(ctx, cloneUrl, branch)
×
772
}
×
773

774
// AddAuthToPushOptions adds authorization to the push options
775
func (c *GitHub) AddAuthToPushOptions(ctx context.Context, pushOptions *git.PushOptions) error {
×
776
        login, err := c.delegate.GetLogin(ctx)
×
777
        if err != nil {
×
778
                return fmt.Errorf("cannot get login: %w", err)
×
779
        }
×
780
        c.delegate.GetCredential().AddToPushOptions(pushOptions, login)
×
781
        return nil
×
782
}
783

784
// ListAllRepositories lists all repositories the credential has access to
785
func (c *GitHub) ListAllRepositories(ctx context.Context) ([]*minderv1.Repository, error) {
3✔
786
        return c.delegate.ListAllRepositories(ctx)
3✔
787
}
3✔
788

789
// GetUserId returns the user id for the acting user
790
func (c *GitHub) GetUserId(ctx context.Context) (int64, error) {
1✔
791
        return c.delegate.GetUserId(ctx)
1✔
792
}
1✔
793

794
// GetName returns the username for the acting user
795
func (c *GitHub) GetName(ctx context.Context) (string, error) {
1✔
796
        return c.delegate.GetName(ctx)
1✔
797
}
1✔
798

799
// GetLogin returns the login for the acting user
800
func (c *GitHub) GetLogin(ctx context.Context) (string, error) {
1✔
801
        return c.delegate.GetLogin(ctx)
1✔
802
}
1✔
803

804
// GetPrimaryEmail returns the primary email for the acting user
805
func (c *GitHub) GetPrimaryEmail(ctx context.Context) (string, error) {
1✔
806
        return c.delegate.GetPrimaryEmail(ctx)
1✔
807
}
1✔
808

809
// ListImages lists all containers in the GitHub Container Registry
810
func (c *GitHub) ListImages(ctx context.Context) ([]string, error) {
×
811
        return c.ghcrwrap.ListImages(ctx)
×
812
}
×
813

814
// GetNamespaceURL returns the URL for the repository
815
func (c *GitHub) GetNamespaceURL() string {
×
816
        return c.ghcrwrap.GetNamespaceURL()
×
817
}
×
818

819
// GetArtifactVersions returns a list of all versions for a specific artifact
820
func (gv *GitHub) GetArtifactVersions(
821
        ctx context.Context, artifact *minderv1.Artifact,
822
        filter provifv1.GetArtifactVersionsFilter,
823
) ([]*minderv1.ArtifactVersion, error) {
2✔
824
        // We don't need to URL-encode the artifact name
2✔
825
        // since this already happens in go-github
2✔
826
        upstreamVersions, err := gv.getPackageVersions(
2✔
827
                ctx, artifact.GetOwner(), artifact.GetTypeLower(), artifact.GetName(),
2✔
828
        )
2✔
829
        if err != nil {
3✔
830
                return nil, fmt.Errorf("error retrieving artifact versions: %w", err)
1✔
831
        }
1✔
832

833
        out := make([]*minderv1.ArtifactVersion, 0, len(upstreamVersions))
1✔
834
        for _, uv := range upstreamVersions {
2✔
835
                tags := uv.Metadata.Container.Tags
1✔
836

1✔
837
                if err := filter.IsSkippable(uv.CreatedAt.Time, tags); err != nil {
1✔
838
                        zerolog.Ctx(ctx).Debug().Str("name", artifact.GetName()).Strs("tags", tags).
×
839
                                Str("reason", err.Error()).Msg("skipping artifact version")
×
840
                        continue
×
841
                }
842

843
                sort.Strings(tags)
1✔
844

1✔
845
                // only the tags and creation time is relevant to us.
1✔
846
                out = append(out, &minderv1.ArtifactVersion{
1✔
847
                        Tags: tags,
1✔
848
                        // NOTE: GitHub's name is actually a SHA. This is misleading...
1✔
849
                        // but it is what it is. We'll use it as the SHA for now.
1✔
850
                        Sha:       *uv.Name,
1✔
851
                        CreatedAt: timestamppb.New(uv.CreatedAt.Time),
1✔
852
                })
1✔
853
        }
854

855
        return out, nil
1✔
856
}
857

858
// setAsRateLimited adds the GitHub to the cache as rate limited.
859
// An optimistic concurrency control mechanism is used to ensure that every request doesn't need
860
// synchronization. GitHub only adds itself to the cache if it's not already there. It doesn't
861
// remove itself from the cache when the rate limit is reset. This approach leverages the high
862
// likelihood of the client or token being rate-limited again. By keeping the client in the cache,
863
// we can reuse client's rateLimits map, which holds rate limits for different endpoints.
864
// This reuse of cached rate limits helps avoid unnecessary GitHub API requests when the client
865
// is rate-limited. Every cache entry has an expiration time, so the cache will eventually evict
866
// the rate-limited client.
867
func (c *GitHub) setAsRateLimited() {
19✔
868
        if c.cache != nil {
38✔
869
                c.cache.Set(c.delegate.GetOwner(), c.delegate.GetCredential().GetCacheKey(), db.ProviderTypeGithub, c)
19✔
870
        }
19✔
871
}
872

873
// waitForRateLimitReset waits for token wait limit to reset. Returns error if wait time is more
874
// than MaxRateLimitWait or requests' context is cancelled.
875
func (c *GitHub) waitForRateLimitReset(ctx context.Context, err error) error {
20✔
876
        var rateLimitError *github.RateLimitError
20✔
877
        if errors.As(err, &rateLimitError) {
38✔
878
                return c.processPrimaryRateLimitErr(ctx, rateLimitError)
18✔
879
        }
18✔
880

881
        var abuseRateLimitError *github.AbuseRateLimitError
2✔
882
        if errors.As(err, &abuseRateLimitError) {
3✔
883
                return c.processAbuseRateLimitErr(ctx, abuseRateLimitError)
1✔
884
        }
1✔
885

886
        return nil
1✔
887
}
888

889
func (c *GitHub) processPrimaryRateLimitErr(ctx context.Context, err *github.RateLimitError) error {
18✔
890
        logger := zerolog.Ctx(ctx)
18✔
891
        rate := err.Rate
18✔
892
        if rate.Remaining == 0 {
36✔
893
                c.setAsRateLimited()
18✔
894

18✔
895
                waitTime := DefaultRateLimitWaitTime
18✔
896
                resetTime := rate.Reset.Time
18✔
897
                if !resetTime.IsZero() {
36✔
898
                        waitTime = time.Until(resetTime)
18✔
899
                }
18✔
900

901
                logRateLimitError(logger, "RateLimitError", waitTime, c.delegate.GetOwner(), err.Response)
18✔
902

18✔
903
                if waitTime > MaxRateLimitWait {
32✔
904
                        logger.Debug().Msgf("rate limit reset time: %v exceeds maximum wait time: %v", waitTime, MaxRateLimitWait)
14✔
905
                        return engerrors.NewRateLimitError(err, int64(rate.Limit), int64(rate.Remaining), resetTime)
14✔
906
                }
14✔
907

908
                // Wait for the rate limit to reset
909
                select {
4✔
910
                case <-time.After(waitTime):
4✔
911
                        return nil
4✔
912
                case <-ctx.Done():
×
913
                        logger.Debug().Err(ctx.Err()).Msg("context done while waiting for rate limit to reset")
×
NEW
914
                        return engerrors.NewRateLimitError(err, int64(rate.Limit), int64(rate.Remaining), resetTime)
×
915
                }
916
        }
917

918
        return nil
×
919
}
920

921
func (c *GitHub) processAbuseRateLimitErr(ctx context.Context, err *github.AbuseRateLimitError) error {
1✔
922
        logger := zerolog.Ctx(ctx)
1✔
923
        c.setAsRateLimited()
1✔
924

1✔
925
        retryAfter := err.RetryAfter
1✔
926
        waitTime := DefaultRateLimitWaitTime
1✔
927
        if retryAfter != nil && *retryAfter > 0 {
2✔
928
                waitTime = *retryAfter
1✔
929
        }
1✔
930

931
        logRateLimitError(logger, "AbuseRateLimitError", waitTime, c.delegate.GetOwner(), err.Response)
1✔
932

1✔
933
        if waitTime > MaxRateLimitWait {
1✔
934
                logger.Debug().Msgf("abuse rate limit wait time: %v exceeds maximum wait time: %v", waitTime, MaxRateLimitWait)
×
NEW
935
                return engerrors.NewRateLimitError(err, 0, 0, time.Now().Add(waitTime))
×
936
        }
×
937

938
        // Wait for the rate limit to reset
939
        select {
1✔
940
        case <-time.After(waitTime):
1✔
941
                return nil
1✔
942
        case <-ctx.Done():
×
943
                logger.Debug().Err(ctx.Err()).Msg("context done while waiting for rate limit to reset")
×
NEW
944
                return engerrors.NewRateLimitError(err, 0, 0, time.Now().Add(waitTime))
×
945
        }
946
}
947

948
func logRateLimitError(logger *zerolog.Logger, errType string, waitTime time.Duration, owner string, resp *http.Response) {
19✔
949
        var method, path string
19✔
950
        if resp != nil && resp.Request != nil {
38✔
951
                method = resp.Request.Method
19✔
952
                path = resp.Request.URL.Path
19✔
953
        }
19✔
954

955
        event := logger.Debug().
19✔
956
                Str("owner", owner).
19✔
957
                Str("wait_time", waitTime.String()).
19✔
958
                Str("error_type", errType)
19✔
959

19✔
960
        if method != "" {
38✔
961
                event = event.Str("method", method)
19✔
962
        }
19✔
963

964
        if path != "" {
38✔
965
                event = event.Str("path", path)
19✔
966
        }
19✔
967

968
        event.Msg("rate limit exceeded")
19✔
969
}
970

971
func performWithRetry[T any](ctx context.Context, op backoffv4.OperationWithData[T]) (T, error) {
23✔
972
        exponentialBackOff := backoffv4.NewExponentialBackOff()
23✔
973
        maxRetriesBackoff := backoffv4.WithMaxRetries(exponentialBackOff, MaxRateLimitRetries)
23✔
974
        return backoffv4.RetryWithData(op, backoffv4.WithContext(maxRetriesBackoff, ctx))
23✔
975
}
23✔
976

977
func isRateLimitError(err error) bool {
29✔
978
        var rateLimitError *github.RateLimitError
29✔
979
        isRateLimitErr := errors.As(err, &rateLimitError)
29✔
980

29✔
981
        var abuseRateLimitError *github.AbuseRateLimitError
29✔
982
        isAbuseRateLimitErr := errors.As(err, &abuseRateLimitError)
29✔
983

29✔
984
        return isRateLimitErr || isAbuseRateLimitErr
29✔
985
}
29✔
986

987
// IsMinderHook checks if a GitHub hook is a Minder hook
988
func IsMinderHook(hook *github.Hook, hostURL string) (bool, error) {
4✔
989
        configURL := hook.GetConfig().GetURL()
4✔
990
        if configURL == "" {
5✔
991
                return false, fmt.Errorf("unexpected hook config structure: %v", hook.Config)
1✔
992
        }
1✔
993
        parsedURL, err := url.Parse(configURL)
3✔
994
        if err != nil {
4✔
995
                return false, err
1✔
996
        }
1✔
997
        if parsedURL.Host == hostURL {
3✔
998
                return true, nil
1✔
999
        }
1✔
1000

1001
        return false, nil
1✔
1002
}
1003

1004
// CanHandleOwner checks if the GitHub provider has the right credentials to handle the owner
1005
func CanHandleOwner(_ context.Context, prov db.Provider, owner string) bool {
4✔
1006
        // TODO: this is fragile and does not handle organization renames, in the future we can make sure the credential
4✔
1007
        // has admin permissions on the owner
4✔
1008
        if prov.Name == fmt.Sprintf("%s-%s", db.ProviderClassGithubApp, owner) {
5✔
1009
                return true
1✔
1010
        }
1✔
1011
        if prov.Class == db.ProviderClassGithub {
4✔
1012
                return true
1✔
1013
        }
1✔
1014
        return false
2✔
1015
}
1016

1017
// NewFallbackTokenClient creates a new GitHub client that uses the GitHub App's fallback token
1018
func NewFallbackTokenClient(appConfig config.ProviderConfig) *github.Client {
3✔
1019
        if appConfig.GitHubApp == nil {
4✔
1020
                return nil
1✔
1021
        }
1✔
1022
        fallbackToken, err := appConfig.GitHubApp.GetFallbackToken()
2✔
1023
        if err != nil || fallbackToken == "" {
3✔
1024
                return nil
1✔
1025
        }
1✔
1026
        var packageListingClient *github.Client
1✔
1027

1✔
1028
        fallbackTokenSource := oauth2.StaticTokenSource(
1✔
1029
                &oauth2.Token{AccessToken: fallbackToken},
1✔
1030
        )
1✔
1031
        fallbackTokenTC := &http.Client{
1✔
1032
                Transport: &oauth2.Transport{
1✔
1033
                        Base:   http.DefaultClient.Transport,
1✔
1034
                        Source: fallbackTokenSource,
1✔
1035
                },
1✔
1036
        }
1✔
1037

1✔
1038
        packageListingClient = github.NewClient(fallbackTokenTC)
1✔
1039
        return packageListingClient
1✔
1040
}
1041

1042
// StartCheckRun calls the GitHub API to initialize a new check using the
1043
// supplied options.
1044
func (c *GitHub) StartCheckRun(
1045
        ctx context.Context, owner, repo string, opts *github.CreateCheckRunOptions,
1046
) (*github.CheckRun, error) {
2✔
1047
        if opts.StartedAt == nil {
3✔
1048
                opts.StartedAt = &github.Timestamp{Time: time.Now()}
1✔
1049
        }
1✔
1050

1051
        run, resp, err := c.client.Checks.CreateCheckRun(ctx, owner, repo, *opts)
2✔
1052
        if err != nil {
3✔
1053
                if isRateLimitError(err) {
1✔
NEW
1054
                        return nil, c.waitForRateLimitReset(ctx, err)
×
NEW
1055
                }
×
1056
                // If error is 403 then it means we are missing permissions
1057
                if resp != nil && resp.StatusCode == 403 {
2✔
1058
                        return nil, fmt.Errorf("missing permissions: check")
1✔
1059
                }
1✔
1060
                return nil, ErroNoCheckPermissions
×
1061
        }
1062
        return run, nil
1✔
1063
}
1064

1065
// UpdateCheckRun updates an existing check run in GitHub. The check run is referenced
1066
// using its run ID. This function returns the updated CheckRun srtuct.
1067
func (c *GitHub) UpdateCheckRun(
1068
        ctx context.Context, owner, repo string, checkRunID int64, opts *github.UpdateCheckRunOptions,
1069
) (*github.CheckRun, error) {
2✔
1070
        run, resp, err := c.client.Checks.UpdateCheckRun(ctx, owner, repo, checkRunID, *opts)
2✔
1071
        if err != nil {
3✔
1072
                if isRateLimitError(err) {
1✔
NEW
1073
                        return nil, c.waitForRateLimitReset(ctx, err)
×
NEW
1074
                }
×
1075
                // If error is 403 then it means we are missing permissions
1076
                if resp != nil && resp.StatusCode == 403 {
2✔
1077
                        return nil, ErroNoCheckPermissions
1✔
1078
                }
1✔
1079
                return nil, fmt.Errorf("updating check: %w", err)
×
1080
        }
1081
        return run, nil
1✔
1082
}
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