Skip to content

Added arm64 to build and test #1

Added arm64 to build and test

Added arm64 to build and test #1

name: Reusable Build and Test
on:
workflow_call:
inputs:
test_linux:
type: boolean
default: true
description: "Run Linux Build and Test"
test_windows:
type: boolean
default: true
description: "Run Windows Build and Test"
test_macintosh:
type: boolean
default: true
description: "Run Mac OS Build"
build_source_dist:
type: boolean
default: true
description: "Build Source Distribution"
upload_artifacts:
type: boolean
default: true
description: "Upload Artifacts"
version:
required: false
type: string
jobs:
build_and_test_linux:
if: ${{ inputs.test_linux }}
name: "Build and test on Linux 👍"
strategy:
fail-fast: false
matrix:
include:
- {platform: 'ubuntu-24.04', python_version: '3.10', mgversion: 'latest', arch: 'x86_64'}
- {platform: 'ubuntu-24.04', python_version: '3.11', mgversion: 'latest', arch: 'x86_64'}
- {platform: 'ubuntu-24.04', python_version: '3.12', mgversion: 'latest', arch: 'x86_64'}
- {platform: 'ubuntu-24.04', python_version: '3.13', mgversion: 'latest', arch: 'x86_64'}
- {platform: 'ubuntu-24.04', python_version: '3.14', mgversion: 'latest', arch: 'x86_64'}
- {platform: 'fedora-42', python_version: '3.13', mgversion: 'latest', arch: 'x86_64'}
- {platform: 'ubuntu-24.04', python_version: '3.12', mgversion: 'latest', arch: 'aarch64'}

Check failure on line 45 in .github/workflows/reusable_buildtest.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/reusable_buildtest.yml

Invalid workflow file

You have an error in your yaml syntax on line 45
runs-on: [self-hosted, ${{ matrix.arch == 'x86_64' && 'X64' || 'ARM64' }}]
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set Memgraph Version
run: |
if [[ "${{ matrix.mgversion }}" == "latest" ]]; then
mgversion=$(./tools/get_memgraph_version.sh)
else
mgversion="${{ matrix.mgversion }}"
fi
echo "MGVERSION=$mgversion" >> $GITHUB_ENV
- name: Download Memgraph
run: |
if [[ "${{ matrix.platform }}" == "fedora-42" ]]; then
MEMGRAPH_PACKAGE_NAME="memgraph-${{ env.MGVERSION }}_1-1.${{ matrix.arch }}.rpm"
LOCAL_PACKAGE_NAME=memgraph.rpm
else
MEMGRAPH_PACKAGE_NAME="memgraph_${{ env.MGVERSION }}-1_${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}.deb"
LOCAL_PACKAGE_NAME=memgraph.deb
fi
curl -L "https://download.memgraph.com/memgraph/v${{ env.MGVERSION }}/${{ matrix.platform }}/${MEMGRAPH_PACKAGE_NAME}" > "${LOCAL_PACKAGE_NAME}"
echo "LOCAL_PACKAGE_NAME=$LOCAL_PACKAGE_NAME" >> $GITHUB_ENV
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Launch Docker Container
run: |
platform="${{ matrix.platform }}"
tag=${platform//-/:}
if [[ "${{ inputs.version }}" != "" ]]; then
echo "Building version ${{ inputs.version }}"
docker run -d --rm \
-e PYMGCLIENT_OVERRIDE_VERSION=${{ inputs.version }} \
--name testcontainer "$tag" sleep infinity
else
docker run -d --rm --name testcontainer "$tag" sleep infinity
fi
- name: Set Environment Variables
run: |
break_packages=""
static_ssl=""
if [[ "${{ matrix.platform }}" == "ubuntu-24.04" ]]; then
# this option is specific to ubuntu, not fedora
break_packages="--break-system-packages"
elif [[ "${{ matrix.platform }}" == fedora* ]]; then
# rpm distros do not ship with static lib for openssl
static_ssl="build_ext --static-openssl=False"
fi
echo "BREAK_PACKAGES=$break_packages" >> $GITHUB_ENV
echo "STATIC_SSL=$static_ssl" >> $GITHUB_ENV
- name: Copy Repo Into Container
run: |
docker cp . testcontainer:/pymgclient
- name: Install system dependencies
run: |
docker cp $LOCAL_PACKAGE_NAME testcontainer:/$LOCAL_PACKAGE_NAME
# Prevents Memgraph from starting.
docker exec -i testcontainer \
bash -c "mkdir -p /etc/systemd/system && ln -s /dev/null /etc/systemd/system/memgraph.service"
# Install dependencies
docker exec -i testcontainer \
bash -c "cd /pymgclient && ./tools/install_linux_deps.sh ${{ matrix.platform }} --python-version ${{ matrix.python_version }} --force-update"
# Install Memgraph package
if [[ "${{ matrix.platform }}" == "fedora-42" ]]; then
docker exec -i testcontainer \
bash -c "dnf install -y /$LOCAL_PACKAGE_NAME"
else
docker exec -i testcontainer \
bash -c "dpkg -i /$LOCAL_PACKAGE_NAME"
fi
rm -v $LOCAL_PACKAGE_NAME
- name: Build Python Wheel
run: |
docker exec -i testcontainer \
bash -c "cd /pymgclient && python${{ matrix.python_version }} setup.py ${{ env.STATIC_SSL }} bdist_wheel"
- name: Audit Wheel
if: ${{ matrix.platform == 'ubuntu-24.04' }}
run: |
docker exec -i testcontainer \
bash -c "cd /pymgclient && auditwheel repair dist/*.whl --plat manylinux_2_39_${{ matrix.arch == 'x86_64' && 'x86_64' || 'aarch64' }} -w dist/ && rm dist/*linux_${{ matrix.arch == 'x86_64' && 'x86_64' || 'aarch64' }}.whl"
- name: Install pymgclient
run: |
docker exec -i testcontainer \
bash -c "python${{ matrix.python_version }} -m pip install ./pymgclient/dist/pymgclient-* ${{ env.BREAK_PACKAGES }}"
- name: Import mgclient to validate installation
run: |
docker exec -i testcontainer \
bash -c "python${{ matrix.python_version }} -c 'import mgclient'"
- name: Run tests
run: |
MEMGRAPH_PORT=10000 # what's this for?
docker exec -i testcontainer \
bash -c "cd /pymgclient && python${{ matrix.python_version }} -m pytest -v"
- name: Build docs
run: |
docker exec -i testcontainer \
bash -c "cd /pymgclient/docs && make html"
- name: Copy Package
run: |
docker cp testcontainer:/pymgclient/dist .
- name: Save source distribution package
if: ${{ inputs.upload_artifacts && matrix.platform == 'ubuntu-24.04' }}
uses: actions/upload-artifact@v4
with:
name: pymgclient-linux-${{ matrix.python_version }}
path: dist/
- name: Cleanup
if: always()
run: |
docker stop testcontainer || echo "Container does not exist"
docker wait testcontainer || echo "Container does not exist"
docker rmi ${{ env.MGVERSION }} || echo "Image does not exist"
build_source_dist:
if: ${{ inputs.build_source_dist }}
name: Build Source Distribution
runs-on: [self-hosted, X64, Ubuntu24.04]
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set override version if provided
if: ${{ inputs.version != '' }}
run: |
echo "Building version ${{ inputs.version }}"
echo "PYMGCLIENT_OVERRIDE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
- name: Create Python Virtual Environment
run: |
python3 -m venv env
source env/bin/activate
pip install setuptools wheel
- name: Build Python Source Distribution
run: |
source env/bin/activate
python setup.py sdist
- name: Save source distribution package
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@v4
with:
name: pymgclient-linux-sdist
path: dist
- name: Cleanup
if: always()
run: |
rm -fr env || true
rm -fr dist || true
build_and_test_windows:
if: ${{ inputs.test_windows }}
name: Build and Test on Windows
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2025]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Set override version if provided
if: ${{ inputs.version != '' }}
shell: bash
run: |
echo "Building version ${{ inputs.version }}"
echo "PYMGCLIENT_OVERRIDE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
install: >
git
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-make
mingw-w64-x86_64-openssl
- name: Add MSYS2 mingw64/bin to PATH
shell: msys2 {0}
run: |
echo "/mingw64/bin" >> $GITHUB_PATH
- name: Set up Windows Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Add Windows Python to PATH
shell: msys2 {0}
run: |
echo "$pythonLocation" >> $GITHUB_PATH
env:
pythonLocation: ${{ env.pythonLocation }}
- name: Install Python build tools
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$pythonLocation"):$PATH"
python -m pip install --upgrade pip setuptools wheel pyopenssl pytest tzdata
env:
pythonLocation: ${{ env.pythonLocation }}
- name: Build pymgclient Wheel
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$pythonLocation"):$PATH"
python setup.py bdist_wheel
env:
pythonLocation: ${{ env.pythonLocation }}
- name: Install built wheel
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$pythonLocation"):$PATH"
python -m pip install dist/*.whl
env:
pythonLocation: ${{ env.pythonLocation }}
- name: Setup WSL Ubuntu
uses: Vampire/setup-wsl@v5
with:
distribution: Ubuntu-24.04
- name: Set Memgraph Version
shell: bash -l {0}
run: |
mgversion=$(./tools/get_memgraph_version.sh)
echo "MGVERSION=$mgversion" >> $GITHUB_ENV
- name: Install and Run Memgraph in WSL
shell: wsl-bash {0}
run: |
mkdir -p $HOME/memgraph/data
sudo apt update
sudo apt install -y curl
curl -L https://download.memgraph.com/memgraph/v${{ env.MGVERSION }}/ubuntu-24.04/memgraph_${{ env.MGVERSION }}-1_amd64.deb -o memgraph.deb
sudo mkdir -p /etc/systemd/system && sudo ln -s /dev/null /etc/systemd/system/memgraph.service # Prevents Memgraph from starting.
sudo apt install ./memgraph.deb
openssl req -x509 -newkey rsa:4096 -days 3650 -nodes -keyout key.pem -out cert.pem -subj "/C=GB/ST=London/L=London/O=Testing Corp./CN=PymgclientTest"
nohup /usr/lib/memgraph/memgraph --bolt-port 7687 --bolt-cert-file="cert.pem" --bolt-key-file="key.pem" --data-directory="~/memgraph/data" --storage-properties-on-edges=true --storage-snapshot-interval-sec=0 --storage-wal-enabled=false --storage-snapshot-on-exit=false --telemetry-enabled=false --log-file='' &
# sleep here instead of using script because it just doesn't work in Windows
sleep 3
# sed $'s/\r$//' ./tools/wait_for_memgraph.sh > ./tools/wait_for_memgraph.unix.sh
# bash ./tools/wait_for_memgraph.unix.sh localhost
- name: Run Tests
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$pythonLocation"):/mingw64/bin:$PATH"
echo $PATH
python -m pytest -v
env:
pythonLocation: ${{ env.pythonLocation }}
MEMGRAPH_HOST: localhost
MEMGRAPH_STARTED_WITH_SSL:
- name: Upload Wheel Artifact
if: ${{ inputs.upload_artifacts && matrix.os == 'windows-2025' }}
uses: actions/upload-artifact@v4
with:
name: pymgclient-win-${{ matrix.python-version }}
path: dist/
# NOTE: Cannot run tests on Mac OS runners because:
# - GitHub hosted runners don't have docker
# - self-hosted runner unable to log in to docker due to requiring a password to unlock the keychain
# Also - github hosted macos runners after macos-13 are all arm64
build_macos:
if: ${{ inputs.test_macintosh }}
name: Build and test on MacOS
strategy:
fail-fast: false
matrix:
platform: [macos-15]
python_version:
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- '3.14'
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set override version if provided
if: ${{ inputs.version != '' }}
run: |
echo "Building version ${{ inputs.version }}"
echo "PYMGCLIENT_OVERRIDE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
- name: Install python and OpenSSL
run: |
brew install python@${{ matrix.python_version }} openssl@1.1
brew link --force --overwrite openssl@1.1
openssl version -a
- name: Manage OpenSSL 3 on ARM machines
if: ${{ contains(matrix.platform, 'ARM64') }}
run: |
brew install openssl@3
brew link --force --overwrite openssl@3
openssl version -a
- name: Make used python version default
run: |
brew unlink python@3 && brew link --force python@${{ matrix.python_version }}
python${{ matrix.python_version }} --version
- name: Create Virtual Env
run: |
python${{ matrix.python_version }} -m venv env
- name: Install pytest and pyopenssl
run: |
export PIP_BREAK_SYSTEM_PACKAGES=1
source env/bin/activate
python${{ matrix.python_version }} -m pip install pyopenssl pytest setuptools
- name: Build pymgclient
run: |
source env/bin/activate
python${{ matrix.python_version }} setup.py bdist_wheel
- name: Install pymgclient
run: |
export PIP_BREAK_SYSTEM_PACKAGES=1
source env/bin/activate
python${{ matrix.python_version }} -m pip install dist/*
- name: Import mgclient to validate installation
run: |
source env/bin/activate
python${{ matrix.python_version }} -c "import mgclient"
- name: Save wheel package
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@v4
with:
name: pymgclient-${{ matrix.platform[0] || matrix.platform }}-${{ matrix.python_version }}
path: dist/