From 14532d27cd609285864771c2ab6729203ad6e590 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 24 Jun 2021 18:03:46 +0100 Subject: [PATCH 1/2] GHA workflow to build the debs --- .github/workflows/debs.yml | 44 +++++++++++++++++++++++++++++++ changelog.d/10248.misc | 1 + scripts-dev/build_debian_packages | 17 +++++++++--- 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/debs.yml create mode 100644 changelog.d/10248.misc diff --git a/.github/workflows/debs.yml b/.github/workflows/debs.yml new file mode 100644 index 000000000000..e03a41942695 --- /dev/null +++ b/.github/workflows/debs.yml @@ -0,0 +1,44 @@ +# GitHub actions workflow which builds the debian packages. + +name: Debs + +on: + push: + branches: ["develop", "release-*"] + +permissions: + contents: read + +jobs: + # first get the list of distros to build for. + get-distros: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - id: set-distros + run: | + echo "::set-output name=distros::$(scripts-dev/build_debian_packages --show-dists-json)" + # map the step outputs to job outputs + outputs: + distros: ${{ steps.set-distros.outputs.distros }} + + # now build the packages with a matrix build. + build-debs: + needs: get-distros + name: "Build .deb packages" + runs-on: ubuntu-latest + strategy: + matrix: + distro: ${{ fromJson(needs.get-distros.outputs.distros) }} + + steps: + - uses: actions/checkout@v2 + with: + path: src + - uses: actions/setup-python@v2 + - run: ./src/scripts-dev/build_debian_packages "${{ matrix.distro }}" + - uses: actions/upload-artifact@v2 + with: + name: packages + path: debs/* diff --git a/changelog.d/10248.misc b/changelog.d/10248.misc new file mode 100644 index 000000000000..5824907bca63 --- /dev/null +++ b/changelog.d/10248.misc @@ -0,0 +1 @@ +Build the Debian packages in CI. diff --git a/scripts-dev/build_debian_packages b/scripts-dev/build_debian_packages index 546724f89fea..e34e12257ed9 100755 --- a/scripts-dev/build_debian_packages +++ b/scripts-dev/build_debian_packages @@ -10,6 +10,7 @@ # can be passed on the commandline for debugging. import argparse +import json import os import signal import subprocess @@ -34,6 +35,7 @@ By default, builds for all known distributions, but a list of distributions can be passed on the commandline for debugging. """ +projdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) class Builder(object): def __init__(self, redirect_stdout=False): @@ -57,9 +59,6 @@ class Builder(object): raise def _inner_build(self, dist, skip_tests=False): - projdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) - os.chdir(projdir) - tag = dist.split(":", 1)[1] # Make the dir where the debs will live. @@ -93,6 +92,7 @@ class Builder(object): ], stdout=stdout, stderr=subprocess.STDOUT, + cwd=projdir, ) container_name = "synapse_build_" + tag @@ -179,6 +179,11 @@ if __name__ == "__main__": action="store_true", help="skip running tests after building", ) + parser.add_argument( + "--show-dists-json", + action="store_true", + help="instead of building the packages, just list the dists to build for, as a json array", + ) parser.add_argument( "dist", nargs="*", @@ -186,4 +191,8 @@ if __name__ == "__main__": help="a list of distributions to build for. Default: %(default)s", ) args = parser.parse_args() - run_builds(dists=args.dist, jobs=args.jobs, skip_tests=args.no_check) + if args.show_dists_json: + json.dump(DISTS, sys.stdout) + print() + else: + run_builds(dists=args.dist, jobs=args.jobs, skip_tests=args.no_check) From e53084c9fe851d4e77c2668c4349689a884ca03f Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 12 Jul 2021 18:00:12 +0100 Subject: [PATCH 2/2] fix lint and review comments --- changelog.d/{10248.misc => 10247.misc} | 0 scripts-dev/build_debian_packages | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename changelog.d/{10248.misc => 10247.misc} (100%) diff --git a/changelog.d/10248.misc b/changelog.d/10247.misc similarity index 100% rename from changelog.d/10248.misc rename to changelog.d/10247.misc diff --git a/scripts-dev/build_debian_packages b/scripts-dev/build_debian_packages index e34e12257ed9..e25c5bb2650d 100755 --- a/scripts-dev/build_debian_packages +++ b/scripts-dev/build_debian_packages @@ -37,6 +37,7 @@ can be passed on the commandline for debugging. projdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + class Builder(object): def __init__(self, redirect_stdout=False): self.redirect_stdout = redirect_stdout @@ -192,7 +193,6 @@ if __name__ == "__main__": ) args = parser.parse_args() if args.show_dists_json: - json.dump(DISTS, sys.stdout) - print() + print(json.dumps(DISTS)) else: run_builds(dists=args.dist, jobs=args.jobs, skip_tests=args.no_check)