2020-10-26 23:22:13 +03:00
|
|
|
// Copyright 2020 Security Scorecard Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2020-10-09 17:47:59 +03:00
|
|
|
package checks
|
|
|
|
|
|
|
|
import (
|
2021-05-14 22:41:50 +03:00
|
|
|
"fmt"
|
2020-10-09 17:47:59 +03:00
|
|
|
"strings"
|
|
|
|
|
2022-01-12 22:49:01 +03:00
|
|
|
"github.com/ossf/scorecard/v4/checker"
|
|
|
|
"github.com/ossf/scorecard/v4/clients"
|
|
|
|
sce "github.com/ossf/scorecard/v4/errors"
|
2020-10-09 17:47:59 +03:00
|
|
|
)
|
|
|
|
|
2021-05-14 22:41:50 +03:00
|
|
|
const (
|
2021-05-28 00:54:34 +03:00
|
|
|
// CheckCITests is the registered name for CITests.
|
CI-Test: stop assuming either "statuses" or "check runs" are used (#1259)
Projects with a lot of different CI services use both and the check
should take that into account so as not to report that PRs
like https://github.com/systemd/systemd/pull/21329
with 28 successful, 4 failing, and 2 neutral checks were merged
without any tests.
Without this patch `scorecard` says that 5 out 30 PRs were merged
without running tests:
```
"Debug: CI test found: pr: 21299, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/472a52d22b9f505a4c284e7ad020ea1b3728466d",
"Debug: CI test found: pr: 21300, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/cf35602cbc1bffcb5ab01153af153d0bf4e5a7e9",
"Debug: CI test found: pr: 21301, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/13b7b8bd7362d198e123a67b8dfdc1c558df5b21",
"Debug: CI test found: pr: 21302, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/dfa4876c417e2a9935d58100d44d94bb41cd5bfb",
"Debug: CI test found: pr: 21304, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/01f6c450b655a8ce233cb5feeaddb4ec8a5610f7",
"Debug: CI test found: pr: 21305, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/547f97d5714b6e1efb8c64fd60b001c13c8880d0",
"Debug: CI test found: pr: 21310, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/0078bbb232ce7dc6f6bf30bba8b8b26645f58b26",
"Debug: CI test found: pr: 21312, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/df8a8240d33a04f66a0ffd756fac2d35b52274da",
"Debug: merged PR without CI test: 21313",
"Debug: CI test found: pr: 21314, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a942a2784005212c34bba790fd7d4688d3bc098c",
"Debug: CI test found: pr: 21316, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/3fec0e6cbfbfa17e018d88efbdf2e7a9231f364b",
"Debug: CI test found: pr: 21318, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/db4f0788c51b7ec70369604a8a327e682c98405c",
"Debug: CI test found: pr: 21320, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/875afa02fabe1dad5aa3d1e9bff89d493a369fd0",
"Debug: CI test found: pr: 21321, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a55277b88966d7449222c21a663b7dd9d3d330bb",
"Debug: CI test found: pr: 21324, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/b9df4a2b208f586838ecf19648169406cf8c71e9",
"Debug: merged PR without CI test: 21325",
"Debug: CI test found: pr: 21327, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/44ddfb922f1434411763a9a0d92d4778f75054f8",
"Debug: CI test found: pr: 21328, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5e034d4d32ce2a0374c9613cf2660d146a35e830",
"Debug: merged PR without CI test: 21329",
"Debug: CI test found: pr: 21330, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4df52c20f4ddc6249c114c4476b50ec9b640ec20",
"Debug: CI test found: pr: 21331, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5dd57a00d5c48e0553062e8eb39357c5f36df20b",
"Debug: merged PR without CI test: 21332",
"Debug: CI test found: pr: 21333, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/e0c311b1aa146852b992c1501d032a6908033c25",
"Debug: CI test found: pr: 21334, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/55caae6a787ab328d7bc52adfd92aefecf789ec9",
"Debug: CI test found: pr: 21335, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/f1d467af2589d129ccd6bba9ed7eaa0b77e568a2",
"Debug: merged PR without CI test: 21337",
"Debug: CI test found: pr: 21341, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/17f8d8f9b4bfaf0ea191409030c511cd713f64eb",
"Debug: CI test found: pr: 21342, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/38ac3ab10aaad96ece4805ca29354e0006a51719",
"Debug: CI test found: pr: 21347, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4f8c9645dfaad98b544e0ba3fdc9258513d8669f",
"Debug: CI test found: pr: 21349, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/502e2b4b9e1dd54a6ac29e7609c2d5e8aa220384"
```
With this patch:
```
"Debug: CI test found: pr: 21299, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/472a52d22b9f505a4c284e7ad020ea1b3728466d",
"Debug: CI test found: pr: 21300, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/cf35602cbc1bffcb5ab01153af153d0bf4e5a7e9",
"Debug: CI test found: pr: 21301, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/13b7b8bd7362d198e123a67b8dfdc1c558df5b21",
"Debug: CI test found: pr: 21302, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/dfa4876c417e2a9935d58100d44d94bb41cd5bfb",
"Debug: CI test found: pr: 21304, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/01f6c450b655a8ce233cb5feeaddb4ec8a5610f7",
"Debug: CI test found: pr: 21305, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/547f97d5714b6e1efb8c64fd60b001c13c8880d0",
"Debug: CI test found: pr: 21310, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/0078bbb232ce7dc6f6bf30bba8b8b26645f58b26",
"Debug: CI test found: pr: 21312, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/df8a8240d33a04f66a0ffd756fac2d35b52274da",
"Debug: CI test found: pr: 21313, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4191612395",
"Debug: CI test found: pr: 21314, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a942a2784005212c34bba790fd7d4688d3bc098c",
"Debug: CI test found: pr: 21316, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/3fec0e6cbfbfa17e018d88efbdf2e7a9231f364b",
"Debug: CI test found: pr: 21318, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/db4f0788c51b7ec70369604a8a327e682c98405c",
"Debug: CI test found: pr: 21320, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/875afa02fabe1dad5aa3d1e9bff89d493a369fd0",
"Debug: CI test found: pr: 21321, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a55277b88966d7449222c21a663b7dd9d3d330bb",
"Debug: CI test found: pr: 21324, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/b9df4a2b208f586838ecf19648169406cf8c71e9",
"Debug: CI test found: pr: 21325, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4191237494",
"Debug: CI test found: pr: 21327, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/44ddfb922f1434411763a9a0d92d4778f75054f8",
"Debug: CI test found: pr: 21328, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5e034d4d32ce2a0374c9613cf2660d146a35e830",
"Debug: CI test found: pr: 21329, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4192198481",
"Debug: CI test found: pr: 21330, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4df52c20f4ddc6249c114c4476b50ec9b640ec20",
"Debug: CI test found: pr: 21331, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5dd57a00d5c48e0553062e8eb39357c5f36df20b",
"Debug: CI test found: pr: 21332, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4192365458",
"Debug: CI test found: pr: 21333, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/e0c311b1aa146852b992c1501d032a6908033c25",
"Debug: CI test found: pr: 21334, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/55caae6a787ab328d7bc52adfd92aefecf789ec9",
"Debug: CI test found: pr: 21335, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/f1d467af2589d129ccd6bba9ed7eaa0b77e568a2",
"Debug: CI test found: pr: 21337, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4197451714",
"Debug: CI test found: pr: 21341, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/17f8d8f9b4bfaf0ea191409030c511cd713f64eb",
"Debug: CI test found: pr: 21342, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/38ac3ab10aaad96ece4805ca29354e0006a51719",
"Debug: CI test found: pr: 21347, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4f8c9645dfaad98b544e0ba3fdc9258513d8669f",
"Debug: CI test found: pr: 21349, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/502e2b4b9e1dd54a6ac29e7609c2d5e8aa220384"
```
Co-authored-by: Naveen <172697+naveensrinivasan@users.noreply.github.com>
2021-11-15 03:03:18 +03:00
|
|
|
CheckCITests = "CI-Tests"
|
|
|
|
success = "success"
|
2021-05-14 22:41:50 +03:00
|
|
|
)
|
2021-04-10 15:26:56 +03:00
|
|
|
|
2021-05-22 20:19:52 +03:00
|
|
|
//nolint:gochecknoinits
|
2020-10-09 17:47:59 +03:00
|
|
|
func init() {
|
2022-02-08 06:03:36 +03:00
|
|
|
supportedRequestTypes := []checker.RequestType{
|
|
|
|
checker.CommitBased,
|
|
|
|
}
|
|
|
|
if err := registerCheck(CheckCITests, CITests, supportedRequestTypes); err != nil {
|
2022-01-13 01:14:18 +03:00
|
|
|
// this should never happen
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-10-09 17:47:59 +03:00
|
|
|
}
|
|
|
|
|
2021-08-01 01:31:34 +03:00
|
|
|
// CITests runs CI-Tests check.
|
2021-04-19 22:18:34 +03:00
|
|
|
func CITests(c *checker.CheckRequest) checker.CheckResult {
|
2022-02-03 03:01:35 +03:00
|
|
|
commits, err := c.RepoClient.ListCommits()
|
2020-10-09 17:47:59 +03:00
|
|
|
if err != nil {
|
2022-02-03 03:01:35 +03:00
|
|
|
e := sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("RepoClient.ListCommits: %v", err))
|
2021-07-22 18:37:31 +03:00
|
|
|
return checker.CreateRuntimeErrorResult(CheckCITests, e)
|
2020-10-09 17:47:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
totalMerged := 0
|
|
|
|
totalTested := 0
|
2022-02-03 03:01:35 +03:00
|
|
|
for i := range commits {
|
|
|
|
pr := &commits[i].AssociatedMergeRequest
|
|
|
|
// TODO(#575): We ignore associated PRs if Scorecard is being run on a fork
|
|
|
|
// but the PR was created in the original repo.
|
2021-08-12 01:27:48 +03:00
|
|
|
if pr.MergedAt.IsZero() {
|
2020-10-09 17:47:59 +03:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
totalMerged++
|
2020-12-23 05:01:44 +03:00
|
|
|
|
|
|
|
var foundCI bool
|
|
|
|
|
2021-05-14 22:41:50 +03:00
|
|
|
// Github Statuses.
|
CI-Test: stop assuming either "statuses" or "check runs" are used (#1259)
Projects with a lot of different CI services use both and the check
should take that into account so as not to report that PRs
like https://github.com/systemd/systemd/pull/21329
with 28 successful, 4 failing, and 2 neutral checks were merged
without any tests.
Without this patch `scorecard` says that 5 out 30 PRs were merged
without running tests:
```
"Debug: CI test found: pr: 21299, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/472a52d22b9f505a4c284e7ad020ea1b3728466d",
"Debug: CI test found: pr: 21300, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/cf35602cbc1bffcb5ab01153af153d0bf4e5a7e9",
"Debug: CI test found: pr: 21301, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/13b7b8bd7362d198e123a67b8dfdc1c558df5b21",
"Debug: CI test found: pr: 21302, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/dfa4876c417e2a9935d58100d44d94bb41cd5bfb",
"Debug: CI test found: pr: 21304, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/01f6c450b655a8ce233cb5feeaddb4ec8a5610f7",
"Debug: CI test found: pr: 21305, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/547f97d5714b6e1efb8c64fd60b001c13c8880d0",
"Debug: CI test found: pr: 21310, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/0078bbb232ce7dc6f6bf30bba8b8b26645f58b26",
"Debug: CI test found: pr: 21312, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/df8a8240d33a04f66a0ffd756fac2d35b52274da",
"Debug: merged PR without CI test: 21313",
"Debug: CI test found: pr: 21314, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a942a2784005212c34bba790fd7d4688d3bc098c",
"Debug: CI test found: pr: 21316, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/3fec0e6cbfbfa17e018d88efbdf2e7a9231f364b",
"Debug: CI test found: pr: 21318, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/db4f0788c51b7ec70369604a8a327e682c98405c",
"Debug: CI test found: pr: 21320, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/875afa02fabe1dad5aa3d1e9bff89d493a369fd0",
"Debug: CI test found: pr: 21321, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a55277b88966d7449222c21a663b7dd9d3d330bb",
"Debug: CI test found: pr: 21324, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/b9df4a2b208f586838ecf19648169406cf8c71e9",
"Debug: merged PR without CI test: 21325",
"Debug: CI test found: pr: 21327, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/44ddfb922f1434411763a9a0d92d4778f75054f8",
"Debug: CI test found: pr: 21328, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5e034d4d32ce2a0374c9613cf2660d146a35e830",
"Debug: merged PR without CI test: 21329",
"Debug: CI test found: pr: 21330, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4df52c20f4ddc6249c114c4476b50ec9b640ec20",
"Debug: CI test found: pr: 21331, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5dd57a00d5c48e0553062e8eb39357c5f36df20b",
"Debug: merged PR without CI test: 21332",
"Debug: CI test found: pr: 21333, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/e0c311b1aa146852b992c1501d032a6908033c25",
"Debug: CI test found: pr: 21334, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/55caae6a787ab328d7bc52adfd92aefecf789ec9",
"Debug: CI test found: pr: 21335, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/f1d467af2589d129ccd6bba9ed7eaa0b77e568a2",
"Debug: merged PR without CI test: 21337",
"Debug: CI test found: pr: 21341, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/17f8d8f9b4bfaf0ea191409030c511cd713f64eb",
"Debug: CI test found: pr: 21342, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/38ac3ab10aaad96ece4805ca29354e0006a51719",
"Debug: CI test found: pr: 21347, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4f8c9645dfaad98b544e0ba3fdc9258513d8669f",
"Debug: CI test found: pr: 21349, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/502e2b4b9e1dd54a6ac29e7609c2d5e8aa220384"
```
With this patch:
```
"Debug: CI test found: pr: 21299, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/472a52d22b9f505a4c284e7ad020ea1b3728466d",
"Debug: CI test found: pr: 21300, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/cf35602cbc1bffcb5ab01153af153d0bf4e5a7e9",
"Debug: CI test found: pr: 21301, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/13b7b8bd7362d198e123a67b8dfdc1c558df5b21",
"Debug: CI test found: pr: 21302, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/dfa4876c417e2a9935d58100d44d94bb41cd5bfb",
"Debug: CI test found: pr: 21304, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/01f6c450b655a8ce233cb5feeaddb4ec8a5610f7",
"Debug: CI test found: pr: 21305, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/547f97d5714b6e1efb8c64fd60b001c13c8880d0",
"Debug: CI test found: pr: 21310, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/0078bbb232ce7dc6f6bf30bba8b8b26645f58b26",
"Debug: CI test found: pr: 21312, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/df8a8240d33a04f66a0ffd756fac2d35b52274da",
"Debug: CI test found: pr: 21313, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4191612395",
"Debug: CI test found: pr: 21314, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a942a2784005212c34bba790fd7d4688d3bc098c",
"Debug: CI test found: pr: 21316, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/3fec0e6cbfbfa17e018d88efbdf2e7a9231f364b",
"Debug: CI test found: pr: 21318, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/db4f0788c51b7ec70369604a8a327e682c98405c",
"Debug: CI test found: pr: 21320, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/875afa02fabe1dad5aa3d1e9bff89d493a369fd0",
"Debug: CI test found: pr: 21321, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a55277b88966d7449222c21a663b7dd9d3d330bb",
"Debug: CI test found: pr: 21324, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/b9df4a2b208f586838ecf19648169406cf8c71e9",
"Debug: CI test found: pr: 21325, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4191237494",
"Debug: CI test found: pr: 21327, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/44ddfb922f1434411763a9a0d92d4778f75054f8",
"Debug: CI test found: pr: 21328, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5e034d4d32ce2a0374c9613cf2660d146a35e830",
"Debug: CI test found: pr: 21329, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4192198481",
"Debug: CI test found: pr: 21330, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4df52c20f4ddc6249c114c4476b50ec9b640ec20",
"Debug: CI test found: pr: 21331, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5dd57a00d5c48e0553062e8eb39357c5f36df20b",
"Debug: CI test found: pr: 21332, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4192365458",
"Debug: CI test found: pr: 21333, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/e0c311b1aa146852b992c1501d032a6908033c25",
"Debug: CI test found: pr: 21334, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/55caae6a787ab328d7bc52adfd92aefecf789ec9",
"Debug: CI test found: pr: 21335, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/f1d467af2589d129ccd6bba9ed7eaa0b77e568a2",
"Debug: CI test found: pr: 21337, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4197451714",
"Debug: CI test found: pr: 21341, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/17f8d8f9b4bfaf0ea191409030c511cd713f64eb",
"Debug: CI test found: pr: 21342, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/38ac3ab10aaad96ece4805ca29354e0006a51719",
"Debug: CI test found: pr: 21347, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4f8c9645dfaad98b544e0ba3fdc9258513d8669f",
"Debug: CI test found: pr: 21349, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/502e2b4b9e1dd54a6ac29e7609c2d5e8aa220384"
```
Co-authored-by: Naveen <172697+naveensrinivasan@users.noreply.github.com>
2021-11-15 03:03:18 +03:00
|
|
|
prSuccessStatus, err := prHasSuccessStatus(pr, c)
|
|
|
|
if err != nil {
|
|
|
|
return checker.CreateRuntimeErrorResult(CheckCITests, err)
|
|
|
|
}
|
|
|
|
if prSuccessStatus {
|
|
|
|
totalTested++
|
|
|
|
foundCI = true
|
|
|
|
continue
|
2020-12-23 05:01:44 +03:00
|
|
|
}
|
|
|
|
|
2021-07-22 18:37:31 +03:00
|
|
|
// Github Check Runs.
|
CI-Test: stop assuming either "statuses" or "check runs" are used (#1259)
Projects with a lot of different CI services use both and the check
should take that into account so as not to report that PRs
like https://github.com/systemd/systemd/pull/21329
with 28 successful, 4 failing, and 2 neutral checks were merged
without any tests.
Without this patch `scorecard` says that 5 out 30 PRs were merged
without running tests:
```
"Debug: CI test found: pr: 21299, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/472a52d22b9f505a4c284e7ad020ea1b3728466d",
"Debug: CI test found: pr: 21300, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/cf35602cbc1bffcb5ab01153af153d0bf4e5a7e9",
"Debug: CI test found: pr: 21301, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/13b7b8bd7362d198e123a67b8dfdc1c558df5b21",
"Debug: CI test found: pr: 21302, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/dfa4876c417e2a9935d58100d44d94bb41cd5bfb",
"Debug: CI test found: pr: 21304, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/01f6c450b655a8ce233cb5feeaddb4ec8a5610f7",
"Debug: CI test found: pr: 21305, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/547f97d5714b6e1efb8c64fd60b001c13c8880d0",
"Debug: CI test found: pr: 21310, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/0078bbb232ce7dc6f6bf30bba8b8b26645f58b26",
"Debug: CI test found: pr: 21312, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/df8a8240d33a04f66a0ffd756fac2d35b52274da",
"Debug: merged PR without CI test: 21313",
"Debug: CI test found: pr: 21314, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a942a2784005212c34bba790fd7d4688d3bc098c",
"Debug: CI test found: pr: 21316, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/3fec0e6cbfbfa17e018d88efbdf2e7a9231f364b",
"Debug: CI test found: pr: 21318, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/db4f0788c51b7ec70369604a8a327e682c98405c",
"Debug: CI test found: pr: 21320, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/875afa02fabe1dad5aa3d1e9bff89d493a369fd0",
"Debug: CI test found: pr: 21321, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a55277b88966d7449222c21a663b7dd9d3d330bb",
"Debug: CI test found: pr: 21324, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/b9df4a2b208f586838ecf19648169406cf8c71e9",
"Debug: merged PR without CI test: 21325",
"Debug: CI test found: pr: 21327, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/44ddfb922f1434411763a9a0d92d4778f75054f8",
"Debug: CI test found: pr: 21328, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5e034d4d32ce2a0374c9613cf2660d146a35e830",
"Debug: merged PR without CI test: 21329",
"Debug: CI test found: pr: 21330, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4df52c20f4ddc6249c114c4476b50ec9b640ec20",
"Debug: CI test found: pr: 21331, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5dd57a00d5c48e0553062e8eb39357c5f36df20b",
"Debug: merged PR without CI test: 21332",
"Debug: CI test found: pr: 21333, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/e0c311b1aa146852b992c1501d032a6908033c25",
"Debug: CI test found: pr: 21334, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/55caae6a787ab328d7bc52adfd92aefecf789ec9",
"Debug: CI test found: pr: 21335, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/f1d467af2589d129ccd6bba9ed7eaa0b77e568a2",
"Debug: merged PR without CI test: 21337",
"Debug: CI test found: pr: 21341, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/17f8d8f9b4bfaf0ea191409030c511cd713f64eb",
"Debug: CI test found: pr: 21342, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/38ac3ab10aaad96ece4805ca29354e0006a51719",
"Debug: CI test found: pr: 21347, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4f8c9645dfaad98b544e0ba3fdc9258513d8669f",
"Debug: CI test found: pr: 21349, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/502e2b4b9e1dd54a6ac29e7609c2d5e8aa220384"
```
With this patch:
```
"Debug: CI test found: pr: 21299, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/472a52d22b9f505a4c284e7ad020ea1b3728466d",
"Debug: CI test found: pr: 21300, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/cf35602cbc1bffcb5ab01153af153d0bf4e5a7e9",
"Debug: CI test found: pr: 21301, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/13b7b8bd7362d198e123a67b8dfdc1c558df5b21",
"Debug: CI test found: pr: 21302, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/dfa4876c417e2a9935d58100d44d94bb41cd5bfb",
"Debug: CI test found: pr: 21304, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/01f6c450b655a8ce233cb5feeaddb4ec8a5610f7",
"Debug: CI test found: pr: 21305, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/547f97d5714b6e1efb8c64fd60b001c13c8880d0",
"Debug: CI test found: pr: 21310, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/0078bbb232ce7dc6f6bf30bba8b8b26645f58b26",
"Debug: CI test found: pr: 21312, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/df8a8240d33a04f66a0ffd756fac2d35b52274da",
"Debug: CI test found: pr: 21313, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4191612395",
"Debug: CI test found: pr: 21314, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a942a2784005212c34bba790fd7d4688d3bc098c",
"Debug: CI test found: pr: 21316, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/3fec0e6cbfbfa17e018d88efbdf2e7a9231f364b",
"Debug: CI test found: pr: 21318, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/db4f0788c51b7ec70369604a8a327e682c98405c",
"Debug: CI test found: pr: 21320, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/875afa02fabe1dad5aa3d1e9bff89d493a369fd0",
"Debug: CI test found: pr: 21321, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/a55277b88966d7449222c21a663b7dd9d3d330bb",
"Debug: CI test found: pr: 21324, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/b9df4a2b208f586838ecf19648169406cf8c71e9",
"Debug: CI test found: pr: 21325, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4191237494",
"Debug: CI test found: pr: 21327, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/44ddfb922f1434411763a9a0d92d4778f75054f8",
"Debug: CI test found: pr: 21328, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5e034d4d32ce2a0374c9613cf2660d146a35e830",
"Debug: CI test found: pr: 21329, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4192198481",
"Debug: CI test found: pr: 21330, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4df52c20f4ddc6249c114c4476b50ec9b640ec20",
"Debug: CI test found: pr: 21331, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/5dd57a00d5c48e0553062e8eb39357c5f36df20b",
"Debug: CI test found: pr: 21332, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4192365458",
"Debug: CI test found: pr: 21333, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/e0c311b1aa146852b992c1501d032a6908033c25",
"Debug: CI test found: pr: 21334, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/55caae6a787ab328d7bc52adfd92aefecf789ec9",
"Debug: CI test found: pr: 21335, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/f1d467af2589d129ccd6bba9ed7eaa0b77e568a2",
"Debug: CI test found: pr: 21337, context: github-actions: https://api.github.com/repos/systemd/systemd/check-runs/4197451714",
"Debug: CI test found: pr: 21341, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/17f8d8f9b4bfaf0ea191409030c511cd713f64eb",
"Debug: CI test found: pr: 21342, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/38ac3ab10aaad96ece4805ca29354e0006a51719",
"Debug: CI test found: pr: 21347, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/4f8c9645dfaad98b544e0ba3fdc9258513d8669f",
"Debug: CI test found: pr: 21349, context: ci/semaphoreci/pr: Debian autopkgtest (LXC): https://api.github.com/repos/systemd/systemd/statuses/502e2b4b9e1dd54a6ac29e7609c2d5e8aa220384"
```
Co-authored-by: Naveen <172697+naveensrinivasan@users.noreply.github.com>
2021-11-15 03:03:18 +03:00
|
|
|
prCheckSuccessful, err := prHasSuccessfulCheck(pr, c)
|
|
|
|
if err != nil {
|
|
|
|
return checker.CreateRuntimeErrorResult(CheckCITests, err)
|
|
|
|
}
|
|
|
|
if prCheckSuccessful {
|
|
|
|
totalTested++
|
|
|
|
foundCI = true
|
2020-10-12 20:18:40 +03:00
|
|
|
}
|
2020-12-23 05:01:44 +03:00
|
|
|
|
|
|
|
if !foundCI {
|
2022-02-12 02:48:58 +03:00
|
|
|
c.Dlogger.Debug(&checker.LogMessage{
|
2022-02-15 21:26:06 +03:00
|
|
|
Text: fmt.Sprintf("merged PR without CI test: %d", pr.Number),
|
2021-08-24 03:54:22 +03:00
|
|
|
})
|
2020-12-23 05:01:44 +03:00
|
|
|
}
|
2020-10-12 20:18:40 +03:00
|
|
|
}
|
2020-12-23 05:01:44 +03:00
|
|
|
|
2021-07-22 18:37:31 +03:00
|
|
|
if totalMerged == 0 {
|
|
|
|
return checker.CreateInconclusiveResult(CheckCITests, "no pull request found")
|
|
|
|
}
|
|
|
|
|
|
|
|
reason := fmt.Sprintf("%d out of %d merged PRs checked by a CI test", totalTested, totalMerged)
|
|
|
|
return checker.CreateProportionalScoreResult(CheckCITests, reason, totalTested, totalMerged)
|
2020-10-12 20:18:40 +03:00
|
|
|
}
|
|
|
|
|
2021-05-14 22:41:50 +03:00
|
|
|
// PR has a status marked 'success' and a CI-related context.
|
2021-08-12 01:27:48 +03:00
|
|
|
func prHasSuccessStatus(pr *clients.PullRequest, c *checker.CheckRequest) (bool, error) {
|
2021-09-01 21:34:58 +03:00
|
|
|
statuses, err := c.RepoClient.ListStatuses(pr.HeadSHA)
|
2021-05-14 22:41:50 +03:00
|
|
|
if err != nil {
|
2021-09-10 18:50:33 +03:00
|
|
|
return false, sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("Client.Repositories.ListStatuses: %v", err))
|
2021-05-14 22:41:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, status := range statuses {
|
2021-09-01 21:34:58 +03:00
|
|
|
if status.State != success {
|
2021-05-14 22:41:50 +03:00
|
|
|
continue
|
|
|
|
}
|
2021-12-08 20:34:28 +03:00
|
|
|
if isTest(status.Context) || isTest(status.TargetURL) {
|
2022-02-12 02:48:58 +03:00
|
|
|
c.Dlogger.Debug(&checker.LogMessage{
|
2021-09-01 21:34:58 +03:00
|
|
|
Path: status.URL,
|
2021-08-24 03:54:22 +03:00
|
|
|
Type: checker.FileTypeURL,
|
|
|
|
Text: fmt.Sprintf("CI test found: pr: %d, context: %s", pr.Number,
|
2021-09-01 21:34:58 +03:00
|
|
|
status.Context),
|
2021-08-24 03:54:22 +03:00
|
|
|
})
|
2021-05-14 22:41:50 +03:00
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// PR has a successful CI-related check.
|
2021-08-12 01:27:48 +03:00
|
|
|
func prHasSuccessfulCheck(pr *clients.PullRequest, c *checker.CheckRequest) (bool, error) {
|
2021-09-01 20:43:53 +03:00
|
|
|
crs, err := c.RepoClient.ListCheckRunsForRef(pr.HeadSHA)
|
2021-07-22 18:37:31 +03:00
|
|
|
if err != nil {
|
2021-09-10 18:50:33 +03:00
|
|
|
return false, sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("Client.Checks.ListCheckRunsForRef: %v", err))
|
2021-07-22 18:37:31 +03:00
|
|
|
}
|
2021-05-14 22:41:50 +03:00
|
|
|
|
2021-09-01 20:43:53 +03:00
|
|
|
for _, cr := range crs {
|
|
|
|
if cr.Status != "completed" {
|
2021-05-14 22:41:50 +03:00
|
|
|
continue
|
|
|
|
}
|
2021-09-01 20:43:53 +03:00
|
|
|
if cr.Conclusion != success {
|
2021-05-14 22:41:50 +03:00
|
|
|
continue
|
|
|
|
}
|
2021-09-01 20:43:53 +03:00
|
|
|
if isTest(cr.App.Slug) {
|
2022-02-12 02:48:58 +03:00
|
|
|
c.Dlogger.Debug(&checker.LogMessage{
|
2021-09-01 20:43:53 +03:00
|
|
|
Path: cr.URL,
|
2021-08-24 03:54:22 +03:00
|
|
|
Type: checker.FileTypeURL,
|
|
|
|
Text: fmt.Sprintf("CI test found: pr: %d, context: %s", pr.Number,
|
2021-09-01 20:43:53 +03:00
|
|
|
cr.App.Slug),
|
2021-08-24 03:54:22 +03:00
|
|
|
})
|
2021-05-14 22:41:50 +03:00
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
2022-01-11 19:28:07 +03:00
|
|
|
// isTest returns true if the given string is a CI test.
|
2020-10-12 20:18:40 +03:00
|
|
|
func isTest(s string) bool {
|
|
|
|
l := strings.ToLower(s)
|
|
|
|
|
|
|
|
// Add more patterns here!
|
2021-04-29 05:54:07 +03:00
|
|
|
for _, pattern := range []string{
|
|
|
|
"appveyor", "buildkite", "circleci", "e2e", "github-actions", "jenkins",
|
2021-12-04 02:33:01 +03:00
|
|
|
"mergeable", "packit-as-a-service", "semaphoreci", "test", "travis-ci",
|
2022-01-28 04:42:50 +03:00
|
|
|
"flutter-dashboard", "Cirrus CI",
|
2021-04-29 05:54:07 +03:00
|
|
|
} {
|
2020-10-12 20:18:40 +03:00
|
|
|
if strings.Contains(l, pattern) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|