|
| 1 | +name: Workflow for Cloud init image for Cuttlefish |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'cloud-init-image-for-cuttlefish/**' |
| 7 | + push: |
| 8 | + branchs: |
| 9 | + - '**' |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-cidata-iso-job: |
| 13 | + runs-on: ubuntu-22.04 |
| 14 | + container: |
| 15 | + image: debian@sha256:9258a75a7e4323c9e5562b361effc84ee747920116d8adfc98a465a5cdc9150e # debian:bookworm-20250407 (amd64) |
| 16 | + defaults: |
| 17 | + run: |
| 18 | + working-directory: ./cloud-init-image-for-cuttlefish |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + - name: Setting up build environment |
| 23 | + run: | |
| 24 | + apt-get update |
| 25 | + apt-get upgrade -y |
| 26 | + apt-get install -y sudo |
| 27 | + apt-get install -y ca-certificates |
| 28 | + apt-get install -y cloud-init |
| 29 | + apt-get install -y xorriso genisoimage |
| 30 | + - name: Check user-data |
| 31 | + run: | |
| 32 | + ./check_user_data.sh |
| 33 | + - name: Create gigabyte-cidata.iso image |
| 34 | + run: | |
| 35 | + ./gen_cidata_iso.sh |
| 36 | + - name: Upload artifacts |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: cloud-init-image-for-cuttlefish-artifacts |
| 40 | + path: cloud-init-image-for-cuttlefish/gigabyte-cidata.iso |
| 41 | + |
| 42 | + test-qemu-cloud-arm64-cidata-job: |
| 43 | + needs: build-cidata-iso-job |
| 44 | + runs-on: ubuntu-22.04 |
| 45 | + container: |
| 46 | + image: debian:trixie # debian:trixie (amd64) |
| 47 | + defaults: |
| 48 | + run: |
| 49 | + working-directory: ./cloud-init-image-for-cuttlefish |
| 50 | + env: |
| 51 | + TEST_DISK_SIZE: "10G" |
| 52 | + steps: |
| 53 | + - name: Checkout repository |
| 54 | + uses: actions/checkout@v4 |
| 55 | + - name: Download artifacts |
| 56 | + uses: actions/download-artifact@v4 |
| 57 | + with: |
| 58 | + name: cloud-init-image-for-cuttlefish-artifacts |
| 59 | + - name: Prepare test environment |
| 60 | + run: | |
| 61 | + apt-get update |
| 62 | + apt-get upgrade -y |
| 63 | + apt-get install -y sudo |
| 64 | + apt-get install -y debconf-utils |
| 65 | + echo "tzdata tzdata/Areas select Etc" | debconf-set-selections -v |
| 66 | + echo "tzdata tzdata/Zones/Etc select UTC" | debconf-set-selections -v |
| 67 | + DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata |
| 68 | + dpkg-reconfigure --frontend noninteractive tzdata |
| 69 | + echo "pbuilder pbuilder/mirrorsite string http://deb.debian.org/debian/" | debconf-set-selections -v |
| 70 | + DEBIAN_FRONTEND=noninteractive apt-get install -y pbuilder |
| 71 | + dpkg-reconfigure --frontend noninteractive pbuilder |
| 72 | + apt-get install -y util-linux util-linux-extra |
| 73 | + apt-get install -y xz-utils |
| 74 | + apt-get install -y qemu-system-arm |
| 75 | + apt-get install -y expect |
| 76 | + apt-get install -y e2tools e2fsprogs |
| 77 | + apt-get install -y guestfish |
| 78 | + apt-get install -y lvm2 |
| 79 | + apt-get install -y ubuntu-dev-tools |
| 80 | + apt-get install -y u-boot-qemu |
| 81 | + apt-get install -y wget curl |
| 82 | + apt-get install -y openssh-client sshpass |
| 83 | + apt-get install -y screen |
| 84 | + - name: Download Debian |
| 85 | + run: | |
| 86 | + ./download_debian.sh |
| 87 | + - name: Download Cuttlefish |
| 88 | + run: | |
| 89 | + ../gigabyte-ampere-cuttlefish-installer/utils/download-ci-cf.sh |
| 90 | + - name: Move artifacts to current working directory. |
| 91 | + run: | |
| 92 | + mv ../gigabyte-cidata.iso . |
| 93 | + - name: Cloud image first boot with qemu |
| 94 | + run: | |
| 95 | + screen -d -m -L -Logfile console_001.log ./run_qemu.sh |
| 96 | + while ! egrep "[^[:space:]]+[[:space:]]login:" console_001.log; do sleep 30; done |
| 97 | + cp -f console_001.log console_001_p1.log |
| 98 | + CONSOLELINES=$(cat console_001_p1.log | wc -l) |
| 99 | + cat console_001_p1.log |
| 100 | + grep "login:" console_001_p1.log > /dev/null |
| 101 | + echo "CONSOLELINES=${CONSOLELINES}" >> $GITHUB_ENV |
| 102 | + - name: Wait for post install script finish |
| 103 | + run: | |
| 104 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'while [ ! -e /var/log/custom-startup.log ]; do sleep 30; echo "Check custom-startup.log"; done' |
| 105 | + sshpass -p cuttlefish scp -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -P 33322 vsoc-01@localhost:/var/log/custom-startup.log ./custom-startup.log |
| 106 | + CUSTOM_LOG_LINES=$(wc -l < ./custom-startup.log) |
| 107 | + cat ./custom-startup.log |
| 108 | + while ! grep "VM successful" ./custom-startup.log; do sleep 30; sshpass -p cuttlefish scp -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -P 33322 vsoc-01@localhost:/var/log/custom-startup.log ./custom-startup.log; tail -n +${CUSTOM_LOG_LINES} ./custom-startup.log; CUSTOM_LOG_LINES=$(wc -l < ./custom-startup.log); done |
| 109 | + - name: Deploy cuttlefish |
| 110 | + run: | |
| 111 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'echo cuttlefish | sudo -S -k apt-get install -y unzip' |
| 112 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'mkdir cf' |
| 113 | + sshpass -p cuttlefish scp -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -P 33322 cvd-host_package.tar.gz vsoc-01@localhost:/home/vsoc-01/ |
| 114 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'cd cf; tar -xvf ../cvd-host_package.tar.gz' |
| 115 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'rm -f cvd-host_package.tar.gz' |
| 116 | + sshpass -p cuttlefish scp -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -P 33322 aosp_cf_arm64*_phone-*.zip vsoc-01@localhost:/home/vsoc-01/ |
| 117 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'cd cf; unzip ../aosp_cf_arm64*_phone-*.zip' |
| 118 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'rm -f aosp_cf_arm64*_phone-*.zip' |
| 119 | + - name: Run cuttlefish command line |
| 120 | + run: | |
| 121 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'cd cf; HOME=$PWD ./bin/launch_cvd -help' || true |
| 122 | + - name: Run apt-cache policy |
| 123 | + run: | |
| 124 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'apt-cache policy' |
| 125 | + - name: Test for lzop |
| 126 | + run: | |
| 127 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'lzop -V' |
| 128 | + - name: Test for Google NTP server |
| 129 | + run: | |
| 130 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'ntpq -p' |
| 131 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'ntpq -p' | grep 'time1.google' && CHECK_GOOGLE_TIME_SERVER=1 |
| 132 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'ntpq -p' | grep '.GOOG.' && CHECK_GOOGLE_TIME_SERVER=1 |
| 133 | + if [ x"${CHECK_GOOGLE_TIME_SERVER}" != x"1" ]; then echo "Google Time Servers not found!"; false; fi |
| 134 | + - name: Test for ulimit |
| 135 | + run: | |
| 136 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'ulimit -a' |
| 137 | + test $(sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'ulimit -n') -ge 2048 |
| 138 | + - name: Test for iptables command |
| 139 | + run: | |
| 140 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'update-alternatives --display iptables' | grep "link currently points to /usr/sbin/iptables-legacy" |
| 141 | + - name: Shutdown qemu |
| 142 | + run: | |
| 143 | + sshpass -p cuttlefish ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -p 33322 vsoc-01@localhost 'echo cuttlefish | sudo -S -k shutdown -h 1' |
| 144 | + while ! grep "reboot: Power down" console_001.log; do sleep 30; done |
| 145 | + tail -n +"${CONSOLELINES}" console_001.log |
0 commit comments