Run smoke tests before releasing (#4273)

This commit is contained in:
Puskar Basu
2024-05-23 14:05:29 +05:30
committed by GitHub
parent 663f4031ea
commit 789bb15bf9
8 changed files with 356 additions and 2 deletions

View File

@@ -284,7 +284,9 @@ jobs:
run: |
mkdir ~/artifacts
mv $GITHUB_WORKSPACE/dist/steampipe_linux_amd64.tar.gz ~/artifacts/linux.tar.gz
mv $GITHUB_WORKSPACE/dist/steampipe_linux_arm64.tar.gz ~/artifacts/linux-arm.tar.gz
mv $GITHUB_WORKSPACE/dist/steampipe_darwin_amd64.zip ~/artifacts/darwin.zip
mv $GITHUB_WORKSPACE/dist/steampipe_darwin_arm64.zip ~/artifacts/darwin-arm.zip
- name: List Build Artifacts
run: ls -l ~/artifacts
@@ -297,6 +299,14 @@ jobs:
if-no-files-found: error
overwrite: true
- name: Save Linux ARM Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact-linux-arm
path: ~/artifacts/linux-arm.tar.gz
if-no-files-found: error
overwrite: true
- name: Save MacOS Build Artifact
uses: actions/upload-artifact@v4
with:
@@ -305,6 +315,14 @@ jobs:
if-no-files-found: error
overwrite: true
- name: Save MacOS ARM Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact-darwin-arm
path: ~/artifacts/darwin-arm.zip
if-no-files-found: error
overwrite: true
run_acceptance_tests:
name: Acceptance tests
needs: [create_test_build,build_and_release_assets]
@@ -434,9 +452,216 @@ jobs:
$GITHUB_WORKSPACE/tests/acceptance/run.sh ${{ matrix.test_block }}.bats
steampipe service stop --force
smoke_test_ubuntu_24:
name: Smoke test (Ubuntu 24, x86_64)
runs-on: ubuntu-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Linux Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-linux
path: ./artifacts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull Ubuntu latest Image
run: docker pull ubuntu:latest
- name: Create and Start Ubuntu latest Container
run: |
docker run -d --name ubuntu-24-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts ubuntu:latest tail -f /dev/null
- name: Get runner/container info
run: |
docker exec ubuntu-24-test /scripts/linux_container_info.sh
- name: Install dependencies, create user, and assign necessary permissions
run: |
docker exec ubuntu-24-test /scripts/prepare_ubuntu_container.sh
- name: Run smoke tests
run: |
docker exec -u steampipe ubuntu-24-test /scripts/smoke_test.sh
- name: Stop and Remove Container
run: |
docker stop ubuntu-24-test
docker rm ubuntu-24-test
smoke_test_centos_9:
name: Smoke test (Centos stream 9, x86_64)
runs-on: ubuntu-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Linux Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-linux
path: ./artifacts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull CentOS Stream 9 image
run: docker pull quay.io/centos/centos:stream9
- name: Create and Start CentOS stream9 Container
run: |
docker run -d --name centos-stream9-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts quay.io/centos/centos:stream9 tail -f /dev/null
- name: Get runner/container info
run: |
docker exec centos-stream9-test /scripts/linux_container_info.sh
- name: Install dependencies, create user, and assign necessary permissions
run: |
docker exec centos-stream9-test /scripts/prepare_centos_container.sh
- name: Run smoke tests
run: |
docker exec -u steampipe centos-stream9-test /scripts/smoke_test.sh
- name: Stop and Remove Container
run: |
docker stop centos-stream9-test
docker rm centos-stream9-test
smoke_test_amazonlinux:
name: Smoke test (Amazonlinux 2023, x86_64)
runs-on: ubuntu-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Linux Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-linux
path: ./artifacts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull Amazon Linux 2023 Image
run: docker pull amazonlinux:2023
- name: Create and Start Amazon Linux 2023 Container
run: |
docker run -d --name amazonlinux-2023-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts amazonlinux:2023 tail -f /dev/null
- name: Get runner/container info
run: |
docker exec amazonlinux-2023-test /scripts/linux_container_info.sh
- name: Install dependencies, create user, and assign necessary permissions
run: |
docker exec amazonlinux-2023-test /scripts/prepare_amazonlinux_container.sh
- name: Run smoke tests
run: |
docker exec -u steampipe amazonlinux-2023-test /scripts/smoke_test.sh
- name: Stop and Remove Container
run: |
docker stop amazonlinux-2023-test
docker rm amazonlinux-2023-test
smoke_test_ubuntu_24_arm64:
name: Smoke test (Ubuntu 24, ARM64)
runs-on: ubuntu-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Linux Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-linux-arm
path: ./artifacts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Create Buildx Builder
run: |
docker buildx create --use --name mybuilder
docker buildx inspect --bootstrap
- name: Pull Ubuntu 24 ARM64 Image
run: docker pull arm64v8/ubuntu:latest
- name: Create and Start Ubuntu 24 ARM64 Container
run: |
docker run -d --name ubuntu-24-arm64-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts arm64v8/ubuntu:latest tail -f /dev/null
- name: Get runner/container info
run: |
docker exec ubuntu-24-arm64-test /scripts/linux_container_info.sh
- name: Install dependencies, create user, and assign necessary permissions
run: |
docker exec ubuntu-24-arm64-test /scripts/prepare_ubuntu_arm_container.sh
- name: Run smoke tests
run: |
docker exec -u steampipe ubuntu-24-arm64-test /scripts/smoke_test.sh
- name: Stop and Remove Container
run: |
docker stop ubuntu-24-arm64-test
docker rm ubuntu-24-arm64-test
smoke_test_darwin_arm:
name: Smoke test (MacOS 14, ARM64)
runs-on: macos-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Darwin Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-darwin-arm
path: ~/artifacts
- name: Extract Darwin Artifacts and Install Binary
run: |
unzip ~/artifacts/darwin-arm.zip -d /usr/local/bin
- name: Install jq
run: |
brew install jq
- name: Get runner/container info
run: |
uname -a
sw_vers
- name: Run Smoke tests
run: |
ls -al $GITHUB_WORKSPACE/scripts
chmod +x $GITHUB_WORKSPACE/scripts/smoke_test.sh
$GITHUB_WORKSPACE/scripts/smoke_test.sh
create_release_tag:
name: Tag Release
needs: [run_acceptance_tests]
needs: [run_acceptance_tests, smoke_test_ubuntu_24, smoke_test_amazonlinux, smoke_test_centos_9, smoke_test_ubuntu_24_arm64, smoke_test_darwin_arm]
runs-on: ubuntu-latest
steps:
- name: Trim asset version prefix and Validate

View File

@@ -18,7 +18,7 @@ Also https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-versi
**/
// The main version number that is being run at the moment.
var steampipeVersion = "0.23.2"
var steampipeVersion = "0.23.1"
// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release

View File

@@ -0,0 +1,7 @@
#!/bin/sh
# This is a a script to get the information about the linux container.
# Used in release smoke tests.
uname -a # uname information
cat /etc/os-release # OS version information
ldd --version # glibc version information

View File

@@ -0,0 +1,20 @@
#!/bin/sh
# This is a a script to install dependencies/packages, create user, and assign necessary permissions in the amazonlinux 2023 container.
# Used in release smoke tests.
# update yum and install required packages
yum install -y shadow-utils tar gzip ca-certificates jq
# Extract the steampipe binary
tar -xzf /artifacts/linux.tar.gz -C /usr/local/bin
# Create user, since steampipe cannot be run as root
useradd -m steampipe
# Ensure the binary is executable and owned by steampipe and is executable
chown steampipe:steampipe /usr/local/bin/steampipe
chmod +x /usr/local/bin/steampipe
# Ensure the script is executable
chown steampipe:steampipe /scripts/smoke_test.sh
chmod +x /scripts/smoke_test.sh

View File

@@ -0,0 +1,21 @@
#!/bin/sh
# This is a a script to install dependencies/packages, create user, and assign necessary permissions in the centos 9 container.
# Used in release smoke tests.
# update yum and install required packages
yum install -y epel-release
yum install -y tar ca-certificates jq
# Extract the steampipe binary
tar -xzf /artifacts/linux.tar.gz -C /usr/local/bin
# Create user, since steampipe cannot be run as root
useradd -m steampipe
# Ensure the binary is executable and owned by steampipe and is executable
chown steampipe:steampipe /usr/local/bin/steampipe
chmod +x /usr/local/bin/steampipe
# Ensure the script is executable
chown steampipe:steampipe /scripts/smoke_test.sh
chmod +x /scripts/smoke_test.sh

View File

@@ -0,0 +1,20 @@
#!/bin/sh
# This is a a script to install dependencies/packages, create user, and assign necessary permissions in the ubuntu 24 container.
# Used in release smoke tests.
# update apt and install required packages
apt-get update
apt-get install -y tar ca-certificates jq
# Extract the steampipe binary
tar -xzf /artifacts/linux-arm.tar.gz -C /usr/local/bin
# Make the binary executable
chmod +x /usr/local/bin/steampipe
# Create user, since steampipe cannot be run as root
useradd -m steampipe
# Make the scripts executable
chown steampipe:steampipe /scripts/smoke_test.sh
chmod +x /scripts/smoke_test.sh

View File

@@ -0,0 +1,20 @@
#!/bin/sh
# This is a a script to install dependencies/packages, create user, and assign necessary permissions in the ubuntu 24 container.
# Used in release smoke tests.
# update apt and install required packages
apt-get update
apt-get install -y tar ca-certificates jq
# Extract the steampipe binary
tar -xzf /artifacts/linux.tar.gz -C /usr/local/bin
# Make the binary executable
chmod +x /usr/local/bin/steampipe
# Create user, since steampipe cannot be run as root
useradd -m steampipe
# Make the scripts executable
chown steampipe:steampipe /scripts/smoke_test.sh
chmod +x /scripts/smoke_test.sh

41
scripts/smoke_test.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/sh
# This is a script with set of commands to smoke test a steampipe build.
# The plan is to gradually add more tests to this script.
/usr/local/bin/steampipe --version # check version
/usr/local/bin/steampipe query "select 1 as installed" # verify installation
/usr/local/bin/steampipe plugin install steampipe # verify plugin install
/usr/local/bin/steampipe plugin list # verify plugin listings
/usr/local/bin/steampipe query "select name from steampipe_registry_plugin limit 10;" # verify simple query
/usr/local/bin/steampipe plugin uninstall steampipe # verify plugin uninstall
/usr/local/bin/steampipe plugin list # verify plugin listing after uninstalling
/usr/local/bin/steampipe plugin install steampipe # re-install for other tests
# the file path is different for darwin and linux
if [ "$(uname -s)" = "Darwin" ]; then
/usr/local/bin/steampipe query "select name from steampipe_registry_plugin limit 1;" --export /Users/runner/query.sps # verify file export
cat /Users/runner/query.sps | jq '.end_time' # verify file created is readable
else
/usr/local/bin/steampipe query "select name from steampipe_registry_plugin limit 1;" --export /home/steampipe/query.sps # verify file export
cat /home/steampipe/query.sps | jq '.end_time' # verify file created is readable
fi
# Ensure the log file path exists before trying to read it
LOG_PATH="/home/steampipe/.steampipe/logs/steampipe-*.log"
if [ "$(uname -s)" = "Darwin" ]; then
LOG_PATH="/Users/runner/.steampipe/logs/steampipe-*.log"
fi
# Verify log level in logfile
STEAMPIPE_LOG=info /usr/local/bin/steampipe query "select name from steampipe_registry_plugin limit 1;"
# Check if log file exists before attempting to cat it
if ls $LOG_PATH 1> /dev/null 2>&1; then
bash -c "cat $LOG_PATH | grep '\[INFO\]'"
else
echo "Log file not found: $LOG_PATH"
exit 1
fi