SebKuzminsky / pycam

Other
340 stars 98 forks source link

This PR is just for testing travis integration, please ignore #86

Closed SebKuzminsky closed 6 years ago

SebKuzminsky commented 6 years ago

I'll close this PR and delete the test branches when I'm done with them.

ebo commented 6 years ago

On Oct 26 2017 8:43 AM, Sebastian Kuzminsky wrote:

SebKuzminsky commented on this pull request.

@@ -15,6 +15,9 @@ before_install: ./scripts/travis-install-build-deps.sh install: true

script:

    • export BRANCH=$(if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then echo ${TRAVIS_BRANCH}; else echo ${TRAVIS_PULL_REQUEST_BRANCH}-${TRAVIS_BRANCH}-pull-request; fi)
    • git branch -D ${BRANCH} || true
    • git checkout -b ${BRANCH} ${TRAVIS_COMMIT}

My goal is to have the travis job run on the right commit (which it currently does), and with a sensible git branch name (which it currently doesn't).

When building pushes, the git branch is unspecified (detached HEAD) and Travis runs on the tip commit of the branch you pushed, as shown here: https://travis-ci.org/SebKuzminsky/pycam/jobs/292734192

When building PRs, github makes the merge on a throw-away integration branch and Travis runs on the merge commit, again with a detached HEAD, as shown here: https://travis-ci.org/SebKuzminsky/pycam/jobs/292734200

You can construct the desired branch name from Travis' environment variables (line 18). Now, how do you convince git to use that desired branch name?

If a branch exists and you "checkout -b" it, you get this error and HEAD doesn't move:

> cat .git/HEAD
ref: refs/heads/master
> git branch i-exist v0.6.0
> git checkout -b i-exist v0.6.1
fatal: A branch named 'i-exist' already exists.
> cat .git/HEAD
ref: refs/heads/master

I can't convince myself that it will always be the case in all Travis jobs that the branch name we want to build does not exist, but i can convince myself that the above code (lines 19 & 20) will always do what I want: remove the branch if it exists, then create it anew pointing to the commit i want.

There is a simple solution which guarantees that the new name will never exist prior to execution -- use mktemp or similar to create a temporary directory tree which should be deleted as soon as the context dies. I am assuming you want it to go away after you are done with it...

Hope this helps...

EBo --

SebKuzminsky commented 6 years ago

For a directory name I agree with you @ebo , but this is for a git branch name. (Travis automatically takes care to throw away the temporary work space at the end of the job.)

We use git branch names to construct the version number, here: https://github.com/SebKuzminsky/pycam/blob/master/pycam/__init__.py#L29

This code is currently broken, and the Travis branch name work is the first step to fixing it.

ebo commented 6 years ago

On Oct 26 2017 9:25 AM, Sebastian Kuzminsky wrote:

For a directory name I agree with you @ebo , but this is for a git branch name. (Travis automatically takes care to throw away the temporary work space at the end of the job.)

We use git branch names to construct the version number, here:

https://github.com/SebKuzminsky/pycam/blob/master/pycam/__init__.py#L29

This code is currently broken, and the Travis branch name work is the first step to fixing it.

Ahhh... I misunderstood the need. Best of luck.