Skip to content

Commit 00a8c81

Browse files
halnasriThomasClausnitzer
authored andcommitted
fix pr count gate and coverage gate and add check_artifact_exists evidence to statements JLS-54 and JLS-55
1 parent 1695462 commit 00a8c81

6 files changed

Lines changed: 104 additions & 36 deletions

File tree

.github/workflows/coverage_gate.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55
inputs:
66
artifact_id:
7-
description: "Unused, kept for consistency with parent"
7+
description: "Artifact name for the coverage-gate result"
88
required: true
99
type: string
1010

@@ -52,3 +52,18 @@ jobs:
5252
fi
5353
5454
echo "Coverage is above threshold."
55+
56+
- name: Create coverage-gate result
57+
if: always()
58+
run: |
59+
mkdir -p coverage_gate
60+
echo "status=${{ job.status }}" > coverage_gate/result.txt
61+
echo "sha=${{ github.sha }}" >> coverage_gate/result.txt
62+
echo "run_id=${{ github.run_id }}" >> coverage_gate/result.txt
63+
64+
- name: Upload coverage-gate artifact
65+
if: always()
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: ${{ inputs.artifact_id }}
69+
path: coverage_gate/result.txt

.github/workflows/parent-workflow.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ jobs:
6767
coverage_gate:
6868
name: Run Coverage Gate Workflow
6969
needs: [ubuntu]
70+
if: ${{ github.event_name == 'pull_request' && github.base_ref == 'main'
71+
|| github.event_name == 'schedule' }}
7072
uses: ./.github/workflows/coverage_gate.yml
7173
with:
7274
artifact_id: "coverage_gate-${{ github.sha }}"
7375

7476
pr_count_gate:
7577
name: Run PR Count Gate Workflow
7678
uses: ./.github/workflows/pr_count_gate.yml
79+
with:
80+
artifact_id: "pr_count_gate-${{ github.sha }}"
7781

7882
dependency_review:
7983
name: Run dependency_review Workflow

.github/workflows/pr_count_gate.yml

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,59 @@ name: PR Count Gate
22

33
on:
44
workflow_call:
5+
inputs:
6+
artifact_id:
7+
required: true
8+
type: string
59

610
jobs:
711
pr_count_gate:
812
runs-on: ubuntu-latest
913

1014
steps:
11-
- name: Count open pull requests
12-
id: pr-count
13-
uses: actions/github-script@v7
14-
with:
15-
github-token: ${{ secrets.GITHUB_TOKEN }}
16-
script: |
17-
const { owner, repo } = context.repo;
18-
const per_page = 100;
19-
let page = 1;
20-
let total = 0;
21-
22-
while (true) {
23-
const { data } = await github.rest.pulls.list({
24-
owner,
25-
repo,
26-
state: 'open',
27-
per_page,
28-
page,
29-
});
30-
if (data.length === 0) break;
31-
total += data.length;
32-
if (data.length < per_page) break;
33-
page++;
34-
}
35-
36-
core.info(`Open pull requests: ${total}`);
37-
core.setOutput('open_prs', total.toString());
15+
- name: Count open pull requests
16+
id: pr-count
17+
uses: actions/github-script@v7
18+
with:
19+
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
script: |
21+
const { owner, repo } = context.repo;
22+
const per_page = 100;
23+
let page = 1;
24+
let total = 0;
25+
26+
while (true) {
27+
const { data } = await github.rest.pulls.list({
28+
owner,
29+
repo,
30+
state: 'open',
31+
base: 'main',
32+
per_page,
33+
page,
34+
});
35+
if (data.length === 0) break;
36+
total += data.length;
37+
if (data.length < per_page) break;
38+
page++;
39+
}
40+
41+
core.info(`Open pull requests: ${total}`);
42+
core.setOutput('open_prs', total.toString());
43+
44+
- name: Write PR count result
45+
if: always()
46+
run: |
47+
mkdir -p pr_count_gate
48+
echo "status=${{ job.status }}" > pr_count_gate/result.txt
49+
echo "open_prs=${{ steps.pr-count.outputs.open_prs }}" >> pr_count_gate/result.txt
50+
echo "sha=${{ github.sha }}" >> pr_count_gate/result.txt
51+
echo "run_id=${{ github.run_id }}" >> pr_count_gate/result.txt
52+
53+
54+
- name: Upload PR count gate artifact
55+
if: always()
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: ${{ inputs.artifact_id }}
59+
path: pr_count_gate/result.txt
60+

TSF/trustable/statements/JLS-04.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ references:
88
evidence:
99
type: "check_artifact_exists"
1010
configuration:
11-
check_amalgamation: exclude
12-
codeql: exclude
13-
dependency_review: include
14-
labeler: exclude
15-
publish_documentation: exclude
16-
test_trudag_extensions: exclude
17-
ubuntu: exclude
11+
ubuntu: exclude
12+
coverage_gate: exclude
13+
codeql: exclude
14+
labeler: exclude
15+
test_trudag_extensions: exclude
16+
dependency_review: include
17+
check_amalgamation: exclude
18+
publish_documentation: exclude
19+
pr_count_gate: exclude
1820
score:
1921
Jonas-Kirchhoff: 1.0
2022
Erikhu1: 1.0

TSF/trustable/statements/JLS-54.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ references:
55
- type: verbose_file
66
path: "./.github/workflows/coverage_gate.yml"
77
description: "GitHub Actions workflow enforcing a minimum coverage threshold."
8+
evidence:
9+
type: "check_artifact_exists"
10+
configuration:
11+
ubuntu: exclude
12+
coverage_gate: include
13+
codeql: exclude
14+
labeler: exclude
15+
test_trudag_extensions: exclude
16+
dependency_review: exclude
17+
check_amalgamation: exclude
18+
publish_documentation: exclude
19+
pr_count_gate: exclude
820
---
921

10-
In the eclipse-score/inc_nlohmann_json repository, code coverage for unit and integration tests is measured in every CI run, and a minimum coverage threshold is defined for each protected branch. If coverage for a change would fall below this threshold, the CI workflow blocks the merge until coverage is restored or the change is rejected.
22+
In the eclipse-score/inc_nlohmann_json repository, code coverage is measured in CI and a minimum threshold is enforced for pull requests into main and pushes to main. If coverage falls below the threshold, the coverage_gate check fails and blocks merging into main until coverage is restored.

TSF/trustable/statements/JLS-55.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ references:
55
- type: verbose_file
66
path: "./.github/workflows/pr_count_gate.yml"
77
description: "GitHub Actions workflow enforcing a limit on open PRs."
8+
evidence:
9+
type: "check_artifact_exists"
10+
configuration:
11+
ubuntu: exclude
12+
coverage_gate: exclude
13+
codeql: exclude
14+
labeler: exclude
15+
test_trudag_extensions: exclude
16+
dependency_review: exclude
17+
check_amalgamation: exclude
18+
publish_documentation: exclude
19+
pr_count_gate: include
820
---
921

1022
In eclipse-score/inc_nlohmann_json, a GitHub Actions workflow checks the number of open pull requests in the main branch. If the number exceeds a defined threshold, the workflow fails and blocks further merges until the number of open pull requests is reduced below that threshold.

0 commit comments

Comments
 (0)