Skip to content

Store root directory in variable#32

Merged
DunnCoding merged 5 commits intodevelopfrom
fixScript
Jun 26, 2018
Merged

Store root directory in variable#32
DunnCoding merged 5 commits intodevelopfrom
fixScript

Conversation

@DunnCoding
Copy link
Copy Markdown
Collaborator

This PR is to remove changing directories via relative paths.

Instead we store the root directory of the project in a variable, and use the absolute path of the stored pwd

@codecov-io
Copy link
Copy Markdown

codecov-io commented May 18, 2018

Codecov Report

Merging #32 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop      #32   +/-   ##
========================================
  Coverage    80.15%   80.15%           
========================================
  Files            2        2           
  Lines          131      131           
========================================
  Hits           105      105           
  Misses          26       26
Flag Coverage Δ
#KituraKit 80.15% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d86140...973ec92. Read the comment docs.

@DunnCoding DunnCoding requested a review from djones6 May 18, 2018 09:18
Copy link
Copy Markdown
Contributor

@djones6 djones6 left a comment

Choose a reason for hiding this comment

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

Please also rebase this branch on develop to get rid of the spurious merge commit from master

ci/update.sh Outdated
git checkout pod
git pull origin master

DIR=$(pwd)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be the first line of the script (other than perhaps a comment block that says what this script is for). In case, for example, one of the other commands changed the pwd.

I'd also suggest a comment explaining what the variable is (ie. 'The root of the project directory') and giving it a more descriptive name eg. projectDir

ci/update.sh Outdated
@@ -75,7 +77,7 @@ cd ../SwiftyRequest*
rm -rf ../../../Sources/KituraKit/SwiftyRequest
cp -r Sources/SwiftyRequest ../../../Sources/KituraKit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These shouldn't be relative paths, they should be using $projectDir (see comment on naming above)

ci/update.sh Outdated
cd $DIR/Sources/KituraKit

# Remove all the import statements that aren't needed
read -a SWIFTFILES <<< $(find .. -name "*.swift")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be find $projectDir/Sources, and you can get rid of the cd above altogether

ci/update.sh Outdated
cd $DIR

rm -rf swift-4.0-RELEASE-ubuntu14.04/
rm -rf Package-Builder/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

similarly you can get rid of the cd and pass an absolute path to rm

@DunnCoding
Copy link
Copy Markdown
Collaborator Author

Addressed all review comments.
@djones6

Copy link
Copy Markdown
Contributor

@djones6 djones6 left a comment

Choose a reason for hiding this comment

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

Some more instances of cd and ..

ci/update.sh Outdated
@@ -59,26 +62,25 @@ git pull origin master
swift package resolve

cd .build/checkouts/LoggerAPI*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unnecessary cd

ci/update.sh Outdated
rm -rf $projectDir/Sources/KituraKit/LoggerAPI
cp -r Sources/LoggerAPI $projectDir/Sources/KituraKit

cd ../CircuitBreaker*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unnecessary cd

ci/update.sh Outdated
rm -rf $projectDir/Sources/KituraKit/CircuitBreaker
cp -r Sources/CircuitBreaker $projectDir/Sources/KituraKit

cd ../KituraContracts*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unnecessary cd

ci/update.sh Outdated
cp -r Sources/KituraContracts $projectDir/Sources/KituraKit
mv $projectDir/Sources/KituraKit/KituraContracts/CodableQuery/*.swift $projectDir/Sources/KituraKit/KituraContracts/

cd ../SwiftyRequest*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unnecessary cd

ci/update.sh Outdated
rm -rf ../../../Sources/KituraKit/LoggerAPI
cp -r Sources/LoggerAPI ../../../Sources/KituraKit
rm -rf $projectDir/Sources/KituraKit/LoggerAPI
cp -r Sources/LoggerAPI $projectDir/Sources/KituraKit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rather than the cd above, I believe this could be accomplished with

cp -r $projectDir/.build/checkouts/LoggerAPI*/Sources/LoggerAPI $projectDir/Sources/KituraKit

@djones6
Copy link
Copy Markdown
Contributor

djones6 commented May 18, 2018

After discussion, the suggestion above doesn't work (apparently, can't have a wildcard in the middle of a file path). An alternative that still avoids .. would be:

 cd $projectDir/.build/checkouts/SwiftyRequest* && cp <source> <dest>
 cd $projectDir/.build/checkouts/LoggerAPI* && cp <source> <dest>

By adding the and (&&) this avoids copying a relative path from the wrong location if the cd were to fail (which is possible, since you are cd'ing into a wildcarded location, where the location is SPM's implementation detail (we've been advised before not to rely on the structure of .build).

A slower (but safer) approach would be:

swift package edit SwiftyRequest
cp $projectDir/Packages/SwiftyRequest/Sources $projectDir/Sources

The location of the edited package is something we can rely on and since it has a predictable name, doesn't require the wildcard stuff above.

ci/update.sh Outdated
rm -rf ../../../Sources/KituraKit/CircuitBreaker
cp -r Sources/CircuitBreaker ../../../Sources/KituraKit
rm -rf $projectDir/Sources/KituraKit/CircuitBreaker
cd .build/checkouts/CircuitBreaker* && cp -r Sources/CircuitBreaker $projectDir/Sources/KituraKit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No good - you are cding to another location above but not returning to $projectDir before executing the next cd to a relative location.
You could fix this by prepending $projectDir to each cd, but then the git commands at the end would fail (you'd need a final cd $projectDir before them).

I'd recommend the cd-less approach I suggested in my earlier review (using swift package edit) as you can then stay at the project root for the duration of the script.

@DunnCoding
Copy link
Copy Markdown
Collaborator Author

@djones6 Ready for a fresh review.
As per your suggestion I've removed the 'cd' commands and opted for the swift package edit option. You mentioned this is a slower option, however as this is a 'travis only' script I think the added safety far outweighs the loss in speed.

Thanks for the suggestion 👍

Copy link
Copy Markdown
Contributor

@djones6 djones6 left a comment

Choose a reason for hiding this comment

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

👍

@DunnCoding DunnCoding merged commit 0f4a8f3 into develop Jun 26, 2018
@DunnCoding DunnCoding deleted the fixScript branch June 26, 2018 07:36
@djones6 djones6 mentioned this pull request Jun 27, 2018
DunnCoding pushed a commit that referenced this pull request Jun 28, 2018
* fix: pod update script (#32)

* feat: Add basic, google token and facebook token authentication (#33)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants