Skip to content

Skip running the tests #1

Skip running the tests

Skip running the tests #1

Workflow file for this run

name: macOS
on:
push:
branches:
- release/*
- feature/*
- develop
- main
- kotlin-deploy
- DO-1622-split-ci
jobs:
build:
runs-on: macos-latest
continue-on-error: true
strategy:
matrix:
build-target:
# radix-engine-toolkit Crate
- crate: radix-engine-toolkit
target-triple: aarch64-apple-darwin
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
- crate: radix-engine-toolkit
target-triple: x86_64-apple-ios
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
- crate: radix-engine-toolkit
target-triple: x86_64-apple-darwin
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
- crate: radix-engine-toolkit
target-triple: aarch64-apple-ios
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
- crate: radix-engine-toolkit
target-triple: aarch64-apple-ios-sim
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
# radix-engine-toolkit-uniffi Crate
- crate: radix-engine-toolkit-uniffi
target-triple: aarch64-apple-darwin
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
- crate: radix-engine-toolkit-uniffi
target-triple: x86_64-apple-ios
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
- crate: radix-engine-toolkit-uniffi
target-triple: x86_64-apple-darwin
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
- crate: radix-engine-toolkit-uniffi
target-triple: aarch64-apple-ios
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
- crate: radix-engine-toolkit-uniffi
target-triple: aarch64-apple-ios-sim
custom-linker: ""
custom-compiler: /usr/local/opt/llvm/bin/clang
custom-archiver: /usr/local/opt/llvm/bin/llvm-ar
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- name: Checkout
uses: actions/checkout@v3
- name: Install Build Dependencies
run: brew install llvm
- name: Install Rust Toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup.sh
chmod +x rustup.sh
./rustup.sh -y
rustup update
rustup toolchain install nightly
- name: Install Rust Targets
run: |
rustup target install ${{ matrix.build-target.target-triple }}
rustup +nightly target install ${{ matrix.build-target.target-triple }}
rustup component add rust-src --toolchain nightly-x86_64-apple-darwin
- name: Building Toolkit
run: |
(
export CURRENT_DIRECTORY=$(pwd)
export CRATE_PATH="$CURRENT_DIRECTORY/${{matrix.build-target.crate}}"
cd $CRATE_PATH
export LINKER_ENVIRONMENT_VARIABLE="CARGO_TARGET_"$(echo ${{ matrix.build-target.target-triple }} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g')"_LINKER"
if [ ! -z "${{ matrix.build-target.custom-linker }}" ]
then
export $LINKER_ENVIRONMENT_VARIABLE=${{ matrix.build-target.custom-linker }}
fi
export CC=${{ matrix.build-target.custom-compiler }}
export AR=${{ matrix.build-target.custom-archiver }}
cargo +nightly build \
-Z build-std=std,panic_abort \
-Z build-std-features=panic_immediate_abort \
--target ${{ matrix.build-target.target-triple }} \
--release
unset $LINKER_ENVIRONMENT_VARIABLE
export CC="/usr/local/opt/llvm/bin/clang"
export AR="/usr/local/opt/llvm/bin/llvm-ar"
if [ "${{matrix.build-target.crate}}" == "radix-engine-toolkit" ]; then
INCLUDE_DIRECTORY_PATH="$CRATE_PATH/target/${{ matrix.build-target.target-triple }}/release/include"
mkdir $INCLUDE_DIRECTORY_PATH
rustup default nightly
cbindgen \
--lang c \
--config cbindgen.toml \
--output "$INCLUDE_DIRECTORY_PATH/libradix_engine_toolkit.h"
rustup default stable
echo "module RadixEngineToolkit {" > "$INCLUDE_DIRECTORY_PATH/module.modulemap"
echo " umbrella header \"libradix_engine_toolkit.h\"" >> "$INCLUDE_DIRECTORY_PATH/module.modulemap"
echo " export *" >> "$INCLUDE_DIRECTORY_PATH/module.modulemap"
echo "}" >> "$INCLUDE_DIRECTORY_PATH/module.modulemap"
fi
(
BUILD_PATH="$CRATE_PATH/target/${{ matrix.build-target.target-triple }}/release"
cd $BUILD_PATH
BUILD_ARTIFACTS_PATH=$(find . -type f \( -name "*.a" -o -name "*.dylib" -o -name "*.dll" -o -name "*.so" -o -name "*.d" -o -name "*.wasm" \) -maxdepth 1)
if [ "${{matrix.build-target.crate}}" == "radix-engine-toolkit" ]; then
tar -czf "./${{ matrix.build-target.target-triple }}.tar.gz" $BUILD_ARTIFACTS_PATH ./include
else
tar -czf "./${{ matrix.build-target.target-triple }}.tar.gz" $BUILD_ARTIFACTS_PATH
fi
)
)
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: "${{ matrix.build-target.crate }}-${{ matrix.build-target.target-triple }}"
path: "./${{matrix.build-target.crate}}/target/${{ matrix.build-target.target-triple }}/release/${{ matrix.build-target.target-triple }}.tar.gz"
create-uniffi-bindings:
needs: [build]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Clone uniffi-bindgen-cs
uses: actions/checkout@v3
with:
repository: radixdlt/uniffi-bindgen-cs
path: uniffi-bindgen-cs
submodules: 'recursive'
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: Extracting the Library
run: |
mkdir extracted
cd radix-engine-toolkit-uniffi-x86_64-apple-darwin
tar -xvzf x86_64-apple-darwin.tar.gz --directory="../extracted"
working-directory: artifacts
- name: Generate the Bindings
run: |
cargo run \
--manifest-path="../../uniffi-bindgen/Cargo.toml" -- \
generate ../../radix-engine-toolkit-uniffi/src/radix_engine_toolkit_uniffi.udl \
--language swift \
--out-dir ./output \
--lib-file ./libradix_engine_toolkit_uniffi.a
cargo run \
--manifest-path="../../uniffi-bindgen/Cargo.toml" -- \
generate ../../radix-engine-toolkit-uniffi/src/radix_engine_toolkit_uniffi.udl \
--language kotlin \
--out-dir ./output \
--lib-file ./libradix_engine_toolkit_uniffi.a
cargo run \
--manifest-path="../../uniffi-bindgen/Cargo.toml" -- \
generate ../../radix-engine-toolkit-uniffi/src/radix_engine_toolkit_uniffi.udl \
--language python \
--out-dir ./output \
--lib-file ./libradix_engine_toolkit_uniffi.a
cargo run \
--manifest-path="../../uniffi-bindgen-cs/bindgen/Cargo.toml" -- \
../../radix-engine-toolkit-uniffi/src/radix_engine_toolkit_uniffi.udl \
--out-dir ./output \
--lib-file ./libradix_engine_toolkit_uniffi.dylib
working-directory: artifacts/extracted
- name: Compress Artifacts
run: |
tar -czf "./UniFFI-Bindings.tar.gz" ./output
working-directory: artifacts/extracted
- name: Upload Bindings
uses: actions/upload-artifact@v3
with:
name: "UniFFI-Bindings"
path: "./artifacts/extracted/UniFFI-Bindings.tar.gz"
build-test-kit:
needs: [build]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run Generator
run: cargo run
working-directory: generator
- name: Compress Generated
run: tar -czf "./test-kit.tar.gz" ./output
working-directory: generator
- name: Upload Generated Artifacts
uses: actions/upload-artifact@v3
with:
name: "test-kit.tar.gz"
path: "./generator/test-kit.tar.gz"
publish-swift-spm:
needs: [build, create-uniffi-bindings]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout Swift Egine toolkit
uses: actions/checkout@v3
with:
repository: radixdlt/swift-engine-toolkit
token: ${{ secrets.RADIX_BOT_PAT }}
path: ./swift-engine-toolkit
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: Build XCFramework
working-directory: artifacts
run: |
# The name of the crate that we will be creating the XCFramework and the bindings for.
CRATE_NAME="radix-engine-toolkit-uniffi"
# The name of the directory to write the extracted libraries in.
EXTRACTED="extracted"
mkdir $EXTRACTED
# Extract the UniFFI Bindings
mkdir $EXTRACTED/UniFFI-Bindings
tar -xvzf "UniFFI-Bindings/UniFFI-Bindings.tar.gz" --directory="./$EXTRACTED/UniFFI-Bindings"
# Creating the include directory - this will be used in the XCFramework build steps
mkdir $EXTRACTED/include
cp $EXTRACTED/UniFFI-Bindings/output/radix_engine_toolkit_uniffiFFI.modulemap $EXTRACTED/include/module.modulemap
cp $EXTRACTED/UniFFI-Bindings/output/radix_engine_toolkit_uniffiFFI.h $EXTRACTED/include/radix_engine_toolkit_uniffiFFI.h
# Extract the builds of the targets that we need. All of them have a common known pattern which
# we depend on for the extraction: `${CRATE_NAME}-${TARGET_TRIPLE}`.
for TARGET_TRIPLE in "aarch64-apple-darwin" "x86_64-apple-darwin" "aarch64-apple-ios-sim" "x86_64-apple-ios" "aarch64-apple-ios"
do
# Create a new directory for the target
mkdir $EXTRACTED/$TARGET_TRIPLE;
BUILD_ARTIFACT="$CRATE_NAME-$TARGET_TRIPLE"
tar -xvzf "$BUILD_ARTIFACT/$TARGET_TRIPLE.tar.gz" --directory="./$EXTRACTED/$TARGET_TRIPLE"
done
rm -rf ./$EXTRACTED/*.tar.gz
# Using Lipo to combine some of the libraries into fat libraries.
mkdir ./$EXTRACTED/macos-arm64_x86_64/
mkdir ./$EXTRACTED/ios-simulator-arm64_x86_64
lipo -create \
"./$EXTRACTED/aarch64-apple-darwin/libradix_engine_toolkit_uniffi.dylib" \
"./$EXTRACTED/x86_64-apple-darwin/libradix_engine_toolkit_uniffi.dylib" \
-o "./$EXTRACTED/macos-arm64_x86_64/libradix_engine_toolkit_uniffi.dylib"
lipo -create \
"./$EXTRACTED/aarch64-apple-ios-sim/libradix_engine_toolkit_uniffi.dylib" \
"./$EXTRACTED/x86_64-apple-ios/libradix_engine_toolkit_uniffi.dylib" \
-o "./$EXTRACTED/ios-simulator-arm64_x86_64/libradix_engine_toolkit_uniffi.dylib"
# Set proper id, so that Xcode can properly locate the dynamic library
install_name_tool -id @rpath/libradix_engine_toolkit_uniffi.dylib ./$EXTRACTED/aarch64-apple-ios/libradix_engine_toolkit_uniffi.dylib
install_name_tool -id @rpath/libradix_engine_toolkit_uniffi.dylib ./$EXTRACTED/macos-arm64_x86_64/libradix_engine_toolkit_uniffi.dylib
install_name_tool -id @rpath/libradix_engine_toolkit_uniffi.dylib ./$EXTRACTED/ios-simulator-arm64_x86_64/libradix_engine_toolkit_uniffi.dylib
# Creating the XCFramework
xcodebuild -create-xcframework \
-library "./$EXTRACTED/aarch64-apple-ios/libradix_engine_toolkit_uniffi.dylib" \
-headers "./$EXTRACTED/include" \
-library "./$EXTRACTED/macos-arm64_x86_64/libradix_engine_toolkit_uniffi.dylib" \
-headers "./$EXTRACTED/include" \
-library "./$EXTRACTED/ios-simulator-arm64_x86_64/libradix_engine_toolkit_uniffi.dylib" \
-headers "./$EXTRACTED/include" \
-output "./$EXTRACTED/RadixEngineToolkit.xcframework"
- name: Publish to Swift Engine Toolkit
run: |
BRANCH=${{ github.ref_name }}
BUILD_CRATE_MANIFEST="./radix-engine-toolkit-uniffi/Cargo.toml"
CRATE_VERSION=$(cargo read-manifest --manifest-path $BUILD_CRATE_MANIFEST | jq -r '.version')
LAST_COMMIT_SHA=$(git rev-parse --short HEAD)
SPM_VERSION="$CRATE_VERSION-$LAST_COMMIT_SHA"
SET_UPSTREAM_FLAG=""
cd swift-engine-toolkit
REMOTE_BRANCH=$(git ls-remote --heads origin $BRANCH)
if [ -z "$REMOTE_BRANCH" ]
then
git checkout -b $BRANCH
# Allows creating branch on remote
SET_UPSTREAM_FLAG="-u"
else
git fetch origin $BRANCH
git checkout $BRANCH
git pull origin $BRANCH
fi
cp -R ../artifacts/extracted/RadixEngineToolkit.xcframework ./Sources/RadixEngineToolkit
cp -R ../artifacts/extracted/UniFFI-Bindings/output/radix_engine_toolkit_uniffi.swift ./Sources/EngineToolkit/radix_engine_toolkit_uniffi.swift
git add .
git commit -m "Update RET from $BRANCH - $LAST_COMMIT_SHA"
git tag -a $SPM_VERSION -m "RET update from $BRANCH - $LAST_COMMIT_SHA"
git push $SET_UPSTREAM_FLAG origin $BRANCH
git push origin $SPM_VERSION
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: "RadixEngineToolkit.xcframework"
path: "./artifacts/extracted/RadixEngineToolkit.xcframework"