Skip to content

Commit

Permalink
Split mac/ios targets
Browse files Browse the repository at this point in the history
  • Loading branch information
pronebird committed Oct 29, 2024
1 parent b7eb852 commit 01382a8
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
paths:
- "nym-vpn-core/**"
- ".github/workflows/ci-nym-vpn-core.yml"
- ".github/workflows/ci-nym-vpn-core-ios.yml"
workflow_dispatch:

env:
Expand All @@ -14,26 +14,17 @@ env:

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [custom-runner-mac-m1]
target: [native, ios]
runs-on: ${{ matrix.os }}
runs-on: custom-runner-mac-m1

steps:
- name: "Cleanup working directory"
if: contains(matrix.os, 'custom')
shell: bash
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev libmnl-dev libnftnl-dev protobuf-compiler git curl gcc g++ make unzip

- name: Checkout repo
uses: actions/checkout@v4

Expand All @@ -42,21 +33,12 @@ jobs:
with:
toolchain: stable
components: rustfmt, clippy

- name: Add rust target (iOS)
if: matrix.target == 'ios'
run: rustup target add aarch64-apple-ios
targets: aarch64-apple-ios

- name: Set env
shell: bash
run: |
if ${{ matrix.target == 'ios' }}; then
triplet=aarch64-apple-ios
echo "TRIPLET=$triplet" >> $GITHUB_ENV
else
triplet=universal-apple-darwin
echo "TRIPLET=$triplet" >> $GITHUB_ENV
fi
echo "TRIPLET=aarch64-apple-ios" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@v5
Expand All @@ -70,13 +52,6 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build wireguard
if: matrix.target != 'ios'
shell: bash
run: |
./wireguard/build-wireguard-go.sh
- name: Build wireguard (iOS)
if: matrix.target == 'ios'
shell: bash
run: |
./wireguard/build-wireguard-go.sh --ios
Expand All @@ -87,18 +62,11 @@ jobs:
cargo fmt --check
- name: Build
if: matrix.target != 'ios'
working-directory: nym-vpn-core
run: |
cargo build --verbose
- name: Build (iOS)
if: matrix.target == 'ios'
working-directory: nym-vpn-core
run: |
cargo build --verbose --target aarch64-apple-ios -p nym-vpn-lib
- name: Generate uniffi (iOS)
- name: Generate uniffi
if: matrix.target == 'ios'
working-directory: nym-vpn-core
run: |
Expand All @@ -107,39 +75,26 @@ jobs:
--config crates/nym-vpn-lib/uniffi.toml \
--language swift --out-dir build -n
- name: Uniffi diff check (iOS)
if: matrix.target == 'ios'
- name: Uniffi diff check
working-directory: nym-vpn-core
run: |
diff -B build/nym_vpn_lib.swift crates/nym-vpn-lib/uniffi/nym_vpn_lib.swift
continue-on-error: true
id: diff_ios

- name: Upload generated uniffi file (iOS)
if: steps.diff_ios.outcome == 'failure' && matrix.target == 'ios'
- name: Upload generated uniffi file
if: steps.diff_ios.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: updated-uniffi-ios
path: nym-vpn-core/build/nym_vpn_lib.swift
retention-days: 1

- name: Fail workflow for uniffi (iOS)
if: steps.diff_ios.outcome == 'failure' && matrix.target == 'ios'
- name: Fail workflow for uniffi
if: steps.diff_ios.outcome == 'failure'
run: exit 1

- name: Run tests (macOS)
if: matrix.target != 'ios'
working-directory: nym-vpn-core
run: |
cargo test --verbose
- name: Clippy
working-directory: nym-vpn-core
run: |
cargo clippy -- -Dwarnings
- name: Clippy (iOS)
if: matrix.target == 'ios'
working-directory: nym-vpn-core
run: |
cargo clippy --target aarch64-apple-ios -p nym-vpn-lib -- -Dwarnings
71 changes: 71 additions & 0 deletions .github/workflows/ci-nym-vpn-core-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: ci-nym-vpn-core

on:
# push:
pull_request:
paths:
- "nym-vpn-core/**"
- ".github/workflows/ci-nym-vpn-core-macos.yml"
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
AGENT_ISSELFHOSTED: 1 # https://github.com/actions/setup-go/issues/432

jobs:
build:
runs-on: custom-runner-mac-m1

steps:
- name: "Cleanup working directory"
shell: bash
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- name: Checkout repo
uses: actions/checkout@v4

- name: Install rust toolchain
uses: brndnmtthws/rust-action-rustup@v1
with:
toolchain: stable
components: rustfmt, clippy

- name: Set env
shell: bash
run: |
echo "TRIPLET=universal-apple-darwin" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "stable"

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "21.12" # 3.21.12: the version on ubuntu 24.04. Don't change this!
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build wireguard
shell: bash
run: |
./wireguard/build-wireguard-go.sh
- name: rustfmt check
working-directory: nym-vpn-core
run: |
cargo fmt --check
- name: Run tests
working-directory: nym-vpn-core
run: |
cargo test --verbose
- name: Clippy
working-directory: nym-vpn-core
run: |
cargo clippy -- -Dwarnings

0 comments on commit 01382a8

Please sign in to comment.