Skip to content

Commit

Permalink
github: switch to use lxc
Browse files Browse the repository at this point in the history
vagrant on macos is fragile recently, try to use lxc.

Signed-off-by: Kentaro Hayashi <[email protected]>
  • Loading branch information
kenhys committed Dec 6, 2023
1 parent e18a591 commit bfb4106
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 56 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ jobs:
test:
name: Test
needs: build
runs-on: macos-latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
distribution:
- debian-bullseye
- debian-bookworm
- ubuntu-focal
- ubuntu-jammy
- images:debian/11
- images:debian/12
- ubuntu:20.04
- ubuntu:22.04
steps:
- uses: actions/checkout@master
- uses: actions/download-artifact@master
Expand All @@ -112,5 +112,6 @@ jobs:
- uses: actions/download-artifact@master
with:
name: packages-apt-source-${{ matrix.distribution }}
- name: Run Test
- uses: canonical/[email protected]
- name: Run Test
run: fluent-package/apt/systemd-test/test.sh ${{ matrix.distribution }}
11 changes: 6 additions & 5 deletions .github/workflows/yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,21 @@ jobs:
test:
name: Test
needs: build
runs-on: macos-latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
distribution:
- centos-7
- rockylinux-8
- almalinux-9
- amazonlinux-2
- images:centos/7
- images:almalinux/8
- images:almalinux/9
# - amazonlinux-2
# - amazonlinux-2023
steps:
- uses: actions/checkout@master
- uses: actions/download-artifact@master
with:
name: packages-${{ matrix.distribution }}
- uses: canonical/[email protected]
- name: Run Test
run: fluent-package/yum/systemd-test/test.sh ${{ matrix.distribution }}
37 changes: 14 additions & 23 deletions fluent-package/apt/systemd-test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ if [ -z $1 ]; then
exit 1
fi

vm=$1
dir="/vagrant/fluent-package/apt/systemd-test"

vagrant status $vm | grep -E "^${vm}\s+not created (.*)$"
if [ $? -ne 0 ]; then
echo "Error: The VM already exists. Need to destroy it in advance with the following command."
echo "$ vagrant destroy $vm"
exit 1
fi
image=$1
dir="/host/fluent-package/apt/systemd-test"

set -eu

Expand All @@ -32,24 +25,22 @@ fi

for apt_repo_type in local v5 lts; do
echo -e "\nRun test: $apt_repo_type\n"
vagrant up $vm
vagrant ssh $vm -- $dir/setup.sh
vagrant ssh $vm -- $dir/install-newly.sh $apt_repo_type
vagrant destroy -f $vm
lxc launch $image target
lxc config device add target host disk source=$PWD path=/host
lxc exec target -- $dir/setup.sh
lxc exec tartet -- $dir/install-newly.sh $apt_repo_type
lxc stop target
lxc delete target
done

for test_filename in ${test_filenames[@]}; do
echo -e "\nRun test: $test_filename\n"
vagrant up $vm
vagrant ssh $vm -- $dir/setup.sh
vagrant ssh $vm -- $dir/$test_filename
vagrant destroy -f $vm
# I want to use snapshot instead of destorying it for every test,
# but somehow, it will be often an error on GitHub Actions...
# $ vagrant ssh $vm -- $dir/setup.sh
# $ vagrant snapshot save -f $vm after-setup
# (execute a test)
# $ vagrant snapshot restore $vm after-setup
lxc launch $image target
lxc config device add target host disk source=$PWD path=/host
lxc exec target -- $dir/setup.sh
lxc exec tartet -- $dir/$test_filename
lxc stop target
lxc delete target
done

echo -e "\nAll Success!\n"
36 changes: 14 additions & 22 deletions fluent-package/yum/systemd-test/test.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
#!/bin/bash

if [ -z $1 ]; then
echo "Error: Need to specify VM name in the Vagrantfile."
echo "Ex.) $ ./test.sh almalinux-9"
echo "Error: Need to specify distribution name."
echo "Ex.) $ ./test.sh centos-7"
exit 1
fi

vm=$1
dir="/vagrant/fluent-package/yum/systemd-test"

vagrant status $vm | grep -E "^${vm}\s+not created (.*)$"
if [ $? -ne 0 ]; then
echo "Error: The VM already exists. Need to destroy it in advance with the following command."
echo "$ vagrant destroy $vm"
exit 1
fi
image=$1
dir="/host/fluent-package/yum/systemd-test"

set -eu

Expand All @@ -26,21 +19,20 @@ test_filenames=(

for yum_repo_type in local v5 lts; do
echo -e "\nRun test: $yum_repo_type\n"
vagrant up $vm
vagrant ssh $vm -- $dir/install-newly.sh $yum_repo_type
vagrant destroy -f $vm
lxc launch $image target
lxc config device add target host disk source=$PWD path=/host
lxc exec tartet -- $dir/install-newly.sh $yum_repo_type
lxc stop target
lxc delete target
done

for test_filename in ${test_filenames[@]}; do
echo -e "\nRun test: $test_filename\n"
vagrant up $vm
vagrant ssh $vm -- $dir/$test_filename
vagrant destroy -f $vm
# I want to use snapshot instead of destroying it for every test,
# but somehow, it will be often an error on GitHub Actions...
# $ vagrant snapshot save -f $vm after-setup
# (execute a test)
# $ vagrant snapshot restore $vm after-setup
lxc launch $image target
lxc config device add target host disk source=$PWD path=/host
lxc exec tartet -- $dir/$test_filename
lxc stop target
lxc delete target
done

echo -e "\nAll Success!\n"

0 comments on commit bfb4106

Please sign in to comment.