Remove tests that were moved to pmaports.git (!1787)

Clean up some leftovers from the pmaports.git move.
This commit is contained in:
Oliver Smith 2019-05-19 21:58:46 +02:00 committed by Martijn Braam
parent 0431a51932
commit 4daf991640
2 changed files with 0 additions and 224 deletions

View File

@ -1,99 +0,0 @@
#!/usr/bin/env python3
import os
import subprocess
import sys
def get_changed_files():
try:
branch = os.environ['CI_COMMIT_REF_NAME']
raw = subprocess.check_output(['git', 'diff', '--name-only',
'master...{}'.format(branch)])
except (KeyError, subprocess.CalledProcessError):
raw = subprocess.check_output(['git', 'diff', '--name-only',
'HEAD~1'])
return raw.decode().splitlines()
def get_changed_packages():
files = get_changed_files()
packages = set()
for file in files:
if not file.startswith("aports/"):
continue
name = file.split("/")[2]
package_path = "/".join(file.split("/")[0:3])
apkbuild_path = os.path.join(package_path, "APKBUILD")
if not os.path.exists(apkbuild_path):
print("No APKBUILD found at {}".format(package_path))
continue
packages.add(name)
return packages
def check_output_always(command):
try:
return subprocess.check_output(command)
except subprocess.CalledProcessError as e:
return e.output
def check_checksums(package):
command = ['./pmbootstrap.py', 'checksum', package]
try:
subprocess.check_output(command)
except subprocess.CalledProcessError:
print("Something gone wrong in pmbootstrap. Log:")
logfile = os.path.expanduser("~/.local/var/pmbootstrap/log.txt")
with open(logfile) as log:
print(log.read())
print("Test script failed on checksumming package '{}'".format(package))
exit(1)
result = check_output_always(['git', 'status', '--porcelain', '--untracked-files=no']).decode()
if result == "":
print("** The checksums are correct")
else:
print(result)
result = check_output_always(['git', 'diff']).decode()
print(result)
print("** The checksums are not correct")
exit(1)
def check_build(packages):
# Initialize build environment with less logging
commands = [["build_init"],
["--details-to-stdout", "build", "--strict"] + list(packages)]
for command in commands:
process = subprocess.Popen(["./pmbootstrap.py"] + command)
process.communicate()
if process.returncode != 0:
print("** Building failed")
exit(1)
if __name__ == "__main__":
# Allow to specify "--build" to build instead of only verifying checksums
build = False
if len(sys.argv) > 1:
if sys.argv[1] == "--build":
build = True
else:
print("usage: {} [--build]".format(sys.argv[0]))
exit(1)
packages = get_changed_packages()
if len(packages) == 0:
print("No aports packages changed in this commit")
exit(0)
if build:
print("Building in strict mode: " + ", ".join(packages))
check_build(packages)
else:
for package in packages:
print("Checking {} for correct checksums".format(package))
check_checksums(package)

View File

@ -1,125 +0,0 @@
#!/usr/bin/env python3
"""
Copyright 2019 Oliver Smith
This file is part of pmbootstrap.
pmbootstrap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
pmbootstrap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
import argparse
import glob
import os
import sys
import urllib.request
def get_devices():
""":returns: list of all devices in the aports folders"""
ret = []
pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
for path in glob.glob(pmb_src + "/aports/device/device-*/"):
device = os.path.dirname(path).split("device-", 1)[1]
ret.append(device)
return sorted(ret)
def get_wiki_devices_html(path):
""":param path: to a local file with the saved content of the devices wiki
page or None to download a fresh copy
:returns: HTML of the page, split into booting and not booting:
{"booting": "<!DOCTYPE HTML>\n<html..."
"not_booting": "Not booting</span></h2>\n<p>These..."}"""
content = ""
if path:
# Read file
with open(path, encoding="utf-8") as handle:
content = handle.read()
else:
# Download wiki page
url = "http://wiki.postmarketos.org/wiki/Devices"
content = urllib.request.urlopen(url).read().decode("utf-8")
# Split into booting and not booting
split = content.split("<span class=\"mw-headline\" id=\"Not_booting\">")
if len(split) != 2:
print("*** Failed to parse wiki page")
sys.exit(2)
return {"booting": split[0], "not_booting": split[1]}
def check_device(device, html, is_booting):
""":param is_booting: require the device to be in the booting section, not
just anywhere in the page (i.e. in the not booting
table).
:returns: True when the device is in the appropriate section."""
if device in html["booting"]:
return True
if device in html["not_booting"]:
if is_booting:
print(device + ": still in 'not booting' section (if this is a"
" merge request, your device should be in the booting"
" section already)")
return False
return True
print(device + ": not in the wiki yet.")
return False
def main():
# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("--booting", help="devices must be in the upper table,"
" being in the 'not booting' table below is not"
" enough (all devices in pmbootstrap master should be"
" in the upper table)", action="store_true")
parser.add_argument("--path", help="instead of downloading the devices"
" page from the wiki, use a local HTML file",
default=None)
args = parser.parse_args()
# Check all devices
html = get_wiki_devices_html(args.path)
error = False
for device in get_devices():
if not check_device(device, html, args.booting):
error = True
# Ask to adjust the wiki
if error:
print("*** Wiki check failed!")
print("Thank you for porting postmarketOS to a new device! \o/")
print("")
print("Now it's time to add some documentation:")
print("1) Create a device specific wiki page as described here:")
print(" <https://wiki.postmarketos.org/wiki/Help:Device_Page>")
print("2) Add your device to the overview matrix:")
print(" <https://wiki.postmarketos.org/wiki/Devices>")
print("3) Run these tests again with an empty commit in your PR:")
print(" $ git commit --allow-empty -m 'run tests again'")
print("")
print("Please take the time to do these steps. It will make your")
print("precious porting efforts visible for others, and allow them")
print("not only to use what you have created, but also to build upon")
print("it more easily. Many times one person did a port with basic")
print("functionallity, and then someone else jumped in and")
print("contributed major new features.")
return 1
else:
print("*** Wiki check successful!")
return 0
sys.exit(main())