2017-07-30 19:43:02 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import subprocess
|
Testsuite: Run UIs in Qemu and check running processes and more (#982)
* Testsuite: Run UIs in Qemu and check running processes (and other changes)
* When `pmbootstrap qemu` gets killed, it now takes down the Qemu process with it
* `test/check_checksums.py` got a new optional `--build` parameter, which makes
it build all changed packages instead of just checking the checksums
* We run this before running the testsuite now, so all changed packages get
built before running tests (otherwise tests would hang without any output
while a changed package is building)
* New testcase, that zaps all chroots, installs a specific UI (xfce4 and
plasma-mobile currently, easy to extend), runs it via Qemu and checks the
running processes via SSH.
* Version checking testcase: rewritten to include Alpine's testsuite file in
our source tree, so we don't need to clone their git repo anymore. Now it
is enabled for Travis.
* All this gives us a nice 10% code coverage boost
* Increased the `hello-world` pkgrel to verify that the Travis job is working.
* Various fixes
* Build device-packages for the device arch and don't raise an
exception, but print a note if --ignore-depends is not specified
and therefore the kernel gets installed, too.
* Don't use --force when building in Travis (because abuild doesn't
check the checksums then. Bug report on the way.)
* Don't run the building process in the background, but wait for its
completion
* Exit with 1 when showing usage in check_checksums.py
2018-02-02 00:16:29 +00:00
|
|
|
import sys
|
2017-07-30 19:43:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_changed_files():
|
|
|
|
try:
|
2018-06-05 21:45:17 +00:00
|
|
|
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'])
|
2017-07-30 19:43:02 +00:00
|
|
|
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]
|
2017-08-04 14:52:24 +00:00
|
|
|
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
|
2017-07-30 19:43:02 +00:00
|
|
|
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)
|
2018-07-09 20:19:59 +00:00
|
|
|
except subprocess.CalledProcessError:
|
2017-07-30 19:43:02 +00:00
|
|
|
print("Something gone wrong in pmbootstrap. Log:")
|
|
|
|
logfile = os.path.expanduser("~/.local/var/pmbootstrap/log.txt")
|
|
|
|
with open(logfile) as log:
|
|
|
|
print(log.read())
|
2017-07-30 21:54:47 +00:00
|
|
|
print("Test script failed on checksumming package '{}'".format(package))
|
|
|
|
exit(1)
|
2017-07-30 19:43:02 +00:00
|
|
|
|
|
|
|
result = check_output_always(['git', 'status', '--porcelain', '--untracked-files=no']).decode()
|
|
|
|
|
|
|
|
if result == "":
|
|
|
|
print("** The checksums are correct")
|
|
|
|
else:
|
2017-07-31 09:55:51 +00:00
|
|
|
print(result)
|
|
|
|
result = check_output_always(['git', 'diff']).decode()
|
2017-07-30 19:43:02 +00:00
|
|
|
print(result)
|
|
|
|
print("** The checksums are not correct")
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
Testsuite: Run UIs in Qemu and check running processes and more (#982)
* Testsuite: Run UIs in Qemu and check running processes (and other changes)
* When `pmbootstrap qemu` gets killed, it now takes down the Qemu process with it
* `test/check_checksums.py` got a new optional `--build` parameter, which makes
it build all changed packages instead of just checking the checksums
* We run this before running the testsuite now, so all changed packages get
built before running tests (otherwise tests would hang without any output
while a changed package is building)
* New testcase, that zaps all chroots, installs a specific UI (xfce4 and
plasma-mobile currently, easy to extend), runs it via Qemu and checks the
running processes via SSH.
* Version checking testcase: rewritten to include Alpine's testsuite file in
our source tree, so we don't need to clone their git repo anymore. Now it
is enabled for Travis.
* All this gives us a nice 10% code coverage boost
* Increased the `hello-world` pkgrel to verify that the Travis job is working.
* Various fixes
* Build device-packages for the device arch and don't raise an
exception, but print a note if --ignore-depends is not specified
and therefore the kernel gets installed, too.
* Don't use --force when building in Travis (because abuild doesn't
check the checksums then. Bug report on the way.)
* Don't run the building process in the background, but wait for its
completion
* Exit with 1 when showing usage in check_checksums.py
2018-02-02 00:16:29 +00:00
|
|
|
def check_build(packages):
|
2018-02-09 18:43:58 +00:00
|
|
|
# Initialize build environment with less logging
|
|
|
|
commands = [["build_init"],
|
|
|
|
["--details-to-stdout", "build", "--strict"] + list(packages)]
|
|
|
|
for command in commands:
|
2018-02-13 23:12:46 +00:00
|
|
|
process = subprocess.Popen(["./pmbootstrap.py"] + command)
|
|
|
|
process.communicate()
|
|
|
|
if process.returncode != 0:
|
2018-02-09 18:43:58 +00:00
|
|
|
print("** Building failed")
|
|
|
|
exit(1)
|
Testsuite: Run UIs in Qemu and check running processes and more (#982)
* Testsuite: Run UIs in Qemu and check running processes (and other changes)
* When `pmbootstrap qemu` gets killed, it now takes down the Qemu process with it
* `test/check_checksums.py` got a new optional `--build` parameter, which makes
it build all changed packages instead of just checking the checksums
* We run this before running the testsuite now, so all changed packages get
built before running tests (otherwise tests would hang without any output
while a changed package is building)
* New testcase, that zaps all chroots, installs a specific UI (xfce4 and
plasma-mobile currently, easy to extend), runs it via Qemu and checks the
running processes via SSH.
* Version checking testcase: rewritten to include Alpine's testsuite file in
our source tree, so we don't need to clone their git repo anymore. Now it
is enabled for Travis.
* All this gives us a nice 10% code coverage boost
* Increased the `hello-world` pkgrel to verify that the Travis job is working.
* Various fixes
* Build device-packages for the device arch and don't raise an
exception, but print a note if --ignore-depends is not specified
and therefore the kernel gets installed, too.
* Don't use --force when building in Travis (because abuild doesn't
check the checksums then. Bug report on the way.)
* Don't run the building process in the background, but wait for its
completion
* Exit with 1 when showing usage in check_checksums.py
2018-02-02 00:16:29 +00:00
|
|
|
|
|
|
|
|
2017-07-30 19:43:02 +00:00
|
|
|
if __name__ == "__main__":
|
Testsuite: Run UIs in Qemu and check running processes and more (#982)
* Testsuite: Run UIs in Qemu and check running processes (and other changes)
* When `pmbootstrap qemu` gets killed, it now takes down the Qemu process with it
* `test/check_checksums.py` got a new optional `--build` parameter, which makes
it build all changed packages instead of just checking the checksums
* We run this before running the testsuite now, so all changed packages get
built before running tests (otherwise tests would hang without any output
while a changed package is building)
* New testcase, that zaps all chroots, installs a specific UI (xfce4 and
plasma-mobile currently, easy to extend), runs it via Qemu and checks the
running processes via SSH.
* Version checking testcase: rewritten to include Alpine's testsuite file in
our source tree, so we don't need to clone their git repo anymore. Now it
is enabled for Travis.
* All this gives us a nice 10% code coverage boost
* Increased the `hello-world` pkgrel to verify that the Travis job is working.
* Various fixes
* Build device-packages for the device arch and don't raise an
exception, but print a note if --ignore-depends is not specified
and therefore the kernel gets installed, too.
* Don't use --force when building in Travis (because abuild doesn't
check the checksums then. Bug report on the way.)
* Don't run the building process in the background, but wait for its
completion
* Exit with 1 when showing usage in check_checksums.py
2018-02-02 00:16:29 +00:00
|
|
|
# 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)
|
|
|
|
|
2017-07-30 19:43:02 +00:00
|
|
|
packages = get_changed_packages()
|
|
|
|
|
|
|
|
if len(packages) == 0:
|
|
|
|
print("No aports packages changed in this commit")
|
|
|
|
exit(0)
|
|
|
|
|
Testsuite: Run UIs in Qemu and check running processes and more (#982)
* Testsuite: Run UIs in Qemu and check running processes (and other changes)
* When `pmbootstrap qemu` gets killed, it now takes down the Qemu process with it
* `test/check_checksums.py` got a new optional `--build` parameter, which makes
it build all changed packages instead of just checking the checksums
* We run this before running the testsuite now, so all changed packages get
built before running tests (otherwise tests would hang without any output
while a changed package is building)
* New testcase, that zaps all chroots, installs a specific UI (xfce4 and
plasma-mobile currently, easy to extend), runs it via Qemu and checks the
running processes via SSH.
* Version checking testcase: rewritten to include Alpine's testsuite file in
our source tree, so we don't need to clone their git repo anymore. Now it
is enabled for Travis.
* All this gives us a nice 10% code coverage boost
* Increased the `hello-world` pkgrel to verify that the Travis job is working.
* Various fixes
* Build device-packages for the device arch and don't raise an
exception, but print a note if --ignore-depends is not specified
and therefore the kernel gets installed, too.
* Don't use --force when building in Travis (because abuild doesn't
check the checksums then. Bug report on the way.)
* Don't run the building process in the background, but wait for its
completion
* Exit with 1 when showing usage in check_checksums.py
2018-02-02 00:16:29 +00:00
|
|
|
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)
|