Can Xcode Cloud trigger a PR build from a fork? - xcode-cloud

Xcode Cloud's PR start conditions is great - But what about PRs that are coming from a fork. Not surprisingly I'm getting an error when XCC tries to checkout the source branch:
fatal: couldn't find remote ref BRANCH_NAME
Is there an easy way around this that doesn't include pushing those branches to upstream first?

Related

Github how to push Xcode project without old files and folders?

I finished an Xcode project and pushed it to github from Xcode 'Source Control' Menu. Then I changed the project name CountryBook to Countries. I Built project and ran. Everything was okay. Then I coiped project folder to desktop as a backup. Then pushed project again. Everything has messed up. Some old named folders and files still exist in repo. Then I deleted every directory and file from github repository. Now, backup version of project is working. But when I try to push it to repo, old files are still exist. I deleted 'origin' from 'Remotes' and created a new repo named 'Countries'. I pushed project again but it was same. A mixed version of old files and new files. When I clone the github version of project, of course it is not runnable. What sould I do and how can I push clean version of my project? I don't want to lose project.
This is Countries repo now:
This is my working project folder with correct content:
I would fix it via command line, lets assume you start from scratch:
Step 1 - prepare the working branch:
Clone the project
Navigate to root folder of the project
Checkout the main branch ("main", "master", or whatever it is)
Create a new branch you will be working with
git clone https://github.com/yourorg/yourrepo
cd yourrepo
git checkout main # or master
git checkout -b fixprojectstructure # branch name can be anything
Step 2 - clean project locally
Delete old project, old workspace, ensure the names in Podfile and Podfile.lock are fine
Build the project and ensure it's working
Step 3 - commit your changes:
# assuming you are in the root of the project
git add .
git commit -m "Some explanation"
Step 4 - push your changes:
I usually do it the lazy way: just run git push, which will show you the proper syntax to push remotely, something like
> git push
fatal: The current branch fixprojectstructure has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin fixprojectstructure
> git push --set-upstream origin fixprojectstructure
Enumerating objects: ...
...
remote: Create a pull request for 'fixprojectstructure' on GitHub by visiting:
remote: https://github.com/.../pull/new/fixprojectstructure
remote:
...
Branch 'fixprojectstructure' set up to track remote branch 'fixprojectstructure' from 'origin'.
Step 5 - merge your changes:
Basically just do what the line above is saying:
Navigate to https://github.com/.../pull/new/fixprojectstructure
Create pull request
Merge pull request to main (or whatever the initial branch was)
Note on the side: configure the gitignore file properly for your repo as well. For starters, follow the gitignore template to create a proper gitignore file, and then change it the way you need to.
For instance:
Usually, if you use cocoapods, you do not store .workspace folder and its contents in the repo. Instead it's generated using pod install command on each machine that needs it.
It's also common to exclude Pods directory from storing in the repo, although there are pro / cons arguments both ways.

Is there any way to prove a heroku deployment corresponds to a github repo?

I want to set an opensource project where users can be sure that the deployed version .heroku.com corresponds with the actual source code in github master branch github.com/
Is there any way to prove a heroku deployment corresponds to a github repo?
Your app can spit out the latest deployed Git SHA if it has the "Dyno Metadata" feature turned on: https://devcenter.heroku.com/articles/dyno-metadata
Using that, you can show the latest SHA and compare it against the public repo.
Also, to add to what Jon said, you can do this via the heroku releases command. Every release, be it a code deployment, config var is 'tagged' - the command will show you everything that has changed on your app and a deploy will show the short git SHA, you can copy the SHA and then use the git command to search the repo for it.
eg.
assuming heroku releases returns
v10 Deploy 33f21247 foo#bah.com 2018/09/03 10:01:38 +0100
then you could do:
git cat-file commit 33f21247
which will then output the corresponding match, or a message saying it's not found. Obviously, this assumes your local repo is in sync with GitHub. To check it against GitHub you'd need to open your repo on GitHub like:
https://github.com/heroku/{projectname}/commit/{sha}
which will show the same commit on GitHub.

Integrating GitLab with TeamCity

Since GitLab 7.6, or thereabouts, there is a new option to use TeamCity directly from GitLab projects. In the setup there is this message:
The build configuration in Teamcity must use the build format number
%build.vcs.number% you will also want to configure monitoring of all
branches so merge requests build, that setting is in the vsc root
advanced settings.
I'm not sure how this works. Lets say I have a repository Foo.
I have setup a build on TeamCity to listen to Foo with branch specification: +:refs/pull/*/merge
I then fork Foo in gitlab as FooFork, make a change, then request a merge FooFork -> Foo.
But nothing happens to test this merge, which is what I was expecting GitLab to do. If I accept the merge than the build server jumps into action (immediately) and builds twice (master and /ref/master).
I've also set the build configuration to use exactly: %build.vcs.number% as the build number as prescribed, but gitlab doesn't seem to give me any information about the build result.
So I'm a bit confused really as to what exactly this GitLab -> TeamCity integration is supposed to do and whether I'm doing wrong.
I'm currently running GitLab 7.9 and TeamCity 8.1.4
Update:
Seems this use case was not supported prior to version 8 - https://github.com/gitlabhq/gitlabhq/issues/7240
I'm running GitLab 8.0.2 and TeamCity 9.1.1 and am able to run CI builds on branches and merge requests.
I trigger CI builds for specific branches by setting a VCS trigger together with the branch specification +:refs/heads/(xyz*) where xyz is the string for our ticket system prefix since all active branches need to be named after an entry in our issue tracker.
I trigger builds for merge requests via the branch specification +:refs/(merge-requests/*)
Everything works as as expected and lets us know the status of all feature / bug branches and merge requests automatically.
Thanks to Rob's comment linking to the GitLab 8 release notes entry on the merge request spec.
Same problem here. There might be another way, I'm evaluating right now. Since there's no direct way of getting the merged state from the target MR, you have to build it on your own:
IMO there's the following todos
1.) init a bare repo $ git init
2.) add your target repo $ git remote add origin git#your-repo:<origin.group>/<origin.repo>.git
3.) add the remote/feature/to-merge's $ git remote add target git#your-repo:<feature.group>/<feature.repo>.git
4.) checkout your feature branch $ git checkout -b <feature.branch> feature/<feature.branch>
5.) checkout your original branch $ git checkout -b <origin.branch> origin/<origin.branch>
6.) Rebase feature into your original branch $ git rebase <feature.branch>
As stated here [1], GitLab-CE can fire an event on creation of a merge-request,
so all you have to do is building some meta, that can evaluate the WebHooks.
[1] http://doc.gitlab.com/ce/web_hooks/web_hooks.html#merge-request-events

Git: cannot open .pbxproj file error after renaming Xcode project and pulling changes

I renamed our iOS project (client finally chose a name) following instructions in the most upvoted answer here. I pushed my changes. Now, when my teammates pull, they cannot open the project because Xcode cannot find the .pbxproj file. They subsequently reset to their good local versions.
As usual when I royally f**k up I tried a hard reset to the last good commit, planning to force push the good commit up to the remote. While the reset was 'sucessful', it didn't change the newName.pbxproj back to oldName.pbxproj. So I could not open the project. Checking out my faulty commit didn't help things either. I am back at square one.
.pbxproj is NOT in our .gitignore:
*.DS_Store
*.xcodeproj/xcuserdata/*.xcuserdatad
*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
*/*.xcodeproj/xcuserdata/*.xcuserdatad
*/*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
The only thing I can think of now is to reclone the project from a specific remote commit. How can I do this? Other options? Why won't a renamed .pbxproj transfer over in a pull?
If you do a git log -5 it will show your last 5 commits. Determine the version before you named the file, and you can do a git reset --hard HEAD~<number> where <number> is how many commits you want to go back.
Alternatively, with your renamed proj file, you could try to blow away your remote with a git push origin :branchName then push your local changed branch up to the remote git push origin branchName
Then, have your other team members do a pull from the newly pushed remote.

How to get Jenkins to push to GitHub but not trigger a build off that push

The Setup
I've got a Mac mini set up with Jenkins pulling a repo down from GitHub and performing an Xcode build. Because the mini is firewalled off from the internet I am polling GitHub for changes every 15 minutes.
Prior to kicking off the Xcode build I have Jenkins execute the following script to bump my project build number and commit the results to the repo:
#!/bin/sh
agvtool bump -all
/usr/local/git/bin/git commit -a -m "This is Jenkins, updating your build numbers, sir."
After the build I have a post-build action set up to run another script that pulls and then pushes from GitHub, like so:
#!/bin/sh
/usr/local/git/bin/git pull origin develop
/usr/local/git/bin/git push origin develop
The Problem
Because Jenkins is performing a commit and a push to GitHub each time it runs, the next poll will find the changes it pushed up last time, creating a new build whether there were other actual changes or not.
The Question
Is there something wonky in my setup that I should be doing differently? I'd like Jenkins to update my Xcode target's build number and commit and push that result to GitHub. This configuration obviously accomplishes that, but with the side effect of a build every 15 minutes, instead of a build every 15 minutes as needed.
Jenkins is consulting the SHA1 of the lastSuccessfulBuild to determine if there have been changes, but it's doing that before my commit. Is there a way to set the SHA1 of the current build to the hash resulting from the commit of the version number bump? Something like so:
#!/bin/sh
agvtool bump -all
/usr/local/git/bin/git commit -a -m "This is Jenkins, updating your build numbers, sir."
NEW_SHA=$(/usr/local/git/bin/git rev-parse HEAD)
# Some awesome Jenkins-fu to set the SHA1 of the current build to NEW_SHA
This way when Jenkins compares hashes the next time around it won't build unless there have been changes since its commit to bump version numbers.
Thanks for any and all help.
I think this SO question answers your question, but I can't say for certain as we're not doing build version increment on a polling branch. I would also do the git push prior to building, that way you won't have to worry about as many merges that would occur should you commit code things during the build. Thankfully, if you keep it how it is you won't have much to worry about in the way of Xcode project merges.

Resources