Skip to content

Commit 2e7e141

Browse files
committed
workflows: Add a test to ensure that the LLVM version is correct
This should prevent mistakes like Issue#55137. Reviewed By: thieta Differential Revision: https://reviews.llvm.org/D124539
1 parent 0e27d08 commit 2e7e141

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

.github/workflows/version-check.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/python3
2+
3+
from git import Repo
4+
import re
5+
import sys
6+
7+
version = sys.argv[1]
8+
9+
repo = Repo()
10+
11+
tag = repo.git.describe(tags = True, abbrev=0)
12+
m = re.match('llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)', tag)
13+
if not m:
14+
print("error: Tag is not valid: ", tag)
15+
sys.exit(1)
16+
17+
expected_major = m.group(1)
18+
expected_minor = m.group(2)
19+
expected_patch = int(m.group(3)) + 1
20+
expected_version = f"{expected_major}.{expected_minor}.{expected_patch}"
21+
22+
m = re.match("[0-9]+\.[0-9]+\.[0-9]+", version)
23+
if not m:
24+
print("error: Version is not valid: ", version)
25+
sys.exit(1)
26+
27+
if version != expected_version:
28+
print("error: Expected version", expected_version, "but found version", version)
29+
sys.exit(1)
30+
31+
print("Versions match:", version, expected_version)
32+
sys.exit(0)

.github/workflows/version-check.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: LLVM Project Version Check
2+
3+
on:
4+
push:
5+
branches:
6+
- 'release/**'
7+
pull_request:
8+
9+
10+
jobs:
11+
version_check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Fetch LLVM sources
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Install dependencies
20+
run: |
21+
pip install -r ./llvm/utils/git/requirements.txt
22+
23+
- name: Version Check
24+
run: |
25+
version=`grep -o 'LLVM_VERSION_\(MAJOR\|MINOR\|PATCH\) [0-9]\+' llvm/CMakeLists.txt | cut -d ' ' -f 2 | tr "\n" "." | sed 's/.$//g'`
26+
.github/workflows/version-check.py $version

0 commit comments

Comments
 (0)