feat: add a ci for running smoke tests under macos runner #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Copyright (C) 2023-2024 Hedera Hashgraph, LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
## | |
name: "PR Checks macos" | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
push: | |
branches: | |
- main | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: read | |
concurrency: | |
group: pr-checks-${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
smoke-tests: | |
name: Smoke Tests | |
runs-on: macos-13 | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: [20.x] | |
steps: | |
- name: OS safety check | |
if: runner.os != 'macOS' | |
run: | | |
echo "Not a macOS runner, exiting." | |
exit 1 | |
shell: bash | |
- name: ARM64 safety check | |
run: | | |
arch_name=$(uname -m) | |
if [ "$arch_name" = "arm64" ] | |
then | |
echo "Detected M-series processor runner without nested virtualization support, exiting." | |
exit 1 | |
else | |
echo "Running on supported architecture: ${arch_name}" | |
fi | |
shell: bash | |
- name: Update Homebrew | |
run: | | |
echo "::group::Updating Homebrew" | |
brew update --preinstall | |
echo "::endgroup::" | |
shell: bash | |
- name: Install Lima | |
env: | |
GH_TOKEN: ${{ github.token }} | |
INPUT_LIMA: latest | |
run: | | |
if [ $INPUT_LIMA == "latest" ] | |
then | |
LIMA_VERSION=$(gh release -R lima-vm/lima view --json tagName -q ".tagName") | |
else | |
LIMA_VERSION=$INPUT_LIMA | |
fi | |
echo "::group::Installing Lima version $LIMA_VERSION" | |
curl -fsSL "https://github.com/lima-vm/lima/releases/download/${LIMA_VERSION}/lima-${LIMA_VERSION:1}-$(uname -s)-$(uname -m).tar.gz" | tar Cxzvm /usr/local | |
echo "::endgroup::" | |
shell: bash | |
- name: Install Colima | |
env: | |
GH_TOKEN: ${{ github.token }} | |
INPUT_COLIMA: latest | |
run: | | |
if [ $INPUT_COLIMA == "latest" ] | |
then | |
COLIMA_VERSION=$(gh release -R abiosoft/colima view --json tagName -q ".tagName") | |
else | |
COLIMA_VERSION=$INPUT_COLIMA | |
fi | |
echo "::group::Installing Colima version $COLIMA_VERSION" | |
curl -LO https://github.com/abiosoft/colima/releases/download/${COLIMA_VERSION}/colima-$(uname)-$(uname -m) | |
# install in $PATH | |
install colima-$(uname)-$(uname -m) /usr/local/bin/colima | |
echo "::endgroup::" | |
shell: bash | |
- name: Workaround for Python conflicts in GHA Runners | |
env: | |
HOMEBREW_NO_AUTO_UPDATE: "1" | |
HOMEBREW_NO_INSTALL_UPGRADE: "1" | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1" | |
run: | | |
brew unlink python@3 || true | |
brew uninstall --ignore-dependencies python@3 || true | |
brew install --overwrite --force python@3 | |
shell: bash | |
- name: Install QEMU, Docker client, and Docker Compose | |
env: | |
HOMEBREW_NO_AUTO_UPDATE: "1" | |
HOMEBREW_NO_INSTALL_UPGRADE: "1" | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1" | |
run: | | |
echo "::group::Installing QEMU, Docker client, and Docker Compose" | |
brew install docker docker-compose | |
# Installing QEMU 9.0.2 as a temporary workaround. Version 9.1.0 seems to be broken with Lima/Colima at the moment. | |
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/f1a9cf104a9a51779c7a532b658c490f69974839/Formula/q/qemu.rb | |
brew install qemu.rb 2>&1 | tee install.log | |
echo "::endgroup::" | |
shell: bash | |
- name: Configure Docker Compose plugin | |
run: | | |
mkdir -p ~/.docker/cli-plugins | |
ln -sfn "$(brew --prefix)/opt/docker-compose/bin/docker-compose" ~/.docker/cli-plugins/docker-compose | |
shell: bash | |
- name: Start Colima | |
env: | |
COLIMA_NETWORK_ADDRESS: true | |
run: | | |
CPU_COUNT=$(sysctl -n hw.ncpu) | |
MEMORY=$(sysctl hw.memsize | awk '{print $2/1024/1024/1024}') | |
COLIMA_ARGS="--cpu 6 --memory 8 --arch x86_64" | |
if [ $COLIMA_NETWORK_ADDRESS == "true" ] | |
then | |
COLIMA_ARGS="$COLIMA_ARGS --network-address" | |
fi | |
echo "::group::Starting Colima with args: $COLIMA_ARGS" | |
colima start $COLIMA_ARGS | |
echo "::endgroup::" | |
shell: bash | |
- id: docker-client-version | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "version<<$EOF" >> "$GITHUB_OUTPUT" | |
docker version >> "$GITHUB_OUTPUT" | |
echo "$EOF" >> "$GITHUB_OUTPUT" | |
shell: bash | |
- id: docker-compose-version | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "version<<$EOF" >> "$GITHUB_OUTPUT" | |
docker compose version >> "$GITHUB_OUTPUT" | |
echo "$EOF" >> "$GITHUB_OUTPUT" | |
shell: bash | |
- id: colima-version | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "version<<$EOF" >> "$GITHUB_OUTPUT" | |
colima version >> "$GITHUB_OUTPUT" | |
echo "$EOF" >> "$GITHUB_OUTPUT" | |
shell: bash | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 |