Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts to validate a release package #626

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions package/validate/test-mount-s3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /bin/sh
set -e

echo
echo "Show installed version:"
mount-s3 --version

echo
echo "Mount and list top-level content of bucket: $BUCKET"
mkdir ~/mnt
mount-s3 "$BUCKET" ~/mnt --no-sign-request
ls ~/mnt
16 changes: 16 additions & 0 deletions package/validate/validate-deb-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/sh
set -e

apt-get -qq update -y && apt-get -qq install -y wget gpg
cd /tmp

wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.deb
wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.deb.asc

wget https://s3.amazonaws.com/mountpoint-s3-release/public_keys/KEYS
gpg --import KEYS
gpg --verify mount-s3-$VERSION-$ARCH.deb.asc mount-s3-$VERSION-$ARCH.deb

apt-get install -y ./mount-s3-$VERSION-$ARCH.deb

. $(dirname "$0")/test-mount-s3.sh
19 changes: 19 additions & 0 deletions package/validate/validate-gzip-al2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/sh
set -e

yum update -y && yum install -y wget gpg tar gzip
cd /tmp

wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.tar.gz
wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.tar.gz.asc

wget https://s3.amazonaws.com/mountpoint-s3-release/public_keys/KEYS
gpg --import KEYS
gpg --verify mount-s3-$VERSION-$ARCH.tar.gz.asc mount-s3-$VERSION-$ARCH.tar.gz

tar -zxvf mount-s3-$VERSION-$ARCH.tar.gz
cp bin/mount-s3 /usr/bin/
# install Mountpoint dependencies manually
yum install -y fuse fuse-devel

. $(dirname "$0")/test-mount-s3.sh
16 changes: 16 additions & 0 deletions package/validate/validate-rpm-al2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/sh
set -e

yum update -y && yum install -y wget gpg
cd /tmp

wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.rpm
wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.rpm.asc

wget https://s3.amazonaws.com/mountpoint-s3-release/public_keys/KEYS
gpg --import KEYS
gpg --verify mount-s3-$VERSION-$ARCH.rpm.asc mount-s3-$VERSION-$ARCH.rpm

yum install -y mount-s3-$VERSION-$ARCH.rpm

. $(dirname "$0")/test-mount-s3.sh
60 changes: 60 additions & 0 deletions package/validate/validate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
passaro marked this conversation as resolved.
Show resolved Hide resolved

"""
Script for validating a Mountpoint release package.

This script validates the RPM and DEB packages and the gzip archive built for a Mountpoint release.
"""

import argparse
import os
import subprocess

def validate(args: argparse.Namespace) -> str:
"""Top-level driver."""

package=f"{args.artifact}-{args.os}"
if package == "deb-ubuntu":
image = "ubuntu/ubuntu:20.04"
elif package == "rpm-al2" or package == "gzip-al2":
image = "amazonlinux/amazonlinux:2"
else:
raise Exception(f"unsupported OS {args.os} for {args.artifact}. Supported combinations are: deb-ubuntu, rpm-al2, gzip-al2")

print("Validating Mountpoint Release Package")
print(f"\tVersion: {args.version}")
print(f"\tArch: {args.arch}")
print(f"\tOS: {args.os}")
print(f"\tArtifact: {args.artifact}")
print(f"\tBucket: {args.bucket}")
print("\n")

full_image = f"public.ecr.aws/{image}"
validate_script = f"validate-{package}.sh"
scripts_dir = os.path.dirname(os.path.realpath(__file__))

subprocess.run(["docker", "pull", full_image])
subprocess.run(["docker",
"run",
"--rm",
"--cap-add=SYS_ADMIN",
"--device=/dev/fuse",
f"-v={scripts_dir}:/scripts",
f"--env=ARCH={args.arch}",
f"--env=VERSION={args.version}",
f"--env=BUCKET={args.bucket}",
full_image,
"/bin/bash",
f"/scripts/{validate_script}"])

if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("--version", help="the version number for the Mountpoint release", required=True)
p.add_argument("--arch", help="the architecture to validate", required=True, choices=["x86_64", "arm64"])
p.add_argument("--artifact", help="the artifact to validate", required=True, choices=["deb", "rpm", "gzip"])
p.add_argument("--os", help="the OS to validate on", required=True, choices=["ubuntu", "al2"])
p.add_argument("--bucket", help="the public bucket to mount", required=True)

args = p.parse_args()

validate(args)