Skip to content

Commit

Permalink
[#641] Add tezos binaries tests
Browse files Browse the repository at this point in the history
Problem: We want to test that latests released binaries can be installed
and work fine on different oses. Currently we support only Fedora and Ubuntu

Solution: Add github actions that run docker dontainer with given os and
install and execute each binary in it. Currently we run checks in parallel,
3 jobs per os.
  • Loading branch information
PruStephan committed Aug 1, 2023
1 parent 33a3423 commit cbd05b0
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test-binaries.yml
Original file line number Diff line number Diff line change
@@ -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: ./docker/tests/scripts/test-fedora-binaries.sh

- name: Test ubuntu binaries
run: ./docker/tests/scripts/test-fedora-binaries.sh

16 changes: 16 additions & 0 deletions docker/tests/Dockerfile-fedora-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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
RUN sudo dnf update -y
RUN sudo dnf install -y 'dnf-command(copr)'
RUN sudo dnf copr enable -y @Serokell/Tezos

COPY docker/tests/test-fedora-binaries.py /tezos-packaging/docker/tests/test-fedora-binaries.py
CMD [ "python3", "/tezos-packaging/docker/tests/test-fedora-binaries.py", "--no-cleanup" ]
18 changes: 18 additions & 0 deletions docker/tests/Dockerfile-ubuntu-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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-get install -y python3-all python3-setuptools
RUN apt update -y
RUN apt install -y software-properties-common
RUN apt update -y
RUN add-apt-repository -y ppa:serokell/tezos
RUN apt-get update -y

COPY docker/tests/test-ubuntu-binaries.py /tezos-packaging/docker/tests/test-ubuntu-binaries.py
CMD [ "python3", "/tezos-packaging/docker/tests/test-ubuntu-binaries.py", "--no-cleanup" ]
11 changes: 11 additions & 0 deletions docker/tests/scripts/test-fedora-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2023 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA

set -e

for version in $(jq -r '.fedora[]' docker/supported_versions.json); do
docker build --build-arg dist="$version" -t fedora-test -f docker/tests/Dockerfile-fedora-test .
docker run -i fedora-test
done
11 changes: 11 additions & 0 deletions docker/tests/scripts/test-ubuntu-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/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=latest -t ubuntu-test -f docker/tests/Dockerfile-ubuntu-test .
docker run -i ubuntu-test
done
49 changes: 49 additions & 0 deletions docker/tests/test-fedora-binaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# SPDX-FileCopyrightText: 2023 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA

import subprocess
import sys

binaries = [
"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",
]

def test(cleanup: bool):
processed_binaries = []
for binary in binaries:
try:
install_command = f"sudo dnf install -y {binary}"
installation_result = subprocess.run(install_command, shell=True)
assert installation_result.returncode == 0

processed_binaries.append(binary)

check_binary_command = f"sudo {binary} --version"
check_binary_result = subprocess.run(check_binary_command, shell=True)
assert check_binary_result.returncode == 0
except Exception as e:
print(f"Exception happened when trying to execute tests for {binary}.\n")
raise e
if cleanup:
for binary in processed_binaries:
remove_res = subprocess.run(f"dnf remove {binary}")
assert remove_res.returncode == 0


if __name__ == "__main__":
cleanup = True
if len(sys.argv) > 1 and sys.argv[1] == "--no-cleanup":
cleanup = False
test(cleanup)
53 changes: 53 additions & 0 deletions docker/tests/test-ubuntu-binaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: 2023 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA

import subprocess
import sys

binaries = [
"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",
]

def test(cleanup: bool):
global binaries

binaries = [s.lower() for s in binaries]

processed_binaries = []
for binary in binaries:
try:
install_command = f"apt install -y {binary}"
installation_result = subprocess.run(install_command, shell=True)
assert installation_result.returncode == 0

processed_binaries.append(binary)

check_binary_command = f"{binary} --version"
check_binary_result = subprocess.run(check_binary_command, shell=True)
assert check_binary_result.returncode == 0
except Exception as e:
print(f"Exception happened when trying to execute tests for {binary}.\n")
raise e
if cleanup:
for binary in processed_binaries:
remove_res = subprocess.run("apt remove {binary}")
assert remove_res.returncode == 0


if __name__ == "__main__":
cleanup = True
if len(sys.argv) > 1 and sys.argv[1] == "--no-cleanup":
cleanup = False
test(cleanup)

0 comments on commit cbd05b0

Please sign in to comment.