Skip to content

Commit cffe2c7

Browse files
committed
Relax version bump requirement for non-library changes
Signed-off-by: Jo5ta <Jo5ta@mail.de>
1 parent 259d475 commit cffe2c7

5 files changed

Lines changed: 203 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,91 @@ permissions:
1919
packages: write
2020

2121
jobs:
22+
# ============================================
23+
# Detect what changed (fast, no container)
24+
# ============================================
25+
changes:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
code: ${{ steps.filter.outputs.code }}
29+
tests: ${{ steps.filter.outputs.tests }}
30+
docs: ${{ steps.filter.outputs.docs }}
31+
ci: ${{ steps.filter.outputs.ci }}
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Detect changed paths
39+
id: filter
40+
run: |
41+
set -euo pipefail
42+
43+
if [ "${{ github.event_name }}" = "pull_request" ]; then
44+
BASE="${{ github.event.pull_request.base.sha }}"
45+
HEAD="${{ github.event.pull_request.head.sha }}"
46+
else
47+
# Push event: compare with parent commit
48+
BASE="${{ github.event.before }}"
49+
HEAD="${{ github.sha }}"
50+
51+
# Handle first push or force push (before is all zeros)
52+
if [ "$BASE" = "0000000000000000000000000000000000000000" ]; then
53+
# Compare against parent of HEAD
54+
BASE="${HEAD}^"
55+
fi
56+
fi
57+
58+
CHANGED=$(git diff --name-only "$BASE" "$HEAD" 2>/dev/null || echo "")
59+
60+
# Default all to false
61+
CODE=false
62+
TESTS=false
63+
DOCS=false
64+
CI_FILES=false
65+
66+
# Check each pattern (only if CHANGED is non-empty)
67+
if [ -n "$CHANGED" ]; then
68+
if echo "$CHANGED" | grep -qE '^(tracing_library/|decoder_tool/|command_line_tool/|snapshot_library/|kernel_tracing_library/|cmake/|CMakeLists\.txt|CMakePresets\.json)'; then
69+
CODE=true
70+
fi
71+
72+
if echo "$CHANGED" | grep -qE '^(tests/|examples/)'; then
73+
TESTS=true
74+
fi
75+
76+
if echo "$CHANGED" | grep -qE '^docs/|\.md$'; then
77+
DOCS=true
78+
fi
79+
80+
if echo "$CHANGED" | grep -qE '^(\.github/|scripts/)'; then
81+
CI_FILES=true
82+
fi
83+
fi
84+
85+
echo "code=$CODE" >> $GITHUB_OUTPUT
86+
echo "tests=$TESTS" >> $GITHUB_OUTPUT
87+
echo "docs=$DOCS" >> $GITHUB_OUTPUT
88+
echo "ci=$CI_FILES" >> $GITHUB_OUTPUT
89+
90+
echo "Changed files:"
91+
echo "$CHANGED"
92+
echo ""
93+
echo "Detected: code=$CODE tests=$TESTS docs=$DOCS ci=$CI_FILES"
94+
2295
# ============================================
2396
# Quick checks (format, version) - fail fast
97+
# Skip only for docs-only changes
2498
# ============================================
2599
checks:
26100
runs-on: ubuntu-latest
101+
needs: changes
102+
if: |
103+
github.event_name == 'push' ||
104+
needs.changes.outputs.code == 'true' ||
105+
needs.changes.outputs.tests == 'true' ||
106+
needs.changes.outputs.ci == 'true'
27107
steps:
28108
- name: Checkout code
29109
uses: actions/checkout@v4
@@ -46,10 +126,17 @@ jobs:
46126

47127
# ============================================
48128
# Build and Test
129+
# Skip only for docs-only changes
49130
# ============================================
50131
build-and-test:
51132
runs-on: ubuntu-latest
52-
needs: checks
133+
needs: [changes, checks]
134+
if: |
135+
!failure() && !cancelled() &&
136+
(github.event_name == 'push' ||
137+
needs.changes.outputs.code == 'true' ||
138+
needs.changes.outputs.tests == 'true' ||
139+
needs.changes.outputs.ci == 'true')
53140
steps:
54141
- name: Checkout code
55142
uses: actions/checkout@v4
@@ -84,11 +171,16 @@ jobs:
84171
run: ./scripts/container.sh ./scripts/ci-cd/step_memcheck.sh
85172

86173
# ============================================
87-
# Packaging
174+
# Packaging (only for code/ci changes, or push to main)
88175
# ============================================
89176
package:
90177
runs-on: ubuntu-latest
91-
needs: build-and-test
178+
needs: [changes, build-and-test]
179+
if: |
180+
!failure() && !cancelled() &&
181+
(github.event_name == 'push' ||
182+
needs.changes.outputs.code == 'true' ||
183+
needs.changes.outputs.ci == 'true')
92184
steps:
93185
- name: Checkout code
94186
uses: actions/checkout@v4

docs/presentations/clltk-architecture.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
marp: true
33
theme: default
44
paginate: true
5+
style: |
6+
section {
7+
transform: scale(0.9);
8+
transform-origin: top left;
9+
}
510
---
611

712
<!-- _class: lead -->

docs/presentations/clltk-internals.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
marp: true
33
theme: default
44
paginate: true
5+
style: |
6+
section {
7+
transform: scale(0.9);
8+
transform-origin: top left;
9+
}
510
---
611

712
# CLLTK Internals

docs/presentations/clltk-user-guide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
marp: true
33
theme: default
44
paginate: true
5+
style: |
6+
section {
7+
transform: scale(0.9);
8+
transform-origin: top left;
9+
}
510
---
611

712
# CLLTK - Common Low Level Tracing Kit

scripts/ci-cd/check_version_step.sh

Lines changed: 93 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,114 @@
44

55
ROOT_PATH=$(git rev-parse --show-toplevel)
66

7-
THIS_MAJOR=$(git show HEAD:VERSION.md | head -n 1 | cut -d . -f 1 )
8-
THIS_MINOR=$(git show HEAD:VERSION.md | head -n 1 | cut -d . -f 2 )
9-
THIS_PATCH=$(git show HEAD:VERSION.md | head -n 1 | cut -d . -f 3 )
7+
# ============================================
8+
# Step 1: Check if version-sensitive files changed
9+
# ============================================
1010

11-
THIS_VERSION=$(((THIS_MAJOR * 0x10000) + (THIS_MINOR * 0x100) + (THIS_PATCH * 0x1)))
11+
# Patterns that require a version bump (library source, build system)
12+
VERSION_REQUIRED_PATTERNS=(
13+
"tracing_library/"
14+
"decoder_tool/"
15+
"command_line_tool/"
16+
"snapshot_library/"
17+
"kernel_tracing_library/"
18+
"cmake/"
19+
)
20+
21+
# Root-level files that require version bump
22+
VERSION_REQUIRED_FILES=(
23+
"CMakeLists.txt"
24+
"CMakePresets.json"
25+
)
26+
27+
# Determine base branch for comparison
28+
if git rev-parse --verify origin/main >/dev/null 2>&1; then
29+
BASE_REF="origin/main"
30+
elif git rev-parse --verify main >/dev/null 2>&1; then
31+
BASE_REF="main"
32+
else
33+
echo "Could not find main branch - assuming version bump is required"
34+
BASE_REF=""
35+
fi
1236

37+
if [ -n "$BASE_REF" ]; then
38+
# Get changed files between this branch and main
39+
CHANGED_FILES=$(git diff --name-only "$BASE_REF"...HEAD 2>/dev/null || git diff --name-only "$BASE_REF" HEAD)
40+
41+
# Find which files trigger version requirement
42+
TRIGGERING_FILES=()
43+
for file in $CHANGED_FILES; do
44+
matched=false
45+
# Check directory patterns
46+
for pattern in "${VERSION_REQUIRED_PATTERNS[@]}"; do
47+
if [[ "$file" == "$pattern"* ]]; then
48+
TRIGGERING_FILES+=("$file")
49+
matched=true
50+
break
51+
fi
52+
done
53+
# Check exact file matches (root-level files) if not already matched
54+
if [ "$matched" = false ]; then
55+
for exact in "${VERSION_REQUIRED_FILES[@]}"; do
56+
if [[ "$file" == "$exact" ]]; then
57+
TRIGGERING_FILES+=("$file")
58+
break
59+
fi
60+
done
61+
fi
62+
done
63+
64+
if [ ${#TRIGGERING_FILES[@]} -eq 0 ]; then
65+
echo "Only non-library files changed (tests, docs, scripts, etc.)"
66+
echo "No version bump required for this PR."
67+
exit 0
68+
fi
69+
70+
echo "Library or build system files changed:"
71+
for file in "${TRIGGERING_FILES[@]}"; do
72+
echo " - $file"
73+
done
74+
echo ""
75+
echo "Checking version bump..."
76+
fi
1377

14-
MAIN_VERSION=$(git show origin/main:VERSION.md)
78+
# ============================================
79+
# Step 2: Version comparison
80+
# ============================================
81+
82+
THIS_MAJOR=$(git show HEAD:VERSION.md | head -n 1 | cut -d . -f 1)
83+
THIS_MINOR=$(git show HEAD:VERSION.md | head -n 1 | cut -d . -f 2)
84+
THIS_PATCH=$(git show HEAD:VERSION.md | head -n 1 | cut -d . -f 3)
85+
86+
THIS_VERSION=$(((THIS_MAJOR * 0x10000) + (THIS_MINOR * 0x100) + (THIS_PATCH * 0x1)))
87+
88+
MAIN_VERSION=$(git show origin/main:VERSION.md 2>/dev/null)
1589
if [ $? -ne 0 ]; then
1690
MAIN_VERSION=$(git show main:VERSION.md)
1791
fi
1892

1993
if [[ $MAIN_VERSION =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
20-
MAIN_VERSION="${BASH_REMATCH[1]}"
94+
MAIN_VERSION="${BASH_REMATCH[1]}"
2195
else
22-
echo "No version number in main"
23-
exit
96+
echo "No version number in main"
97+
exit 0
2498
fi
2599

26-
MAIN_MAJOR=$(echo $MAIN_VERSION | cut -d . -f 1 )
27-
MAIN_MINOR=$(echo $MAIN_VERSION | cut -d . -f 2 )
28-
MAIN_PATCH=$(echo $MAIN_VERSION | cut -d . -f 3 )
29-
100+
MAIN_MAJOR=$(echo $MAIN_VERSION | cut -d . -f 1)
101+
MAIN_MINOR=$(echo $MAIN_VERSION | cut -d . -f 2)
102+
MAIN_PATCH=$(echo $MAIN_VERSION | cut -d . -f 3)
30103

31-
MAIN_VERSION=$(((MAIN_MAJOR * 0x10000) + (MAIN_MINOR * 0x100) + (MAIN_PATCH * 0x1)))
104+
MAIN_VERSION_NUM=$(((MAIN_MAJOR * 0x10000) + (MAIN_MINOR * 0x100) + (MAIN_PATCH * 0x1)))
32105

33-
echo "THIS:$THIS_VERSION MAIN:$MAIN_VERSION"
106+
echo "PR version: $THIS_MAJOR.$THIS_MINOR.$THIS_PATCH"
107+
echo "Main version: $MAIN_MAJOR.$MAIN_MINOR.$MAIN_PATCH"
34108

35-
36-
if [ $THIS_VERSION -gt $MAIN_VERSION ]; then
37-
echo "Version stepped"
109+
if [ $THIS_VERSION -gt $MAIN_VERSION_NUM ]; then
110+
echo "Version bumped - good to go!"
38111
exit 0
39112
else
40-
echo "Version not stepped"
113+
echo ""
114+
echo "Please bump the version in VERSION.md before merging."
115+
echo "Current main is $MAIN_MAJOR.$MAIN_MINOR.$MAIN_PATCH - update to at least $MAIN_MAJOR.$MAIN_MINOR.$((MAIN_PATCH + 1))"
41116
exit 1
42117
fi
43-

0 commit comments

Comments
 (0)