diff --git a/.github/workflows/test-binaries.yml b/.github/workflows/test-binaries.yml new file mode 100644 index 000000000..988f740f1 --- /dev/null +++ b/.github/workflows/test-binaries.yml @@ -0,0 +1,23 @@ +name: Test Tezos binaries + +on: + schedule: + - cron: "0 0 * * *" + push: + branches: + - PruStephan/Add_tests_for_packages + +jobs: + test_binaries: + name: Install and test binaries + runs-on: [self-hosted, Linux, X64, nix-with-docker] + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Test fedora binaries + run: nix develop .#buildkite -c ./docker/tests/scripts/test-fedora-binaries.sh + + - name: Test ubuntu binaries + run: nix develop .#buildkite -c ./docker/tests/scripts/test-ubuntu-binaries.sh + diff --git a/.reuse/dep5 b/.reuse/dep5 index bf1e00aff..17abb308b 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -4,6 +4,6 @@ Files: .github/* nix/nix/* nix/build/install_topfind_196.patch protocols.json me Copyright: 2022 Oxhead Alpha License: LicenseRef-MIT-OA -Files: nix/build/install_topfind_196.patch baking/src/tezos_baking/__init__.py +Files: nix/build/install_topfind_196.patch baking/src/tezos_baking/__init__.py binaries.json Copyright: 2023 Oxhead Alpha License: LicenseRef-MIT-OA diff --git a/binaries.json b/binaries.json new file mode 100644 index 000000000..ea1aa14a4 --- /dev/null +++ b/binaries.json @@ -0,0 +1,38 @@ +{ + "released": [ + "tezos-baking", + "tezos-sapling-params", + "tezos-client", + "tezos-admin-client", + "tezos-node", + "tezos-signer", + "tezos-codec", + "tezos-baker-PtMumbai", + "tezos-accuser-PtMumbai", + "tezos-smart-rollup-client-PtMumbai", + "tezos-smart-rollup-node-PtMumbai", + "tezos-baker-PtNairob", + "tezos-accuser-PtNairob", + "tezos-smart-rollup-client-PtNairob", + "tezos-smart-rollup-node-PtNairob" + ], + "candidates": [ + "tezos-smart-rollup-client-Proxford", + "tezos-smart-rollup-client-PtNairob", + "tezos-smart-rollup-node-Proxford", + "tezos-smart-rollup-node-PtNairob", + "tezos-baking", + "tezos-sapling-params", + "tezos-accuser-Proxford", + "tezos-baker-Proxford", + "tezos-accuser-PtNairob", + "tezos-baker-PtNairob", + "tezos-node", + "tezos-dac-node", + "tezos-dac-client", + "tezos-codec", + "tezos-signer", + "tezos-admin-client", + "tezos-client" + ] +} \ No newline at end of file diff --git a/docker/tests/Dockerfile-fedora-test b/docker/tests/Dockerfile-fedora-test new file mode 100644 index 000000000..7d983234e --- /dev/null +++ b/docker/tests/Dockerfile-fedora-test @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2023 Oxhead Alpha +# SPDX-License-Identifier: LicenseRef-MIT-OA + +ARG dist +FROM fedora:${dist} + +WORKDIR /tezos-packaging/docker + +RUN dnf update -y +RUN dnf install -y python3-devel python3-setuptools 'dnf-command(copr)' + +ARG repo +RUN dnf copr enable -y @Serokell/${repo} + +ENV IS_RELEASED=${repo} + +COPY docker/tests/test-fedora-binaries.py /tezos-packaging/docker/tests/test-fedora-binaries.py +COPY binaries.json /tezos-packaging/binaries.json +CMD [ "python3", "/tezos-packaging/docker/tests/test-fedora-binaries.py"] diff --git a/docker/tests/Dockerfile-ubuntu-test b/docker/tests/Dockerfile-ubuntu-test new file mode 100644 index 000000000..e04dd3ab8 --- /dev/null +++ b/docker/tests/Dockerfile-ubuntu-test @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2023 Oxhead Alpha +# SPDX-License-Identifier: LicenseRef-MIT-OA + +ARG dist +FROM ubuntu:${dist} + +WORKDIR /tezos-packaging/docker + +RUN apt update -y +RUN apt install -y python3-all python3-setuptools software-properties-common + +ARG repo +RUN add-apt-repository -yu ppa:serokell/${repo} + +ENV IS_RELEASED=${repo} + +COPY docker/tests/test-ubuntu-binaries.py /tezos-packaging/docker/tests/test-ubuntu-binaries.py +COPY binaries.json /tezos-packaging/binaries.json +CMD [ "python3", "/tezos-packaging/docker/tests/test-ubuntu-binaries.py"] diff --git a/docker/tests/scripts/test-fedora-binaries.sh b/docker/tests/scripts/test-fedora-binaries.sh new file mode 100755 index 000000000..bd33a0bba --- /dev/null +++ b/docker/tests/scripts/test-fedora-binaries.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2023 Oxhead Alpha +# SPDX-License-Identifier: LicenseRef-MIT-OA + +for version in $(jq -r '.fedora[]' docker/supported_versions.json); do + docker build --build-arg dist="$version" --build-arg repo="Tezos" -t fedora-test -f docker/tests/Dockerfile-fedora-test . + docker run fedora-test + docker build --build-arg dist="$version" --build-arg repo="Tezos-rc" -t fedora-test -f docker/tests/Dockerfile-fedora-test . + docker run fedora-test +done \ No newline at end of file diff --git a/docker/tests/scripts/test-ubuntu-binaries.sh b/docker/tests/scripts/test-ubuntu-binaries.sh new file mode 100755 index 000000000..91d248ef8 --- /dev/null +++ b/docker/tests/scripts/test-ubuntu-binaries.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2023 Oxhead Alpha +# SPDX-License-Identifier: LicenseRef-MIT-OA + +set -e + +for version in $(jq -r '.ubuntu[]' docker/supported_versions.json); do + docker build --build-arg dist="$version" --build-arg repo="tezos" -t ubuntu-test -f docker/tests/Dockerfile-ubuntu-test . + docker run fedora-test + docker build --build-arg dist="$version" --build-arg repo="tezos-rc" -t ubuntu-test -f docker/tests/Dockerfile-ubuntu-test . + docker run ubuntu-test +done \ No newline at end of file diff --git a/docker/tests/test-fedora-binaries.py b/docker/tests/test-fedora-binaries.py new file mode 100644 index 000000000..a42aeafb6 --- /dev/null +++ b/docker/tests/test-fedora-binaries.py @@ -0,0 +1,41 @@ +# SPDX-FileCopyrightText: 2023 Oxhead Alpha +# SPDX-License-Identifier: LicenseRef-MIT-OA + +import subprocess +import sys +import json +import os + + +def test(binaries): + subprocess.run("dnf update -y", shell=True, capture_output=True) + for binary in binaries: + try: + subprocess.run( + f"dnf install -y {binary}", shell=True, capture_output=True, check=True + ) + if binary != "tezos-sapling-params" and binary != "tezos-baking": + print(f"{binary}: ", end="", flush=True) + subprocess.check_call( + f"{binary.replace('tezos', 'octez')} --version", shell=True + ) + except Exception as e: + print(f"Exception happened when trying to execute tests for {binary}.\n") + raise e + + +if __name__ == "__main__": + data = {} + with open("/tezos-packaging/binaries.json") as f: + data = json.load(f) + + binaries = [] + is_released = os.environ["IS_RELEASED"] + if is_released == "Tezos": + binaries = data["released"] + elif is_released == "Tezos-rc": + binaries = data["candidates"] + else: + raise "Incorrect argument" + + test(binaries) diff --git a/docker/tests/test-ubuntu-binaries.py b/docker/tests/test-ubuntu-binaries.py new file mode 100644 index 000000000..a90034129 --- /dev/null +++ b/docker/tests/test-ubuntu-binaries.py @@ -0,0 +1,44 @@ +# SPDX-FileCopyrightText: 2023 Oxhead Alpha +# SPDX-License-Identifier: LicenseRef-MIT-OA + +import subprocess +import sys +import json +import os + + +def test(binaries): + subprocess.run("apt update -y", shell=True, capture_output=True) + for binary in binaries: + try: + subprocess.run( + f"apt install -y {binary.lower()}", + shell=True, + capture_output=True, + check=True, + ) + if binary != "tezos-sapling-params" and binary != "tezos-baking": + print(f"{binary}: ", end="", flush=True) + subprocess.check_call( + f"{binary.replace('tezos', 'octez')} --version", shell=True + ) + except Exception as e: + print(f"Exception happened when trying to execute tests for {binary}.\n") + raise e + + +if __name__ == "__main__": + data = {} + with open("/tezos-packaging/binaries.json") as f: + data = json.load(f) + + binaries = [] + is_released = os.environ["IS_RELEASED"] + if is_released == "tezos": + binaries = data["released"] + elif is_released == "tezos-rc": + binaries = data["candidates"] + else: + raise "Incorrect argument" + + test(binaries)