Skip to content

Commit

Permalink
Merge pull request #49 from velocidi/makefile
Browse files Browse the repository at this point in the history
Add Makefile
  • Loading branch information
thyandrecardoso committed Mar 31, 2021
2 parents 4f126cb + 173f363 commit f4b1698
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 58 deletions.
31 changes: 9 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ jobs:
with:
xcode-version: "${{ matrix.xcode }}"
- name: "Install Dependencies"
run: pod install
run: make install
- name: "Compile and Test Velocidi SDK"
env:
TEST_SDK: "${{ matrix.sdk }}"
TEST_DEVICE: "${{ matrix.device }}"
run: ./.github/workflows/xcodebuild.sh clean build test
run: |
make
make test
- name: "Verify code linting generated no changes"
run: git diff --exit-code
- name: Upload coverage to Codecov
Expand All @@ -47,31 +49,17 @@ jobs:
name: "Build example applications"
needs: test
runs-on: "macos-latest"
env:
WORKSPACE: "VelocidiSDK.xcworkspace"
TEST_SDK: "14.4"
TEST_DEVICE: "iPhone 11 Pro Max"
steps:
- uses: actions/checkout@v1
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "latest-stable"
- name: "Install Dependencies"
run: pod install
- name: "Compile Velocidi SDK"
env:
SCHEME: "VelocidiSDK"
run: ./.github/workflows/xcodebuild.sh clean build
- name: "Update Velocidi SDK Pod for example applications"
run: pod install --project-directory=Examples/
run: make install
- name: "Build example Objective-C application"
env:
SCHEME: "ObjcExample"
run: ./.github/workflows/xcodebuild.sh clean build
run: make build-objc-example
- name: "Build example Swift application"
env:
SCHEME: "SwiftExample"
run: ./.github/workflows/xcodebuild.sh clean build
run: make build-swift-example
- name: "Verify code linting generated no changes"
run: git diff --exit-code

Expand All @@ -87,6 +75,5 @@ jobs:
- name: "Lint"
run: |
pod repo update
pod install
pod lib lint --verbose
pod spec lint --verbose
make install
make podlint
14 changes: 0 additions & 14 deletions .github/workflows/xcodebuild.sh

This file was deleted.

34 changes: 34 additions & 0 deletions .scripts/prerequisites.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env sh

FAILED=false

if ! which xcodebuild >/dev/null; then
echo "xcodebuild does not seem to be installed. You can install it by installing Xcode from the App Store."
FAILED=true
fi

if ! which pod >/dev/null; then
echo "Cocoapods does not seem to be installed. You may need to run 'gem install cocoapods'."
FAILED=true
fi

if ! which xcpretty >/dev/null; then
echo "xcpretty does not seem to be installed. You may need to run 'gem install xcpretty'."
FAILED=true
fi

if ! command -v Pods/SwiftLint/swiftlint &> /dev/null; then
echo "Swiftlint does not seem to be installed. You may need to run 'pod install'."
FAILED=true
fi

if ! which oclint >/dev/null; then
echo "oclint does not seem to be installed. You may need to run 'brew tap oclint/formulae && brew install oclint'."
FAILED=true
fi

if $FAILED; then
exit 1
fi

echo "All required dependencies are installed!"
16 changes: 0 additions & 16 deletions .scripts/swiftlint.sh

This file was deleted.

53 changes: 53 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
WORKSPACE ?= VelocidiSDK.xcworkspace
TEST_SDK ?= 14.4
TEST_DEVICE ?= iPhone 11 Pro Max

XCARGS := -workspace $(WORKSPACE) \
-sdk "iphonesimulator$(TEST_SDK)" \
-destination "platform=iOS Simulator,OS=$(TEST_SDK),name=$(TEST_DEVICE)" \
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

build:
set -o pipefail && xcodebuild $(XCARGS) -scheme VelocidiSDK build | xcpretty

# we have to clean schemas independently because xcode does not allow to clean all schemes in a workspace
clean:
xcodebuild $(XCARGS) -scheme VelocidiSDK clean | xcpretty && \
xcodebuild $(XCARGS) -scheme ObjcExample clean | xcpretty && \
xcodebuild $(XCARGS) -scheme SwiftExample clean | xcpretty

test: build
set -o pipefail && xcodebuild $(XCARGS) -scheme VelocidiSDK test | xcpretty

examples: install-examples build-objc-example build-swift-example

install-examples: build
pod install --project-directory=Examples/

build-objc-example: install-examples
set -o pipefail && xcodebuild $(XCARGS) -scheme ObjcExample clean build | xcpretty

build-swift-example: install-examples
set -o pipefail && xcodebuild $(XCARGS) -scheme SwiftExample clean build | xcpretty

install:
pod install

prerequisites:
.scripts/prerequisites.sh

oclint-examples:
set -o pipefail && \
xcodebuild -scheme ObjcExample -sdk iphonesimulator -workspace VelocidiSDK.xcworkspace COMPILER_INDEX_STORE_ENABLE=NO clean build | xcpretty -r json-compilation-database --output compile_commands.json && \
oclint-json-compilation-database -exclude Pods -exclude build -- -report-type xcode -max-priority-3=15000

oclint:
set -o pipefail && \
xcodebuild -scheme VelocidiSDK -sdk iphonesimulator -workspace VelocidiSDK.xcworkspace COMPILER_INDEX_STORE_ENABLE=NO clean build | xcpretty -r json-compilation-database --output compile_commands.json && \
oclint-json-compilation-database -exclude Pods -exclude build -- -report-type xcode -max-priority-3=15000

swiftlint:
Pods/SwiftLint/swiftlint lint --fix && Pods/SwiftLint/swiftlint lint --strict

podlint:
pod lib lint --verbose
12 changes: 6 additions & 6 deletions VelocidiSDK.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f4b1698

Please sign in to comment.