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 workflow to run DD on Linux #9

Merged
merged 6 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 16 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

test-docker-desktop:
name: Test Docker Desktop installation and start
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest] #, macos-latest ]
timeout-minutes: 20
steps:
- uses: actions/checkout@v4

- name: Start Desktop
run: echo Hello Desktop
uses: ./start
timeout-minutes: 5

- name: Docker Desktop info
run: docker info

- name: Gather Diagnostics
if: ${{ failure() }}
run: /opt/docker-desktop/bin/com.docker.diagnose gather -upload
16 changes: 0 additions & 16 deletions .github/workflows/ci_linux.yaml

This file was deleted.

88 changes: 75 additions & 13 deletions start/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,41 @@ description: "Start Docker Desktop on a Github Action node"
runs:
using: "composite"
steps:
- name: Bloc calls to segment.io
id: redirect-segment
shell: bash
run: |
echo '127.0.0.2 api.segment.io' | sudo tee -a /etc/hosts

- name: Get Date
if: runner.os == 'macOS'
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash

- name: Get Docker app cache
- name: Get macOS Docker app cache
id: cache-docker-desktop-app
if: runner.os == 'macOS'
uses: actions/cache@v3
env:
cache-name: cache-docker-desktop-app
with:
path: /Applications/Docker.app
key: docker-desktop-app-mac-amd64-${{ steps.get-date.outputs.date }}

- name: Get Docker install settings cache
- name: Get macOS Docker install settings cache
id: cache-docker-desktop-install-settings
if: runner.os == 'macOS'
uses: actions/cache@v3
env:
cache-name: cache-docker-desktop-install-settings
with:
path: ./cache/desktopInstallSettings/
key: docker-desktop-install-settings-mac-${{ steps.get-date.outputs.date }}

- name: Bloc calls to segment.io
id: redirect-segment
shell: bash
run: |
echo '127.0.0.2 api.segment.io' | sudo tee -a /etc/hosts

- name: Copy Desktop install settings in /Library
if: steps.cache-docker-desktop-install-settings.outputs.cache-hit == 'true'
- name: Copy macOS Desktop install settings in /Library
if: runner.os == 'macOS' && steps.cache-docker-desktop-install-settings.outputs.cache-hit == 'true'
shell: bash
run: |
echo "ls ./cache/desktopInstallSettings/"
Expand All @@ -44,8 +47,8 @@ runs:
echo "/Library/Application Support/com.docker.docker/"
ls "/Library/Application Support/com.docker.docker/"

- name: Install Docker Desktop dmg
if: steps.cache-docker-desktop-install-settings.outputs.cache-hit != 'true'
- name: Install macOS Docker Desktop dmg
if: runner.os == 'macOS' && steps.cache-docker-desktop-install-settings.outputs.cache-hit != 'true'
shell: bash
run: |
sw_vers
Expand All @@ -67,7 +70,8 @@ runs:
/usr/bin/hdiutil detach ./mount/desktop
echo "dmg unmounted"

- name: Install Docker Desktop app
- name: Install macOS Docker Desktop app
if: runner.os == 'macOS'
shell: bash
run: |
sudo mkdir /Library/PrivilegedHelperTools
Expand All @@ -77,6 +81,64 @@ runs:
/usr/bin/open /Applications/Docker.app --args --unattended --add-host-docker-internal-registry
echo "Docker starting..."

- name: Cache Docker Desktop packages
if: runner.os == 'Linux'
id: cache-docker-desktop
uses: actions/cache@v3
with:
key: "docker-desktop-4.25.0-amd64"
path: |
~/downloads/

- name: Download Docker Desktop
if: runner.os == 'Linux' && ${{ steps.cache-docker-desktop.outputs.cache-hit != 'true' }}
shell: bash
run: |
mkdir -p ~/.downloads
curl -sSL https://desktop.docker.com/linux/main/amd64/docker-desktop-4.25.0-amd64.deb > ~/.downloads/docker-desktop.deb

- name: Check for CPU with VM support
if: runner.os == 'Linux'
shell: bash
run: egrep '(vmx|svm)' /proc/cpuinfo

# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
- name: Enable KVM group perms
if: runner.os == 'Linux'
shell: bash
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Install and Run Docker Desktop
if: runner.os == 'Linux'
shell: bash
run: |
sudo add-apt-repository universe
sudo apt update -y
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update -y
sudo apt remove moby-cli moby-compose moby-buildx
sudo apt install qemu-kvm
sudo apt install ~/.downloads/docker-desktop.deb qemu-kvm
mkdir -p ~/.docker/desktop
echo '{"settingsVersion": 30, "licenseTermsVersion": 2}' > ~/.docker/desktop/settings.json
docker context create desktop-linux --docker host=unix://${HOME}/.docker/desktop/docker.sock --description "Docker Desktop"
docker context use desktop-linux

systemctl --user start docker-desktop

until docker ps; do echo "docker not ready, sleep 10 s and try again"; sleep 10; done
echo "Docker started and ready"

- name: Wait for Docker to be up and running
shell: bash
run: |
Expand Down