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 Jul 26, 2023
1 parent 33a3423 commit a90ef54
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test-fedora-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test Fedora binaries (Sequential)

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 binaries
run: ./docker/package/scripts/test-fedora-binaries.sh
19 changes: 19 additions & 0 deletions .github/workflows/test-ubuntu-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test Ubuntu binaries (Sequential)

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 binaries
run: ./docker/package/scripts/test-ubuntu-binaries.sh
12 changes: 12 additions & 0 deletions docker/package/Dockerfile-fedora-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2021 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA

FROM fedora:latest

WORKDIR /tezos-packaging/docker

RUN dnf update -y
RUN dnf install -y python3-devel python3-setuptools

COPY docker/package/test-fedora-binaries.py /tezos-packaging/docker/test-fedora-binaries.py
CMD [ "python3", "/tezos-packaging/docker/test-fedora-binaries.py", "--no-cleanup" ]
12 changes: 12 additions & 0 deletions docker/package/Dockerfile-ubuntu-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2021 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA

FROM ubuntu:latest

WORKDIR /tezos-packaging/docker

RUN apt update -y
RUN apt install -y python3-devel python3-setuptools

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

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

docker build -t fedora-test -f docker/package/Dockerfile-fedora-test .
docker run -i fedora-test
7 changes: 7 additions & 0 deletions docker/package/scripts/test-ubuntu-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

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

docker build -t ubuntu-test -f docker/package/Dockerfile-ubuntu-test .
docker run -i ubuntu-test
66 changes: 66 additions & 0 deletions docker/package/test-fedora-binaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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 setup():
commands = [
'sudo dnf update -y',
'sudo dnf install -y \'dnf-command(copr)\'',
'sudo dnf copr enable -y @Serokell/Tezos'
]
for command in commands:
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert result.returncode == 0, f'{result.returncode}'

def test(cleanup: bool):
sys.stdout.write("Setting up env")
setup()
sys.stdout.write("Setup is done")
processed_binaries = []
try:
for binary in binaries:
sys.stdout.write(f"---------------------|Testing {binary}|---------------------")
sys.stdout.write(f"Installing {binary}")

install_command = f"sudo dnf install -y {binary}"
installation_result = subprocess.run(install_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert installation_result.returncode == 0
sys.stdout.write(f"{binary} binary successfully installed. Checking that version works fine")

processed_binaries.append(binary)

check_binary_command = f"sudo {binary} --version"
check_binary_result = subprocess.run(check_binary_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert check_binary_result.returncode == 0
sys.stdout.write(f"{binary} binary works fine")
except Exception as e:
print("Exception happened when trying to execute tests.")
print(f'{str(e)}')
if cleanup:
sys.stdout.write(f"Removing installed packages")
for binary in processed_binaries:
sys.stdout.write(f"Removing {binary}")
remove_res = subprocess.run("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)
71 changes: 71 additions & 0 deletions docker/package/test-ubuntu-binaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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 setup():
commands = [
'apt update -y',
'apt install -y software-properties-common',
'apt update -y',
'add-apt-repository -y ppa:serokell/tezos',
'apt-get update -y'

]
for command in commands:
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert result.returncode == 0, f'{result.returncode}'

def test(cleanup: bool):
sys.stdout.write("Setting up env")
setup()
sys.stdout.write("Setup is done")


processed_binaries = []
try:
for binary in binaries:
sys.stdout.write(f"---------------------|Testing {binary}|---------------------")
sys.stdout.write(f"Installing {binary}")

install_command = f"sudo apt install -y {binary}"
installation_result = subprocess.run(install_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert installation_result.returncode == 0
sys.stdout.write(f"{binary} binary successfully installed. Checking that version works fine")

processed_binaries.append(binary)

check_binary_command = f"sudo {binary} --version"
check_binary_result = subprocess.run(check_binary_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert check_binary_result.returncode == 0
sys.stdout.write(f"{binary} binary works fine")
except Exception as e:
print("Exception happened when trying to execute tests.")
print(f'{str(e)}')
if cleanup:
sys.stdout.write(f"Removing installed packages")
for binary in processed_binaries:
sys.stdout.write(f"Removing {binary}")
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 a90ef54

Please sign in to comment.