From 50d06cf649f9acdd290d266a94a0438c937abf5f Mon Sep 17 00:00:00 2001 From: mariobassem Date: Tue, 14 Jan 2025 16:17:55 +0200 Subject: [PATCH] feat: support macos in ci --- ...hero_build_s3.yml => hero_build_linux.yml} | 64 +++++++----------- .github/workflows/hero_build_macos.yml | 66 +++++++++++++++++++ test_basic.vsh | 4 +- 3 files changed, 90 insertions(+), 44 deletions(-) rename .github/workflows/{hero_build_s3.yml => hero_build_linux.yml} (54%) create mode 100644 .github/workflows/hero_build_macos.yml diff --git a/.github/workflows/hero_build_s3.yml b/.github/workflows/hero_build_linux.yml similarity index 54% rename from .github/workflows/hero_build_s3.yml rename to .github/workflows/hero_build_linux.yml index e3eaa69e..63187346 100644 --- a/.github/workflows/hero_build_s3.yml +++ b/.github/workflows/hero_build_linux.yml @@ -1,4 +1,4 @@ -name: Build Hero & Run tests +name: Build Hero on Linux & Run tests permissions: contents: write @@ -22,7 +22,7 @@ jobs: # os: macos-latest # short-name: macos-arm64 # - target: x86_64-apple-darwin - # os: macos-latest + # os: macos-13 # short-name: macos-i64 runs-on: ${{ matrix.os }} steps: @@ -47,30 +47,24 @@ jobs: ln -s $GITHUB_WORKSPACE/lib ~/.vmodules/freeflowuniverse/herolib echo "Installing secp256k1..." - if [ "${{ matrix.os }}" = "macos-latest" ]; then - brew install secp256k1 - elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then - # Install build dependencies - sudo apt-get install -y build-essential wget autoconf libtool + # Install build dependencies + sudo apt-get install -y build-essential wget autoconf libtool - # Download and extract secp256k1 - cd /tmp - wget https://github.com/bitcoin-core/secp256k1/archive/refs/tags/v0.3.2.tar.gz - tar -xvf v0.3.2.tar.gz + # Download and extract secp256k1 + cd /tmp + wget https://github.com/bitcoin-core/secp256k1/archive/refs/tags/v0.3.2.tar.gz + tar -xvf v0.3.2.tar.gz - # Build and install - cd secp256k1-0.3.2/ - ./autogen.sh - ./configure - make -j 5 - sudo make install + # Build and install + cd secp256k1-0.3.2/ + ./autogen.sh + ./configure + make -j 5 + sudo make install + + # Cleanup + rm -rf secp256k1-0.3.2 v0.3.2.tar.gz - # Cleanup - rm -rf secp256k1-0.3.2 v0.3.2.tar.gz - else - echo "secp256k1 installation not implemented for ${OSNAME}" - exit 1 - fi echo "secp256k1 installation complete!" - name: Install and Start Redis @@ -82,32 +76,18 @@ jobs: # Install Redis sudo apt-get update sudo apt-get install -y redis + + # Start Redis + redis-server --daemonize yes + # Print versions redis-cli --version redis-server --version - # Start Redis - sudo systemctl start redis-server - redis-cli ping - name: Build Hero run: | - if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then - v -cg -enable-globals -w -n cli/hero.v - # else if [ "${{ matrix.os }}" = "macos-latest" ]; then - # v -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals cli/hero.v - fi + v -cg -enable-globals -w -n cli/hero.v - name: Do all the basic tests run: | - alias vtest='v -stats -enable-globals -n -w -cg -gc none -no-retry-compilation -cc tcc test' ./test_basic.vsh - - # - name: Upload to S3 - # run: | - # echo 'export S3KEYID=${{ secrets.S3KEYID }}' > ${HOME}/mysecrets.sh - # echo 'export S3APPID=${{ secrets.S3APPID }}' >> ${HOME}/mysecrets.sh - # set -e && cat ${HOME}/mysecrets.sh - # sudo bash +x scripts/githubactions.sh - - - name: Extract tag name - run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV diff --git a/.github/workflows/hero_build_macos.yml b/.github/workflows/hero_build_macos.yml new file mode 100644 index 00000000..22474fed --- /dev/null +++ b/.github/workflows/hero_build_macos.yml @@ -0,0 +1,66 @@ +name: Build Hero on Macos & Run tests + +permissions: + contents: write + +on: + push: + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + include: + - target: aarch64-apple-darwin + os: macos-latest + short-name: macos-arm64 + - target: x86_64-apple-darwin + os: macos-13 + short-name: macos-i64 + runs-on: ${{ matrix.os }} + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref_name }} and your repository is ${{ github.repository }}." + + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Setup Vlang + run: | + git clone --depth=1 https://github.com/vlang/v + cd v + make + sudo ./v symlink + cd .. + + - name: Setup Herolib + run: | + mkdir -p ~/.vmodules/freeflowuniverse + ln -s $GITHUB_WORKSPACE/lib ~/.vmodules/freeflowuniverse/herolib + + echo "Installing secp256k1..." + brew install secp256k1 + + echo "secp256k1 installation complete!" + + - name: Install and Start Redis + run: | + brew update + brew install redis + + # Start Redis + redis-server --daemonize yes + + # Print versions + redis-cli --version + redis-server --version + + - name: Build Hero + run: | + v -w -cg -gc none -no-retry-compilation -d use_openssl -enable-globals cli/hero.v + + - name: Do all the basic tests + run: | + ./test_basic.vsh diff --git a/test_basic.vsh b/test_basic.vsh index 6fd7f739..7f18f408 100755 --- a/test_basic.vsh +++ b/test_basic.vsh @@ -1,4 +1,4 @@ -#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run +#!/usr/bin/env -S v -cc gcc -n -w -gc none -no-retry-compilation -d use_openssl -enable-globals run import os import flag @@ -119,7 +119,7 @@ fn dotest(path string, base_dir string, mut cache TestCache) ! { return } - cmd := 'v -stats -enable-globals -n -w -gc none -no-retry-compilation -cc tcc test ${norm_path}' + cmd := 'v -stats -enable-globals -n -w -gc none -no-retry-compilation test ${norm_path}' println(cmd) result := os.execute(cmd) eprintln(result)