-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
160 additions
and
209 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,161 +1,50 @@ | ||
name: Build and Test | ||
name: "CI" | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'chore/**' | ||
- 'docs/**' | ||
- 'feat/**' | ||
- 'feature/**' | ||
- 'fix/**' | ||
- 'refactor/**' | ||
- 'releases/**' | ||
- 'style/**' | ||
- 'test/**' | ||
- 'tech/**' | ||
|
||
env: | ||
RUST_TARGET_PATH: pact-reference/rust/target | ||
BINARIES_PATH: Resources | ||
- 'legacy/**' | ||
|
||
jobs: | ||
build: | ||
name: "Prepare libpact_ffi binaries" | ||
runs-on: macos-11 | ||
timeout-minutes: 60 | ||
test: | ||
name: "Build & Test" | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: true | ||
|
||
concurrency: | ||
group: build-macos11-${{ github.ref }} | ||
group: pactswiftmockserver-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
steps: | ||
- name: "♻️ Checkout repository" | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- uses: fwal/setup-swift@v1 | ||
- name: "Check swift version" | ||
run: swift --version | ||
|
||
- name: "♼ Cache rust binaries" | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ env.RUST_TARGET_PATH }} | ||
${{ env.BINARIES_PATH }} | ||
key: build-${{ runner.os }}-rust-${{ hashFiles('**/libpact_ffi.version') }} | ||
restore-keys: | | ||
build-${{ runner.os }}-rust- | ||
- name: "🔍 Check if binaries exist in ${{ env.BINARIES_PATH }}" | ||
id: check_files | ||
uses: andstor/file-existence-action@v1 | ||
with: | ||
files: "Resources/**/libpact_ffi.a" | ||
|
||
- name: "🎁 Prepare binaries (if not cached)" | ||
if: steps.check_files.outputs.files_exist == 'false' | ||
run: | | ||
Support/build_rust_dependencies | ||
- name: "⬇️ Checkout repository" | ||
uses: actions/checkout@v4 | ||
|
||
testMacOS11: | ||
name: "Test macOS 11" | ||
runs-on: macos-11 | ||
needs: [build] | ||
|
||
concurrency: | ||
group: test-${{ github.ref }}-${{ matrix.scheme }} | ||
cancel-in-progress: true | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
include: | ||
- scheme: "PactSwiftMockServer-iOS" | ||
destination: "platform=iOS Simulator,name=iPhone 12 Pro" | ||
- scheme: "PactSwiftMockServer-macOS" | ||
destination: "arch=x86_64" | ||
|
||
env: | ||
SCHEME: ${{ matrix.scheme }} | ||
DESTINATION: ${{ matrix.destination }} | ||
|
||
steps: | ||
- name: "♻️ Checkout repository" | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- name: "Install Protoc" | ||
uses: arduino/setup-protoc@v1 | ||
|
||
- name: "♼ Cache rust binaries" | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ env.RUST_TARGET_PATH }} | ||
${{ env.BINARIES_PATH }} | ||
key: build-${{ runner.os }}-rust-${{ hashFiles('**/libpact_ffi.version') }} | ||
pact-reference | ||
key: build-${{ runner.os }}-rust-bin-${{ hashFiles('**/libpact_ffi.version') }} | ||
restore-keys: | | ||
build-${{ runner.os }}-rust-bin | ||
build-${{ runner.os }}-rust- | ||
- name: "🏗 Use Xcode 12.4" | ||
run: sudo xcode-select -switch /Applications/Xcode_12.4.app | ||
|
||
- name: "🛠 Prepare Tools" | ||
- name: "⚗️ Build and Test" | ||
run: | | ||
sh Support/prepare_build_tools | ||
Support/build_test_linux | ||
- name: "⚗️ Run tests (Xcode)" | ||
run: | | ||
sh Support/build_test | ||
testMacOS12: | ||
name: "Test macOS 12" | ||
runs-on: macos-12 | ||
needs: [build] | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
include: | ||
- scheme: "PactSwiftMockServer-iOS" | ||
destination: "platform=iOS Simulator,name=iPhone 13 Pro" | ||
- scheme: "PactSwiftMockServer-macOS" | ||
destination: "arch=x86_64" | ||
|
||
env: | ||
SCHEME: ${{ matrix.scheme }} | ||
DESTINATION: ${{ matrix.destination }} | ||
|
||
concurrency: | ||
group: test-${{ github.ref }}-${{ matrix.scheme }} | ||
cancel-in-progress: true | ||
|
||
steps: | ||
- name: "♻️ Checkout repository" | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
- name: "♼ Cache rust binaries" | ||
uses: actions/cache@v3 | ||
- name: "Upload code coverage" | ||
id: codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
path: | | ||
${{ env.RUST_TARGET_PATH }} | ||
${{ env.BINARIES_PATH }} | ||
key: build-${{ runner.os }}-rust-${{ hashFiles('**/libpact_ffi.version') }} | ||
restore-keys: | | ||
build-${{ runner.os }}-rust- | ||
- name: "🏗 Use Xcode 13.4.1" | ||
run: sudo xcode-select -switch /Applications/Xcode_13.4.1.app | ||
|
||
- name: "🛠 Prepare Tools" | ||
run: | | ||
sh Support/prepare_build_tools | ||
- name: "⚗️ Run tests (Xcode)" | ||
run: | | ||
sh Support/build_test | ||
- name: "⬆️ Upload code coverage" | ||
run: | | ||
bash <(curl -s https://codecov.io/bash) -J 'PactSwiftMockServer' | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
verbose: true |
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# PactSwiftMockServer | ||
# PactSwiftMockServer | ||
|
||
[![Build and Test](https://github.com/surpher/PactSwiftMockServer/actions/workflows/build_test.yml/badge.svg?branch=main)](https://github.com/surpher/PactSwiftMockServer/actions/workflows/build_test.yml) | ||
[![CI](https://github.com/surpher/PactSwiftMockServer/actions/workflows/build_test.yml/badge.svg?branch=legacy%2Fv0.5.0)](https://github.com/surpher/PactSwiftMockServer/actions/workflows/build_test.yml) | ||
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](LICENSE.md) | ||
[![codecov](https://codecov.io/gh/surpher/PactSwiftMockServer/branch/main/graph/badge.svg?token=0LYZVF36I9)](https://codecov.io/gh/surpher/PactSwiftMockServer) | ||
|
||
A wrapper around [`libpact_ffi.a`](https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_ffi) binary and exposed as XCFramework to be primarily used by [`PactSwift`](https://github.com/surpher/PactSwift). | ||
A wrapper around [`libpact_ffi.a`](https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_ffi) binary and exposed as archived XCFramework (surpher/PactSwiftServer.git). | ||
|
||
But nothing is stopping you from creating your own interface using this package. | ||
Used as an external module to serve [`PactSwift`](https://github.com/surpher/PactSwift) for iOS, macOS and tvOS platforms. | ||
|
||
Used as a Swift Package for Linux platforms. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# ### Pre-requisites: | ||
# | ||
# `pact-reference` repo and `PactSwift` repo are on the same folder level | ||
# | ||
# ### Usage: | ||
# ./Support/build_rust_dependencies | ||
# | ||
# In order to minimise the built binary size update $LIBPACT_FFI_DI/Cargo.toml and append the following: | ||
# | ||
# [lib] | ||
# crate-type = ["staticlib"] | ||
# | ||
# [profile.release] | ||
# opt-level = 'z' | ||
# lto = true | ||
# panic = 'abort' | ||
# | ||
####################### | ||
|
||
PRODUCT_NAME="PactSwiftMockServer" | ||
WORKSPACE=${GITHUB_WORKSPACE:-$PWD} | ||
LIBPACT_FFI_VERSION="0.4.20" | ||
LIBPACT_FFI_DIR="${WORKSPACE}/pact-reference/rust/pact_ffi" | ||
LIBPACT_PRODUCT_DIR="${WORKSPACE}/pact-reference/rust/target/debug" | ||
CI=${CI:-"false"} | ||
PACT_FOUNDATION_REPO="https://github.com/pact-foundation/pact-reference.git" | ||
|
||
####################### | ||
# Pre-requisite # | ||
####################### | ||
|
||
if [ ! -d "$PWD/$PRODUCT_NAME.xcodeproj" ] | ||
then | ||
echo "🚨 Run this from the same folder where your '$PRODUCT_NAME.xcodeproj' lives." | ||
echo "⚠️ You are runing it in $PWD" | ||
exit 1 | ||
fi | ||
|
||
####################### | ||
# If CI # | ||
####################### | ||
|
||
echo "👮♀️ Verifying project and dependencies' folder setup..." | ||
|
||
if [[ "$CI" == true ]]; then | ||
echo "ℹ️ Adding submodule ${PACT_FOUNDATION_REPO}" | ||
if [ ! -d "$LIBPACT_FFI_DIR" ]; then | ||
# git submodule add "$PACT_FOUNDATION_REPO" | ||
git submodule update --init | ||
|
||
echo "ℹ️ Changing location (1) to ${LIBPACT_FFI_DIR}" | ||
cd "$LIBPACT_FFI_DIR" | ||
git fetch --all --tags | ||
git checkout "tags/libpact_ffi-v$LIBPACT_FFI_VERSION" | ||
fi | ||
|
||
export LD_LIBRARY_PATH="/usr/local/lib" | ||
|
||
elif [ ! -d "$PWD/../pact-reference" ]; then | ||
# TODO: fix this for running locally | ||
echo "🚨 Missing pact-foundation/pact-reference repo." | ||
echo "⚠️ Make sure you 'git clone ${PACT_FOUNDATION_REPO}' at the same folder level as your $PRODUCT_NAME." | ||
exit 1 | ||
else | ||
echo "👍 Project setup seems to be in order." | ||
fi | ||
|
||
echo "ℹ️ Changing location (2) to ${LIBPACT_FFI_DIR}" | ||
cd "$LIBPACT_FFI_DIR" | ||
|
||
####################### | ||
# Setup # | ||
####################### | ||
|
||
# Validate dependencies | ||
|
||
echo "👮♀️ Checking if Rust is installed..." | ||
if which cargo >/dev/null; then | ||
echo "👍 cargo installed" | ||
elif command -v ~/.cargo/bin/cargo &> /dev/null; then | ||
echo "👍 cargo installed in ~/.cargo/bin/" | ||
else | ||
echo "🚨 Rust/Cargo not installed" | ||
echo "ERROR: cargo is required and is was found on this machine. See https://www.rust-lang.org/tools/install" | ||
exit 1 | ||
fi | ||
|
||
############################################## | ||
# Build libpact_ffi libraries # | ||
############################################## | ||
|
||
# Using debug build flag (or not providing it), otherwise libpact_ffi.so must be moved into /usr/local/lib/ | ||
echo "🏗 Building libpact_ffi for current platform (debug build)" | ||
cargo build | ||
echo "✅ libpact_ffi built" | ||
|
||
echo "ℹ️ Setting LD_LIBRARY_PATH to include $LIBPACT_PRODUCT_DIR" | ||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIBPACT_PRODUCT_DIR" | ||
|
||
####################### | ||
# Cleanup # | ||
####################### | ||
|
||
echo "ℹ️ Changing directory back to ${WORKSPACE}" | ||
cd "${WORKSPACE}" | ||
|
||
############################################################################################################## | ||
# Run Swift buld and test # | ||
# https://github.com/apple/swift-package-manager/blob/main/Documentation/Usage.md#requiring-system-libraries # | ||
############################################################################################################## | ||
|
||
echo "ℹ️ Running swift build:" | ||
swift build -Xlinker -L"$LIBPACT_PRODUCT_DIR" | ||
|
||
echo "ℹ️ Running swift test with -Xlinker -L$LIBPACT_PRODUCT_DIR" | ||
swift test -Xlinker -L"$LIBPACT_PRODUCT_DIR" --enable-code-coverage --verbose |
Oops, something went wrong.