Skip to content

Commit 513c6eb

Browse files
🌱 Add config e2e test and fix README (#4232)
* add config e2e test Signed-off-by: Spencer Schrock <[email protected]> * update readme syntax The old syntax was changed so the README was out of date. This was exposed when setting up the e2e repo. Signed-off-by: Spencer Schrock <[email protected]> * fix rename Signed-off-by: Spencer Schrock <[email protected]> --------- Signed-off-by: Spencer Schrock <[email protected]>
1 parent c368d8a commit 513c6eb

File tree

2 files changed

+52
-15
lines changed

2 files changed

+52
-15
lines changed

config/README.md

+12-15
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,37 @@ To annotate your repository, create a `scorecard.yml` file in the root of your r
1010
The file structure is as follows:
1111

1212
```yml
13-
exemptions:
13+
annotations:
1414
- checks:
1515
- binary-artifacts
16-
annotations:
17-
- annotation: test-data # the binary files are only used for testing
16+
reasons:
17+
- reason: test-data # the binary files are only used for testing
1818
- checks:
1919
- dangerous-workflow
20-
annotations:
21-
- annotation: remediated # the workflow is dangerous but only run under maintainers verification and approval
22-
-
20+
reasons:
21+
- reason: remediated # the workflow is dangerous but only run under maintainers verification and approval
2322
```
2423
2524
You can annotate multiple checks at a time:
2625
2726
```yml
28-
exemptions:
27+
annotations:
2928
- checks:
3029
- binary-artifacts
3130
- pinned-dependencies
32-
annotations:
33-
- annotation: test-data # the binary files and files with unpinned dependencies are only used for testing
34-
31+
reasons:
32+
- reason: test-data # the binary files and files with unpinned dependencies are only used for testing
3533
```
3634
3735
And also provide multiple annotations for checks:
3836
3937
```yml
40-
exemptions:
38+
annotations:
4139
- checks:
4240
- binary-artifacts
43-
annotations:
44-
- annotation: test-data # test.exe is only used for testing
45-
- annotation: remediated # dependency.exe is needed and it's used but the binary signature is verified
46-
41+
reasons:
42+
- reason: test-data # test.exe is only used for testing
43+
- reason: remediated # dependency.exe is needed and it's used but the binary signature is verified
4744
```
4845
4946
The available checks are the Scorecard checks in lower case e.g. Binary-Artifacts is `binary-artifacts`.

e2e/config_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2024 OpenSSF Scorecard Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package e2e
16+
17+
import (
18+
"context"
19+
20+
. "github.com/onsi/ginkgo/v2"
21+
. "github.com/onsi/gomega"
22+
23+
"github.com/ossf/scorecard/v5/checks"
24+
"github.com/ossf/scorecard/v5/clients/githubrepo"
25+
"github.com/ossf/scorecard/v5/pkg/scorecard"
26+
)
27+
28+
var _ = Describe("E2E TEST: config parsing", func() {
29+
Context("E2E TEST:Valid config parsing", func() {
30+
It("Should return an annotation from the config", func() {
31+
repo, err := githubrepo.MakeGithubRepo("ossf-tests/scorecard-config-e2e")
32+
Expect(err).Should(BeNil())
33+
results, err := scorecard.Run(context.Background(), repo,
34+
scorecard.WithChecks([]string{checks.CheckCodeReview}),
35+
)
36+
Expect(err).Should(BeNil())
37+
Expect(len(results.Config.Annotations)).Should(BeNumerically(">=", 1))
38+
})
39+
})
40+
})

0 commit comments

Comments
 (0)