Skip to content

Commit

Permalink
add deployment checks (#404)
Browse files Browse the repository at this point in the history
* added deployment checks job, added pod lib lint

* added deployment checks to circleCI config, added carthage archive step to deployment checls

* added check to ensure that a release in github with the current version number doesn't already exist.

* added extra check to ensure that the git tag doesn't exist before deploying

* bumped xcode version for deployment checks job

* updated xcode version for all jobs

* replaced relative url with link so it works locally as well as in CI

* added explicit casts from NSUInteger to unsigned long in a couple of places

* re-added other deployment checks

* added filter to only run deployment checks on release tags and PRs
  • Loading branch information
aboedo committed Dec 1, 2020
1 parent c84372d commit 3fb05c0
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 10 deletions.
42 changes: 36 additions & 6 deletions .circleci/config.yml
Expand Up @@ -64,7 +64,7 @@ commands:
jobs:
runtest:
macos:
xcode: "12.0"
xcode: "12.2.0"
working_directory: ~/purchases-ios
shell: /bin/bash --login -o pipefail
steps:
Expand Down Expand Up @@ -95,9 +95,38 @@ jobs:
- store_artifacts:
path: fastlane/test_output/report.html
destination: test_report.html

deployment-checks:
macos:
xcode: "12.2.0"
working_directory: ~/purchases-ios
shell: /bin/bash --login -o pipefail
steps:
- checkout
# Bundler
- restore_cache:
keys:
- gem-cache-{{ checksum "Gemfile.lock" }}
- run: bundle install --clean --path vendor/bundle
- save_cache:
key: gem-cache-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle

- run:
name: Deployment checks
command: fastlane deployment_checks
environment:
SCAN_SCHEME: All Tests
- store_test_results:
path: fastlane/test_output
- store_artifacts:
path: fastlane/test_output/report.html
destination: test_report.html

docs-deploy:
macos:
xcode: "12.0"
xcode: "12.2.0"
working_directory: ~/purchases-ios
shell: /bin/bash --login -o pipefail
steps:
Expand All @@ -119,7 +148,7 @@ jobs:

integration-tests-cocoapods:
macos:
xcode: "12.0"
xcode: "12.2.0"
working_directory: ~/purchases-ios/
shell: /bin/bash --login -o pipefail
steps:
Expand All @@ -140,7 +169,7 @@ jobs:

integration-tests-swift-package-manager:
macos:
xcode: "12.0"
xcode: "12.2.0"
working_directory: ~/purchases-ios/
shell: /bin/bash --login -o pipefail
steps:
Expand All @@ -151,7 +180,7 @@ jobs:

integration-tests-carthage:
macos:
xcode: "12.0"
xcode: "12.2.0"
working_directory: ~/purchases-ios/
shell: /bin/bash --login -o pipefail
steps:
Expand All @@ -175,7 +204,7 @@ jobs:

integration-tests-xcode-direct-integration:
macos:
xcode: "12.0"
xcode: "12.2.0"
working_directory: ~/purchases-ios/
shell: /bin/bash --login -o pipefail
steps:
Expand All @@ -189,6 +218,7 @@ workflows:
build-test:
jobs:
- runtest
- deployment-checks: *only-release-tags
- integration-tests-cocoapods: *only-release-tags
- integration-tests-swift-package-manager: *only-release-tags
- integration-tests-carthage: *only-release-tags
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/CarthageIntegration/Cartfile
@@ -1 +1 @@
git "../../"
git "./purchases-root"
1 change: 1 addition & 0 deletions IntegrationTests/CarthageIntegration/purchases-root
6 changes: 4 additions & 2 deletions Purchases/Networking/RCHTTPClient.m
Expand Up @@ -67,7 +67,7 @@ - (void)performRequest:(NSString *)httpMethod
@synchronized (self) {
if (self.currentSerialRequest) {
RCDebugLog(@"There's a request currently running and %ld requests left in the queue, queueing %@ %@",
self.queuedRequests.count,
(unsigned long)self.queuedRequests.count,
httpMethod,
path);
[self.queuedRequests addObject:rcRequest];
Expand Down Expand Up @@ -141,7 +141,9 @@ - (void) handleResponse:(NSURLResponse *)response
if (beginNextRequestWhenFinished) {
@synchronized (self) {
RCDebugLog(@"serial request done: %@ %@, %ld requests left in the queue",
self.currentSerialRequest.httpMethod, self.currentSerialRequest.path, self.queuedRequests.count);
self.currentSerialRequest.httpMethod,
self.currentSerialRequest.path,
(unsigned long)self.queuedRequests.count);
RCHTTPRequest *nextRequest = nil;
self.currentSerialRequest = nil;
if (self.queuedRequests.count > 0) {
Expand Down
Expand Up @@ -24,7 +24,7 @@ - (RCSubscriberAttributeDict)unsyncedAttributesByKey {
NSString *appUserID = self.appUserID;
RCSubscriberAttributeDict unsyncedAttributes = [self.subscriberAttributesManager
unsyncedAttributesByKeyForAppUserID:appUserID];
RCLog(@"found %lu unsynced attributes for appUserID: %@", unsyncedAttributes.count, appUserID);
RCLog(@"found %lu unsynced attributes for appUserID: %@", (unsigned long)unsyncedAttributes.count, appUserID);
if (unsyncedAttributes.count > 0) {
RCLog(@"unsynced attributes: %@", unsyncedAttributes);
}
Expand Down
35 changes: 35 additions & 0 deletions fastlane/Fastfile
Expand Up @@ -86,6 +86,15 @@ platform :ios do
Spaceship::Tunes::SandboxTester.create!(email: email, password: password)
end

desc "Deployment checks"
lane :deployment_checks do |options|
version_number = get_version_number(target: "Purchases")
check_no_git_tag_exists(version_number)
check_pods
carthage_archive
check_no_github_release_exists(version_number)
end

desc "archive"
lane :archive do
match(type: "appstore")
Expand All @@ -102,6 +111,32 @@ platform :ios do

end

def check_no_git_tag_exists(version_number)
if git_tag_exists(tag: version_number, remote: true, remote_name: 'origin')
raise "git tag with version #{version_number} already exists!"
end
end


def check_no_github_release_exists(version_number)
found_release_number = get_github_release(url: "revenuecat/purchases-ios", version: version_number)
raise "Release with version #{version_number} already exists!" unless found_release_number.nil?
end

def carthage_archive
# can't use fastlane carthage integration directly because of Carthage/Xcode 12 compatibility issues:
# https://github.com/Carthage/Carthage/issues/3019
Dir.chdir("..") do
sh("./carthage.sh", "build", "--no-skip-current")
sh("./carthage.sh", "archive", "Purchases")
end
end

def check_pods
pod_lib_lint(verbose: true, podspec:'PurchasesCoreSwift.podspec')
pod_lib_lint(verbose: true, podspec:'Purchases.podspec', include_podspecs:'PurchasesCoreSwift.podspec')
end

def increment_build_number(previous_version_number, new_version_number, file_path)
sed_regex = 's|' + previous_version_number + '|' + new_version_number + '|'
backup_extension = '.bck'
Expand Down
10 changes: 10 additions & 0 deletions fastlane/README.md
Expand Up @@ -41,6 +41,11 @@ Make github release
fastlane ios create_sandbox_account
```
Create sandbox account
### ios deployment_checks
```
fastlane ios deployment_checks
```
Deployment checks
### ios archive
```
fastlane ios archive
Expand All @@ -51,6 +56,11 @@ archive
fastlane ios replace_api_key_integration_tests
```
replace API KEY for integration tests
### ios deploy
```
fastlane ios deploy
```
Deploy

----

Expand Down

0 comments on commit 3fb05c0

Please sign in to comment.