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

badges / shields / 45774165149

22 Nov 2026 09:43PM UTC coverage: 79.735% (-18.4%) from 98.17%
45774165149

push

github

web-flow
[Endpoint] Support message override and position it after label in API docs (#12235)

* [Endpoint] Support message override and position it after label in API docs

* Preserve error message when a message override is provided

3371 of 3616 branches covered (93.22%)

43 of 53 new or added lines in 3 files covered. (81.13%)

9589 existing lines in 490 files now uncovered.

41514 of 52065 relevant lines covered (79.73%)

51.0 hits per line

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

53.68
/services/github/github-auth-service.js
1
import gql from 'graphql-tag'
2 ✔
2
import { mergeQueries } from '../../core/base-service/graphql.js'
2 ✔
3
import { BaseGraphqlService, BaseJsonService } from '../index.js'
2 ✔
4

2 ✔
5
function createRequestFetcher(context) {
1 ✔
6
  const { requestFetcher, githubApiProvider } = context
1 ✔
7
  return githubApiProvider.fetch.bind(githubApiProvider, requestFetcher)
1 ✔
8
}
1 ✔
9

2 ✔
10
class GithubAuthV3Service extends BaseJsonService {
2 ✔
11
  constructor(context, config) {
2 ✔
12
    super(context, config)
1 ✔
13
    this._requestFetcher = createRequestFetcher(context)
1 ✔
14
    this.staticAuthConfigured = true
1 ✔
15
  }
1 ✔
16
}
2 ✔
17

2 ✔
18
// Use Github auth, but only when static auth is configured. By using this
2 ✔
19
// class, in production it will behave like GithubAuthV3Service, and in self-
2 ✔
20
// hosting (i.e. with a configured token) like BaseJsonService. This is
2 ✔
21
// useful when consuming GitHub endpoints which are not rate-limited: it
2 ✔
22
// avoids wasting API quota on them in production.
2 ✔
23
class ConditionalGithubAuthV3Service extends BaseJsonService {
2 ✔
24
  constructor(context, config) {
2 ✔
UNCOV
25
    super(context, config)
×
UNCOV
26
    if (context.githubApiProvider.globalToken) {
×
UNCOV
27
      this._requestFetcher = createRequestFetcher(context)
×
UNCOV
28
      this.staticAuthConfigured = true
×
UNCOV
29
    } else {
×
30
      this.staticAuthConfigured = false
×
31
    }
×
UNCOV
32
  }
×
33
}
2 ✔
34

2 ✔
35
class GithubAuthV4Service extends BaseGraphqlService {
2 ✔
36
  constructor(context, config) {
2 ✔
UNCOV
37
    super(context, config)
×
UNCOV
38
    this._requestFetcher = createRequestFetcher(context)
×
UNCOV
39
    this.staticAuthConfigured = true
×
UNCOV
40
  }
×
41

2 ✔
42
  async _requestGraphql(attrs) {
2 ✔
UNCOV
43
    const url = '/graphql'
×
UNCOV
44

×
UNCOV
45
    /*
×
UNCOV
46
    The Github v4 API requires us to query the rateLimit object to return
×
UNCOV
47
    rate limit info in the query body instead of the headers:
×
UNCOV
48
    https://developer.github.com/v4/guides/resource-limitations/#returning-a-calls-rate-limit-status
×
UNCOV
49
    This appends the relevant rateLimit query clause to each
×
UNCOV
50
    call to the GH v4 API so we can keep track of token usage.
×
UNCOV
51
    */
×
UNCOV
52
    const query = mergeQueries(
×
UNCOV
53
      attrs.query,
×
UNCOV
54
      gql`
×
UNCOV
55
        query {
×
UNCOV
56
          rateLimit {
×
UNCOV
57
            limit
×
UNCOV
58
            cost
×
UNCOV
59
            remaining
×
UNCOV
60
            resetAt
×
UNCOV
61
          }
×
UNCOV
62
        }
×
UNCOV
63
      `,
×
UNCOV
64
    )
×
UNCOV
65

×
UNCOV
66
    return super._requestGraphql({
×
UNCOV
67
      ...attrs,
×
UNCOV
68
      ...{
×
UNCOV
69
        url,
×
UNCOV
70
        query,
×
UNCOV
71
        httpErrorMessages: { 401: 'auth required for graphql api' },
×
UNCOV
72
      },
×
UNCOV
73
    })
×
UNCOV
74
  }
×
75
}
2 ✔
76

2 ✔
77
/*
2 ✔
78
Choosing between the Github V3 and V4 APIs when creating a new badge:
2 ✔
79

2 ✔
80
With the V3 API, one request = one point off the usage limit.
2 ✔
81
With the V4 API one request may be many points off the usage limit depending
2 ✔
82
on the query (but will be a minimum of one).
2 ✔
83
https://developer.github.com/v4/guides/resource-limitations/#calculating-nodes-in-a-call
2 ✔
84

2 ✔
85
If we can save ourselves some usage limit it may be worth going with a
2 ✔
86
REST (V3) call over a graphql query.
2 ✔
87
All other things being equal, a graphql query will almost always be a smaller
2 ✔
88
number of bytes over the wire and a smaller/simpler object to parse.
2 ✔
89
*/
2 ✔
90

2 ✔
91
export {
2 ✔
92
  GithubAuthV3Service,
2 ✔
93
  ConditionalGithubAuthV3Service,
2 ✔
94
  GithubAuthV4Service,
2 ✔
95
}
2 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc