Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Makefile #49

Merged
merged 19 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a bit strange to have all the build commands inside the Makefile and then the still use the ./.github/workflows/xcodebuild.sh file in the tests.

Can't we use the make there too? I think it is possible to import env vars into Makefiles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9160da5

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this file to the xcode group, so that it is visible inside the project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 323259f


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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tools are all mostly dead :(
The project seems mostly dead: xcpretty/xcpretty#360

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these examples depend on the install-examples target?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 173f363


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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had some challenges running this.

pyenv: python3: command not found

The `python3' command exists in these Python versions:
  3.7.9

Note: See 'pyenv help global' for tips on allowing both
      python2 and python3 to be found.
make: *** [oclint] Error 127
dlopen(/usr/local/bin/../lib/oclint/rules/libTooManyMethodsRule.dylib, 1): no suitable image found.  Did find:
	/usr/local/bin/../lib/oclint/rules/libTooManyMethodsRule.dylib: code signature in (/usr/local/bin/../lib/oclint/rules/libTooManyMethodsRule.dylib) not valid for use in process using Library Validation: library load disallowed by system policy

oclint: error: cannot open dynamic library: /usr/local/bin/../lib/oclint/rules/libTooManyMethodsRule.dylib
make: *** [oclint] Error 1

Screenshot 2021-03-26 at 12 14 59

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I ever had this problem. I tried uninstalling and installing oclint and I could not replicate this issue. I don't use pyenv, so it might be related to that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of pyenv, I think python3 is required.

The second problem is not related to python.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this oclint run also for the examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a command for this in 3025b2c

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.