[PATCH] D124539: workflows: Add a test to ensure that the LLVM version is correct
Tom Stellard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 27 10:33:20 PDT 2022
tstellar created this revision.
tstellar added reviewers: mgorny, thieta, Tomasz.
Herald added a project: All.
tstellar requested review of this revision.
Herald added a project: LLVM.
This should prevent mistakes like Issue#55137.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124539
Files:
.github/workflows/version-check.py
.github/workflows/version-check.yml
Index: .github/workflows/version-check.yml
===================================================================
--- /dev/null
+++ .github/workflows/version-check.yml
@@ -0,0 +1,26 @@
+name: LLVM Project Version Check
+
+on:
+ push:
+ branches:
+ - 'release/**'
+ pull_request:
+
+
+jobs:
+ version_check:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Fetch LLVM sources
+ uses: actions/checkout at v2
+ with:
+ fetch-depth: 0
+
+ - name: Install dependencies
+ run: |
+ pip install -r ./llvm/utils/git/requirements.txt
+
+ - name: Version Check
+ run: |
+ version=`grep -o 'LLVM_VERSION_\(MAJOR\|MINOR\|PATCH\) [0-9]\+' llvm/CMakeLists.txt | cut -d ' ' -f 2 | tr "\n" "." | sed 's/.$//g'`
+ .github/workflows/version-check.py $version
Index: .github/workflows/version-check.py
===================================================================
--- /dev/null
+++ .github/workflows/version-check.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python3
+
+from git import Repo
+import re
+import sys
+
+version = sys.argv[1]
+
+repo = Repo()
+
+tag = repo.git.describe(tags = True, abbrev=0)
+m = re.match('llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)', tag)
+if not m:
+ print("error: Tag is not valid: ", tag)
+ sys.exit(1)
+
+expected_major = m.group(1)
+expected_minor = m.group(2)
+expected_patch = int(m.group(3)) + 1
+expected_version = f"{expected_major}.{expected_minor}.{expected_patch}"
+
+m = re.match("[0-9]+\.[0-9]+\.[0-9]+", version)
+if not m:
+ print("error: Version is not valid: ", version)
+ sys.exit(1)
+
+if version != expected_version:
+ print("error: Expected version", expected_version, "but found version", version)
+ sys.exit(1)
+
+print("Versions match:", version, expected_version)
+sys.exit(0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124539.425566.patch
Type: text/x-patch
Size: 1809 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220427/da44dced/attachment.bin>
More information about the llvm-commits
mailing list