summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-pr-title-and-commit-messages.py54
-rwxr-xr-xscripts/check-qemu-install8
-rwxr-xr-xscripts/image-build/build-vyos-image8
3 files changed, 69 insertions, 1 deletions
diff --git a/scripts/check-pr-title-and-commit-messages.py b/scripts/check-pr-title-and-commit-messages.py
new file mode 100755
index 00000000..f7376e98
--- /dev/null
+++ b/scripts/check-pr-title-and-commit-messages.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+import time
+
+import requests
+
+# Use the same regex for PR title and commit messages for now
+title_regex = r'^(([a-zA-Z\-_.]+:\s)?)T\d+:\s+[^\s]+.*'
+commit_regex = title_regex
+
+
+def check_pr_title(title):
+ if not re.match(title_regex, title):
+ print(f"PR title '{title}' does not match the required format!")
+ print("Valid title example: T99999: make IPsec secure")
+ sys.exit(1)
+
+
+def check_commit_message(title):
+ if not re.match(commit_regex, title):
+ print(f"Commit title '{title}' does not match the required format!")
+ print("Valid title example: T99999: make IPsec secure")
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ if len(sys.argv) < 2:
+ print("Please specify pull request URL!")
+ sys.exit(1)
+
+ # There seems to be a race condition that causes this scripts to receive
+ # an incomplete PR object that is missing certain fields,
+ # which causes temporary CI failures that require re-running the script
+ #
+ # It's probably better to add a small delay to prevent that
+ time.sleep(5)
+
+ # Get the pull request object
+ pr = requests.get(sys.argv[1]).json()
+ if "title" not in pr:
+ print("The PR object does not have a title field!")
+ print("Did not receive a valid pull request object, please check the URL!")
+ sys.exit(1)
+
+ check_pr_title(pr["title"])
+
+ # Get the list of commits
+ commits = requests.get(pr["commits_url"]).json()
+ for c in commits:
+ # Retrieve every individual commit and check its title
+ co = requests.get(c["url"]).json()
+ check_commit_message(co["commit"]["message"])
diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install
index 41c566e6..b8f3806b 100755
--- a/scripts/check-qemu-install
+++ b/scripts/check-qemu-install
@@ -336,7 +336,9 @@ try:
c.expect('\nWhat would you like to name this image?.*')
c.sendline('')
c.expect(f'\nPlease enter a password for the "{default_user}" user.*')
- c.sendline('')
+ c.sendline('vyos')
+ c.expect(f'\nPlease confirm password for the "{default_user}" user.*')
+ c.sendline('vyos')
c.expect('\nWhat console should be used by default?.*')
c.sendline('S')
@@ -347,6 +349,8 @@ try:
c.sendline('y')
c.expect('\nInstallation will delete all data on both drives. Continue?.*')
c.sendline('y')
+ c.expect('\nWhich file would you like as boot config?.*')
+ c.sendline('')
else:
c.expect('\nWhich one should be used for installation?.*')
c.sendline('')
@@ -354,6 +358,8 @@ try:
c.sendline('y')
c.expect('\nWould you like to use all the free space on the drive?.*')
c.sendline('y')
+ c.expect('\nWhich file would you like as boot config?.*')
+ c.sendline('')
log.info('system installed, shutting down')
diff --git a/scripts/image-build/build-vyos-image b/scripts/image-build/build-vyos-image
index 61431c16..893e0016 100755
--- a/scripts/image-build/build-vyos-image
+++ b/scripts/image-build/build-vyos-image
@@ -30,6 +30,7 @@ import platform
import argparse
import datetime
import functools
+import string
# Import third-party modules
try:
@@ -275,6 +276,13 @@ if __name__ == "__main__":
print("Use --build-type=release option if you want to set version number")
sys.exit(1)
+ # Validate characters in version name
+ if 'version' in args and args['version'] != None:
+ allowed = string.ascii_letters + string.digits + '.' + '-' + '+'
+ if not set(args['version']) <= set(allowed):
+ print(f'Version contained illegal character(s), allowed: {allowed}')
+ sys.exit(1)
+
## Inject some useful hardcoded options
args['build_dir'] = defaults.BUILD_DIR
args['pbuilder_config'] = os.path.join(defaults.BUILD_DIR, defaults.PBUILDER_CONFIG)