Skip to content

Commit

Permalink
Fix/ci with ngrok (danielpaulus#94)
Browse files Browse the repository at this point in the history
Introduces a nice ci workflow that allows to attach a personal device easily to the CI so tests can be run on different OS'es with local devices.
Also shows how to use app-signer to dynamically sign an ipa using a github actions cloud mac.
  • Loading branch information
danielpaulus authored Jan 6, 2022
1 parent 8d671c0 commit 01a4537
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 43 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/real-device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
on:
workflow_dispatch:
inputs:
ngrok:
description: 'ngrok host:port'
required: true
default: ''
udid:
description: 'device udid'
required: true
default: ''
# run this locally to get a device exposed on ngrok
# ngrok tcp 9999
# socat TCP-LISTEN:9999,reuseaddr,fork UNIX-CONNECT:/var/run/usbmuxd
name: CI Real Device Test
jobs:
sign_app_on_mac:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: create profile
run: |
echo $P12_FILE | base64 --decode > testdata/test1.p12
echo $PROFILE | base64 --decode > testdata/test1.mobileprovision
shell: bash
env:
P12_FILE: ${{secrets.P12}}
PROFILE: ${{secrets.PROFILE}}
- name: Run App Signer
run: |
testdata/app-signer-mac --udid=$UDID --p12password=$P12_PW --profilespath=testdata --ipa=testdata/wda.ipa --output=testdata/wda-signed.ipa
env:
P12_PW: ${{secrets.P12PASSWORD}}
UDID: ${{ github.event.inputs.udid }}
- name: delete profiles
if: always()
run: |
rm testdata/test1*
- name: upload the macos build
uses: actions/upload-artifact@v2
with:
name: signed-wda
path: testdata/wda-signed.ipa
retention-days: 1
test_on_windows:
runs-on: windows-latest
needs: sign_app_on_mac
env:
UDID: ${{ github.event.inputs.udid }}
steps:
- uses: actions/cache@v2 # https://github.com/actions/cache/blob/main/examples.md#go---modules
with:
path: |
%LocalAppData%\go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Checkout code
uses: actions/checkout@v2
- name: compile
run: go build
- name: Download mac signed wda from previous job
uses: actions/download-artifact@v2
with:
name: signed-wda
- name: extract ipa #github auto zips artifacts after a workflow is complete so we need to unzip the ipa
#as it is now double zipped
run: Expand-Archive -Force wda-signed.ipa testdata/signed-wda.ipa
- name: forward ngrok
run: netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=27015 connectaddress=$($env:NGROK_URL.Split(":")[0]) connectport=$($env:NGROK_URL.Split(":")[1])
env:
NGROK_URL: ${{ github.event.inputs.ngrok }}
- name: test list
run: go run main.go list
- name: install relative
run: go run main.go install --path testdata\signed-wda.ipa --udid=$($env:UDID)
- name: install absolute
run: go run main.go install --path $PWD\testdata\signed-wda.ipa --udid=$($env:UDID)

test_on_linux:
runs-on: ubuntu-latest
env:
UDID: ${{ github.event.inputs.udid }}
needs:
- sign_app_on_mac
- test_on_windows
steps:
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Checkout code
uses: actions/checkout@v2
- name: Download mac release from previous job
uses: actions/download-artifact@v2
with:
name: signed-wda
- name: extract
run: |
mv wda-signed.ipa testdata/signed-wda.ipa
- name: compile
run: go build
- name: install socat
run: sudo apt install socat
- name: ngrok
run: sudo socat UNIX-LISTEN:/var/run/usbmuxd,fork,mode=777 TCP-CONNECT:$NGROK_URL&
env:
NGROK_URL: ${{ github.event.inputs.ngrok }}
- name: test list
run: go run main.go list
- name: install relative
run: go run main.go install --path testdata/signed-wda.ipa --udid=$UDID

45 changes: 2 additions & 43 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
on:
push:
workflow_dispatch:
inputs:
ngrok:
description: 'ngrok host:port'
required: true
default: ''
udid:
description: 'device udid or blank for default device'
required: false
default: ''
# run this locally to get a device exposed on ngrok
# ngrok tcp 9999
# socat TCP-LISTEN:9999,reuseaddr,fork UNIX-CONNECT:/var/run/usbmuxd
pull_request:

name: Unit tests
jobs:
test_on_windows:
Expand All @@ -34,23 +22,8 @@ jobs:
uses: actions/checkout@v2
- name: compile
run: go build

- name: run unit tests
run: go test -v -tags=fast ./...
- name: forward ngrok
if: ${{ github.event.inputs.ngrok }}
run: netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=27015 connectaddress=$($env:NGROK_URL.Split(":")[0]) connectport=$($env:NGROK_URL.Split(":")[1])
env:
NGROK_PORT: ${{ github.event.inputs.ngrok }}
- name: test list
if: ${{ github.event.inputs.ngrok }}
run: go run main.go list
- name: install relative
if: ${{ github.event.inputs.ngrok }}
run: go run main.go install --path testdata\wda-signed-test.ipa --udid=8a4b8ae031a0565729e92b836e82bccc4540f8fd
- name: install absolute
if: ${{ github.event.inputs.ngrok }}
run: go run main.go install --path $PWD\testdata\wda-signed-test.ipa --udid=8a4b8ae031a0565729e92b836e82bccc4540f8fd

test_on_linux:
runs-on: ubuntu-latest
Expand All @@ -73,18 +46,4 @@ jobs:
run: go build
- name: run unit tests
run: go test -v -tags=fast ./...
#integration piece
- name: test list
if: ${{ github.event.inputs.ngrok }}
run: go run main.go list
- name: install socat
if: ${{ github.event.inputs.ngrok }}
run: sudo apt install socat
- name: ngrok
if: ${{ github.event.inputs.ngrok }}
run: |
sudo socat UNIX-LISTEN:/var/run/usbmuxd,fork,user=mysql,group=mysql,mode=777 TCP-CONNECT:2.tcp.ngrok.io:18860&
- name: run go test
if: ${{ github.event.inputs.ngrok }}
run: go run main.go

Binary file added testdata/app-signer-linux
Binary file not shown.

0 comments on commit 01a4537

Please sign in to comment.