ci: let ubuntu version be configurable

This commit is contained in:
Erik Sundell
2021-10-17 03:31:37 +02:00
parent 8635af59de
commit 922bfad0f5
3 changed files with 22 additions and 12 deletions

View File

@@ -4,15 +4,16 @@ import subprocess
import os
def build_systemd_image(image_name, source_path):
def build_systemd_image(image_name, source_path, build_args=None):
"""
Build docker image with systemd at source_path.
Built image is tagged with image_name
"""
subprocess.check_call([
'docker', 'build', '-t', image_name, source_path
])
cmd = ['docker', 'build', '-t', image_name, source_path]
if build_args:
cmd.extend([f"--build-arg={ba}" for ba in build_args])
subprocess.check_call(cmd)
def run_systemd_image(image_name, container_name, bootstrap_pip_spec):
@@ -138,13 +139,21 @@ def main():
argparser = argparse.ArgumentParser()
subparsers = argparser.add_subparsers(dest='action')
subparsers.add_parser('build-image')
build_image_parser = subparsers.add_parser('build-image')
build_image_parser.add_argument(
"--build-arg",
action="append",
dest="build_args",
)
subparsers.add_parser('stop-container').add_argument(
'container_name'
)
subparsers.add_parser('start-container').add_argument(
'container_name'
)
run_parser = subparsers.add_parser('run')
run_parser.add_argument('container_name')
run_parser.add_argument('command')
@@ -181,7 +190,7 @@ def main():
elif args.action == 'stop-container':
stop_container(args.container_name)
elif args.action == 'build-image':
build_systemd_image(image_name, 'integration-tests')
build_systemd_image(image_name, 'integration-tests', args.build_args)
if __name__ == '__main__':

View File

@@ -60,22 +60,22 @@ jobs:
env:
matrix_include_pre_filter: |
- name: "Int. tests: Ubuntu 18.04, Py 3.6"
runs_on: ubuntu-18.04
ubuntu_version: 18.04
python_version: 3.6
extra_flags: ""
- name: "Int. tests: Ubuntu 20.04, Py 3.9"
runs_on: ubuntu-20.04
ubuntu_version: 20.04
python_version: 3.9
extra_flags: ""
- name: "Int. tests: Ubuntu 20.04, Py 3.9, --upgrade"
runs_on: ubuntu-20.04
ubuntu_version: 20.04
python_version: 3.9
extra_flags: --upgrade
dont_run_on_ref: refs/heads/master
integration-tests:
needs: decide-on-test-jobs-to-run
runs-on: ${{ matrix.runs_on }}
runs-on: ubuntu-${{ matrix.ubuntu_version }}
name: ${{ matrix.name }}
strategy:
@@ -95,7 +95,7 @@ jobs:
- name: Build systemd image
run: |
.github/integration-test.py build-image
.github/integration-test.py build-image --build-arg ubuntu_version=${{ matrix.ubuntu_version }}
- name: Run bootstrap checks
run: |