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 Sep 12, 2023
1 parent 6deb063 commit d78a0b7
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 1 deletion.
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: 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

2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 38 additions & 0 deletions binaries.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
19 changes: 19 additions & 0 deletions docker/tests/Dockerfile-fedora-test
Original file line number Diff line number Diff line change
@@ -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"]
19 changes: 19 additions & 0 deletions docker/tests/Dockerfile-ubuntu-test
Original file line number Diff line number Diff line change
@@ -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"]
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

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
13 changes: 13 additions & 0 deletions docker/tests/scripts/test-ubuntu-binaries.sh
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions docker/tests/test-fedora-binaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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)
39 changes: 39 additions & 0 deletions docker/tests/test-ubuntu-binaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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)

0 comments on commit d78a0b7

Please sign in to comment.