Skip to content

Commit e8aef5d

Browse files
committed
ci: add check for job dependencies
Because merge protection gates on Total Success we should have a job to ensure the yaml really has the right deps for it to work correctly. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
1 parent 661cc9f commit e8aef5d

4 files changed

Lines changed: 51 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ jobs:
153153
name: "Total Success"
154154
if: always()
155155
needs:
156+
- path-filter
156157
- validate
157158
- storage-test
158159
- storage-cross

.github/workflows/validate.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
LINT_VERSION: v2.12.2
1010

1111
jobs:
12-
codespell:
12+
basic:
1313
runs-on: ubuntu-24.04
1414
steps:
1515
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
@@ -18,6 +18,8 @@ jobs:
1818
run: pip install --break-system-packages codespell==v2.4.1
1919
- name: run codespell
2020
run: make codespell
21+
- name: check-ci-yaml
22+
run: make check-ci-yaml
2123

2224
lint:
2325
runs-on: ubuntu-24.04

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ export PATH := $(PATH):${GOBIN}
1111
EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-main} HEAD)
1212

1313

14-
validate: codespell git-validation lint
14+
validate: codespell git-validation lint check-ci-yaml
15+
16+
.PHONY: check-ci-yaml
17+
check-ci-yaml:
18+
hack/ci/ci_yaml_test.py
1519

1620
.PHONY: codespell
1721
codespell:

hack/ci/ci_yaml_test.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
Verify contents of .github/workflows/ci.yml meet specific expectations
5+
"""
6+
7+
import sys
8+
import os
9+
import unittest
10+
import yaml
11+
12+
# Assumes directory structure of this file relative to repo.
13+
SCRIPT_DIRPATH = os.path.dirname(os.path.realpath(__file__))
14+
REPO_ROOT = os.path.realpath(os.path.join(SCRIPT_DIRPATH, '../', '../'))
15+
16+
17+
class TestCaseBase(unittest.TestCase):
18+
19+
CI_YAML = None
20+
21+
def setUp(self):
22+
with open(os.path.join(REPO_ROOT, '.github/workflows/ci.yml')) as ci_yaml:
23+
self.CI_YAML = yaml.safe_load(ci_yaml.read())
24+
25+
26+
class TestDependsOn(TestCaseBase):
27+
28+
ALL_TASK_NAMES = None
29+
30+
def setUp(self):
31+
super().setUp()
32+
self.ALL_TASK_NAMES = list(self.CI_YAML['jobs'].keys())
33+
34+
35+
def test_success_deps(self):
36+
"""Specific success task depends on all others"""
37+
all_tasks = self.ALL_TASK_NAMES.remove('success')
38+
needs = self.CI_YAML['jobs']['success']['needs']
39+
self.assertCountEqual(needs, self.ALL_TASK_NAMES)
40+
41+
if __name__ == "__main__":
42+
unittest.main()

0 commit comments

Comments
 (0)