Skip to content

Instantly share code, notes, and snippets.

@catthehacker
Last active May 4, 2021 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catthehacker/68702214908bcb10a8977bef0b087ba3 to your computer and use it in GitHub Desktop.
Save catthehacker/68702214908bcb10a8977bef0b087ba3 to your computer and use it in GitHub Desktop.
Docker on macOS on GitHub Actions taken from https://github.com/nektos/act
test-macos:
name: Test on MacOS
runs-on: macos-latest
continue-on-error: true # Don't let macos test fail whole workflow
env:
ISO_PATH: ~/.docker/machine/cache/boot2docker.iso
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.16
- uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/cache@v2
with:
key: boot2docker
path: ${{ env.ISO_PATH }}
restore-keys: boot2docker
- name: Install Docker on macOS
run: |
printf " ๐Ÿ› ๏ธ Downloading boot2docker.iso ๐Ÿ› ๏ธ \n\n"
mkdir -p ~/.docker/machine/cache/
test -f ${{ env.ISO_PATH }} && printf " ๐Ÿ› ๏ธ ${{ env.ISO_PATH }} successfully restored ๐Ÿ› ๏ธ \n\n" || wget "https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso" -O ${{ env.ISO_PATH }}
printf " ๐Ÿ› ๏ธ Installing Docker from Homebrew ๐Ÿ› ๏ธ \n\n"
brew install docker docker-machine
printf " ๐Ÿ› ๏ธ Creating Docker VM ๐Ÿ› ๏ธ \n\n"
docker-machine create --driver virtualbox --virtualbox-boot2docker-url ${{ env.ISO_PATH }} default
docker-machine env default
printf " ๐Ÿ› ๏ธ Adding Docker VM info to environment ๐Ÿ› ๏ธ \n\n"
eval "$(docker-machine env default)"
echo "DOCKER_TLS_VERIFY=$DOCKER_TLS_VERIFY" | tee -a $GITHUB_ENV
echo "DOCKER_HOST=$DOCKER_HOST" | tee -a $GITHUB_ENV
echo "DOCKER_CERT_PATH=$DOCKER_CERT_PATH" | tee -a $GITHUB_ENV
echo "DOCKER_MACHINE_NAME=$DOCKER_MACHINE_NAME" | tee -a $GITHUB_ENV
printf " ๐Ÿ› ๏ธ Install Qemu for running containers with different architecture ๐Ÿ› ๏ธ \n\n"
docker run --rm --privileged tonistiigi/binfmt --install all
printf " ๐Ÿ› ๏ธ Finished installing Docker ๐Ÿ› ๏ธ \n\n"
- run: go test -v -timeout 30m -cover ./...
env:
CGO_ENABLED: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment