From: Erik Winkels Date: Thu, 20 Jun 2024 14:33:19 +0000 (+0200) Subject: Add ARM64 tests to repo test script. X-Git-Tag: rec-5.2.0-alpha1~176^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=34d30f51da32fd2816a476458846e3292a505d2f;p=thirdparty%2Fpdns.git Add ARM64 tests to repo test script. --- diff --git a/build-scripts/docker/repo-test/README.md b/build-scripts/docker/repo-test/README.md index 36038b437b..94af3ad403 100644 --- a/build-scripts/docker/repo-test/README.md +++ b/build-scripts/docker/repo-test/README.md @@ -10,6 +10,11 @@ To see the supported releases do `./generate-repo-files.py --help`. This tool is mainly used internally to test releases but might be useful for others. +## Known Issues + +- `--test-aarch64` really only makes sense if the test script is running on + another platform (and so far we've assumed `x86_64` to be the default) + ## Dependencies - Python 3 diff --git a/build-scripts/docker/repo-test/generate-repo-files.py b/build-scripts/docker/repo-test/generate-repo-files.py index f360e82c50..7c4f47ac54 100755 --- a/build-scripts/docker/repo-test/generate-repo-files.py +++ b/build-scripts/docker/repo-test/generate-repo-files.py @@ -58,6 +58,8 @@ def init_argparser(): help='always show output from running a container') parser.add_argument('--test', action='store_true', help='test the release') + parser.add_argument('--test-aarch64', action='store_true', + help='test the release for ARM64') parser.add_argument('--verbose', action='store_true', help='verbose output') parser.add_argument('--version', action='store_true', @@ -111,7 +113,7 @@ def write_list_file (os, os_version, release): tpl = g_env.get_template('pdns-list.jinja2') if os in ['debian', 'ubuntu']: - arch = ' [arch=amd64] ' + arch = ' [arch=amd64,arm64] ' else: arch = ' ' @@ -170,7 +172,7 @@ def write_release_files (release): # Test Release Functions -def build (dockerfile): +def build (dockerfile, arch='x86_64'): # Maybe create `determine_tag` function. if len(str(dockerfile)) <= len(g_dockerfile): print('Unable to determine tag for {}'.format(dockerfile)) @@ -179,9 +181,16 @@ def build (dockerfile): print('Building Docker image using {}...'.format(dockerfile)) if g_verbose: print(' - tag = {}'.format(tag)) - cp = subprocess.run(['docker', 'build', '--no-cache', '--pull', '--file', - dockerfile, '--tag', tag, '.'], - capture_output=not(g_verbose)) + if arch == 'x86_64': + cp = subprocess.run(['docker', 'build', '--no-cache', '--pull', + '--file', dockerfile, '--tag', tag, '.'], + capture_output=not(g_verbose)) + # not very subtle + elif arch == 'aarch64': + cp = subprocess.run(['docker', 'build', '--platform', 'linux/arm64/v8', + '--no-cache', '--pull', '--file', dockerfile, + '--tag', tag, '.'], + capture_output=not(g_verbose)) # FIXME write failed output to log if cp.returncode != 0: print('Error building {}: {}'.format(tag, repr(cp.returncode))) @@ -189,14 +198,20 @@ def build (dockerfile): return ( tag, cp.returncode ) -def run (tag): +def run (tag, arch='x86_64'): if g_run_output: capture_run_output = False else: capture_run_output = not(g_verbose) print('Running Docker container tagged {}...'.format(tag)) - cp = subprocess.run(['docker', 'run', tag], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + if arch == 'x86_64': + cp = subprocess.run(['docker', 'run', tag], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + # not very subtle + elif arch == 'aarch64': + cp = subprocess.run(['docker', 'run', '--platform', 'linux/arm64/v8', + tag], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) version = re.search(r'(PowerDNS Authoritative Server|PowerDNS Recursor|' + r'dnsdist) (\d+\.\d+\.\d+(-\w+)?)', cp.stdout.decode()) @@ -224,17 +239,22 @@ def collect_dockerfiles (release): return files -def test_release (release): +def test_release (release, arch='x86_64'): # sorted because we want determinism dockerfiles = sorted(collect_dockerfiles(release)) failed_builds = [] failed_runs = [] returned_versions = [] - print('=== testing {} ==='.format(release)) + print('=== testing {} ({}) ==='.format(release, arch)) for df in dockerfiles: + if arch == 'aarch64' and str(df).endswith('centos-7'): + continue + if arch == 'aarch64' and not release in ['rec-51', 'rec-master', + 'dnsdist-19', 'dnsdist-master']: + continue if g_verbose: print('--- {} ---'.format(df)) - (tag, returncode) = build(df) + (tag, returncode) = build(df, arch) if returncode != 0: print('Skipping running {} due to build error: {}' .format(df, returncode)) @@ -243,7 +263,7 @@ def test_release (release): print('Skipping running {} due to undetermined tag.'.format(df)) failed_builds.append((str(df), returncode)) else: - (returncode, return_version) = run(tag) + (returncode, return_version) = run(tag, arch) # for some reason 99 is returned on `cmd --version` :shrug: # (not sure if this is true since using `stdout=PIPE...`) if returncode != 0 and returncode != 99: @@ -286,3 +306,6 @@ write_release_files(args.release) if args.test: test_release(args.release) + +if args.test_aarch64: + test_release(args.release, 'aarch64')