Add Linux ARM tests in Steampipe Release (CLI and Assets) workflow. Closes #3468

This commit is contained in:
Puskar Basu
2023-06-09 14:55:24 +05:30
committed by GitHub
parent 55cbd32773
commit 2aaf387a2a
14 changed files with 323 additions and 180 deletions

View File

@@ -312,9 +312,7 @@ jobs:
platform: [ macos-latest ]
test_block:
- "migration"
- "brew"
- "service_and_plugin"
- "blank_aggregators"
- "search_path"
- "chaos_and_query"
- "dynamic_schema"
@@ -411,92 +409,196 @@ jobs:
chmod +x $GITHUB_WORKSPACE/tests/acceptance/run.sh
$GITHUB_WORKSPACE/tests/acceptance/run.sh ${{ matrix.test_block }}.bats
steampipe service stop --force
#
# docker_acceptance_test_debian:
# name: Acceptance tests(Docker - Debian)
# needs: [create_test_build,build_and_release_assets]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# ref: ${{ github.event.ref }}
#
# - name: Prepare for downloads
# id: prepare-for-downloads
# run: |
# mkdir ~/artifacts
#
# - name: Download Linux Build Artifacts
# uses: actions/download-artifact@v3
# with:
# name: build-artifact-linux
# path: ~/artifacts
#
# - name: Extract Ubuntu Artifacts and Install Binary
# run: |
# mkdir ~/build
# tar -xf ~/artifacts/linux.tar.gz -C ~/build
#
# - name: Copy binary
# run: |
# cp ~/build/steampipe tests/dockertesting/debian
#
# - name: Build steampipe docker images
# run: |
# docker build -t spdebian tests/dockertesting/debian --build-arg TARGETBRANCH="${{ github.event.ref }}"
# docker images
#
# - name: Create a container and run the test suite
# timeout-minutes: 15
# run: |
# docker run --name steampipe-deb `docker images -q spdebian`
# echo "docker run complete"
#
# docker_acceptance_test_oraclelinux:
# name: Acceptance tests(Docker - OracleLinux)
# needs: [create_test_build,build_and_release_assets]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# ref: ${{ github.event.ref }}
#
# - name: Prepare for downloads
# id: prepare-for-downloads
# run: |
# mkdir ~/artifacts
#
# - name: Download Linux Build Artifacts
# uses: actions/download-artifact@v3
# with:
# name: build-artifact-linux
# path: ~/artifacts
#
# - name: Extract Ubuntu Artifacts and Install Binary
# run: |
# mkdir ~/build
# tar -xf ~/artifacts/linux.tar.gz -C ~/build
#
# - name: Copy binary
# run: |
# cp ~/build/steampipe tests/dockertesting/oraclelinux
#
# - name: Build steampipe docker images
# run: |
# docker build -t sporacle tests/dockertesting/oraclelinux --build-arg TARGETBRANCH="${{ github.event.ref }}"
# docker images
#
# - name: Create a container and run the test suite
# timeout-minutes: 15
# run: |
# docker run --name steampipe-oracle `docker images -q sporacle`
# echo "docker run complete"
# docker_acceptance_test_debian:
# name: Acceptance tests(Docker - Debian)
# needs: [create_test_build,build_and_release_assets]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# ref: ${{ github.event.ref }}
# - name: Prepare for downloads
# id: prepare-for-downloads
# run: |
# mkdir ~/artifacts
# - name: Download Linux Build Artifacts
# uses: actions/download-artifact@v3
# with:
# name: build-artifact-linux
# path: ~/artifacts
# - name: Extract Ubuntu Artifacts and Install Binary
# run: |
# mkdir ~/build
# tar -xf ~/artifacts/linux.tar.gz -C ~/build
# - name: Copy binary
# run: |
# cp ~/build/steampipe tests/dockertesting/debian
# - name: Build steampipe docker images
# run: |
# docker build -t spdebian tests/dockertesting/debian --build-arg TARGETBRANCH="${{ github.event.ref }}"
# docker images
# - name: Create a container and run the test suite
# timeout-minutes: 15
# run: |
# docker run --name steampipe-deb `docker images -q spdebian`
# echo "docker run complete"
# docker_acceptance_test_oraclelinux:
# name: Acceptance tests(Docker - OracleLinux)
# needs: [create_test_build,build_and_release_assets]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# ref: ${{ github.event.ref }}
# - name: Prepare for downloads
# id: prepare-for-downloads
# run: |
# mkdir ~/artifacts
# - name: Download Linux Build Artifacts
# uses: actions/download-artifact@v3
# with:
# name: build-artifact-linux
# path: ~/artifacts
# - name: Extract Ubuntu Artifacts and Install Binary
# run: |
# mkdir ~/build
# tar -xf ~/artifacts/linux.tar.gz -C ~/build
# - name: Copy binary
# run: |
# cp ~/build/steampipe tests/dockertesting/oraclelinux
# - name: Build steampipe docker images
# run: |
# docker build -t sporacle tests/dockertesting/oraclelinux --build-arg TARGETBRANCH="${{ github.event.ref }}"
# docker images
# - name: Create a container and run the test suite
# timeout-minutes: 15
# run: |
# docker run --name steampipe-oracle `docker images -q sporacle`
# echo "docker run complete"
linux_arm_acceptance_tests:
name: Linux ARM64 acceptance tests
needs: [create_test_build,build_and_release_assets]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
ref: ${{ github.event.ref }}
- name: Configure AWS Credentials
run: |
mkdir ~/.aws
echo -e "[default]\naws_access_key_id = ${{ secrets.ACC_TEST_ARM_LINUX_AWS_ACCESS_KEY_ID }}\naws_secret_access_key = ${{ secrets.ACC_TEST_ARM_LINUX_AWS_SECRET_ACCESS_KEY }}\nregion = ap-south-1" > ~/.aws/credentials
- name: SSH into the EC2 instance and run tests
id: ssh-and-run-test-suite
timeout-minutes: 20
continue-on-error: true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'ap-south-1'
PRIVATE_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_PRIVATE_KEY }}
run: |
# echo $ref
ref=${{ github.event.ref }}
# get branch
branch=$(echo "$ref" | sed 's/.*\///')
# get public IP of this runner
ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
echo $ip
# set PAGER to empty to not get cli output automatically being sent to vim
export PAGER=
# whitelist the ip, add the ip to the security group to allow access into the instance
aws ec2 authorize-security-group-ingress --group-name pskr-sg --protocol tcp --port 22 --cidr $ip/32 --region ap-south-1
#start instance
aws ec2 start-instances --instance-ids i-09b87c86dfdfcd2bd --region ap-south-1 --output text
echo "starting instance..."
sleep 60
# get the public ip and status of the instance
public_ip=$(aws ec2 describe-instances --instance-ids i-09b87c86dfdfcd2bd --query 'Reservations[*].Instances[*].PublicDnsName' --region ap-south-1 --output text)
status=$(aws ec2 describe-instance-status --instance-ids i-09b87c86dfdfcd2bd --query 'InstanceStatuses[*].InstanceState.Name' --region ap-south-1 --output text)
echo $public_ip
echo $status
# check if the instance is available for use, if not, then wait for it
while [ $status != "running" ] ; do
echo "instance not yet available"
sleep 5
status=$(aws ec2 describe-instance-status --instance-ids i-09b87c86dfdfcd2bd --query 'InstanceStatuses[*].InstanceState.Name' --region ap-south-1 --output text)
done
# set up the private key
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
#pwd
pwd
chmod +x tests/acceptance/run-linux-arm.sh
# ssh into the instance and run the full acceptance test suite
ssh -o StrictHostKeyChecking=accept-new -i private_key ubuntu@$public_ip 'bash -s' < tests/acceptance/run-linux-arm.sh $branch
# success if all tests passed
echo "success"
- name: Stop the running instance
if: always()
env:
AWS_ACCESS_KEY_ID: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'ap-south-1'
PRIVATE_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_PRIVATE_KEY }}
run: |
# get public IP of this runner
ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
echo $ip
# stop instance
aws ec2 stop-instances --instance-ids i-09b87c86dfdfcd2bd --region ap-south-1
# remove the ip from the security group
aws ec2 revoke-security-group-ingress --group-name pskr-sg --protocol tcp --port 22 --cidr $ip/32 --region ap-south-1
# fin
echo "fin"
- name: Check if passed/failed
if: always()
run: |
if [ ${{ steps.ssh-and-run-test-suite.outcome }} == 'success' ]; then
exit 0
else
exit 1
fi
create_release_tag:
name: Tag Release
needs: [run_acceptance_tests]
needs: [run_acceptance_tests,linux_arm_acceptance_tests]
runs-on: ubuntu-latest
steps:
- name: Trim asset version prefix and Validate