Additional configuration file(s) for Travis CI? - github

I'm currently contributing through a fork on GitHub to an open source project that uses Travis CI. Turning it on for the fork has been trivial, however I would like to add Slack notifications for our team without affecting the original .travis.yaml, so I was asking myself if it was possible to somehow define a secondary configuration file and add it to .gitignore (if that's ok with the original repo owners). Would this be possible? Is there any other way around the problem?
Looking at the code it seems like .travis.yml is hard-coded and there's no way to override that or have a secondary file, is it?

Related

Can I automatically create a label on a github repo?

Our organisation stores code on github and there are certain ways-of-working that we want new repos created by our team to adhere to (e.g. there is a default set of workflows at .github/workflows that each repo should have, a basic .gitignore, linter config files in .github, etc..). Hence we have built repo templates that people can instantiate using a tool called cookiecutter. Its working really well. Note though that cookiecutter only automates the creation of content, it doesn't actually create the git repo (i.e. it doesn't run git init) and it doesn't create anything on github. Hence, the workflow for someone to use one of our templates is:
cookiecutter --output-dir new-repo-name https://github.com/our-org/our-template-repo
cd new-repo-name
git init
gh repo create new-repo-name --private --source=. --remote=upstream
git add .
git push
Hopefully you get the idea.
We then had an idea that we would like to be able to track all the github repos that get created from our templates. We thought a nice way of doing that would be to ensure that each of those repos had a certain label on them.
Hence I'd like to be able to automatically create labels on such newly created repos. Does anyone know a way of doing that? (I was hoping there was perhaps a way of achieving it by putting a certain file into the .github directory, but alas it seems there is no such thing.)
The only labels that come to my mind are the classic GitHub Labels for issues and pull requests. You can also create them with the GitHub CLI. In your case you could add something like gh label create template --description "Created with template xyz" --color 348AA7 to your script. Let me know if this was helpful.

Github actions failed to deploy Jekyll website on Github pages

I have setup a local Jekyll site that is configured to deploy to Github pages. I used the "Chirpy" theme (see https://github.com/cotes2020/jekyll-theme-chirpy) and followed the instructions successfully to get it to deploy the first time.
I am trying to get my 2nd commit w/ updates to deploy but the process is failing when the Github action runs. I see this output:
This is my first attempt at any of this so don't have any perspective on what is going on w/ any of these technologies.
Thanks for any help and LMK what else might make things clearer!
It seems like after you run test.sh, you tried to switch branches. I suspect that is the problem because it doesn't appear that you tried to git reset or anything like that. I believe your test.sh ran (see these lines) so there are unstaged changes.
If you don't want those changes, you might try a git stash to easily reset. Just a thought.
So the issue was that I checked in the _site and .jekyll-cache directories. Here is the proper .gitignore entries to have the standard gh-pages branch build w/o this problem.
https://github.com/github/gitignore/blob/master/Jekyll.gitignore

Is there a way to prevent some files from appearing on the main branch in the remote repo?

I'm working on a simple project with other people. They use Eclipse to build it, but I don't like Eclipse and wrote a makefile and some batch/bash scripts to do the job for me.
I want to keep track of changes I make to these files, but I don't want others to see them in the main repo (at least not on the default branch, it would be okay to have my own). I could make a subrepo, but I don't want to type the folder each time I build something (besides, keeping makefile NOT in the root would be a bit awkward).
What are my options?
Use MQ-extension
Have adding these needed (personal local) files in MQ-patch(es)
Work locally with patch applied, unapply patch before push

VCS capable of files versioned per user

I have already used some VCS like CVS, SVN and Git. One feature that I am missing cannot be found anywhere.
There are files which I would like to have in the repository but every user should have its own. So when you checkout you get a default of that file and that commit your changes only for yourself.
Why do I want this? There are some files like configuration where I would like to have a default version in the repository (e.g. for building releases or a starting base for new team members) but the changes to that file are only relevant to a certain developer (or working copy) because it will contain paths only valid for that developer/working copy.
Currently when I do not add this files:
- I miss them when creating a new working copy or exporting for a release build
- Have no history which changes I might have done for myself for experimenting
Currently when I add this files to the repository:
- I might never commit them so I have a default in the repository but my file is always flagged "changed". In SVN I can add it to the "ignore-on-commit" changelist to improve a bit.
- I might loose my very own changes of a difficult configuration file (data crash, laptop theft, etc.)
Is there a VCS capable of this? Do SNV or git support something regarding this I might have overseen?
If I understood and decomposed your task correctly
"Have a set of default templates of something, which are starting point of per-user customization and these customized versions must be stored separately and be accessible only by responsible person"
you can use this workflow (draft, subject of modifications and corrections), Subversion based for simplicity and transparent management (strong point of any CVCS really)
Subversion repository
Each user of repo have own predefined path inside repository-tree (with common path-pattern for manageability and easy automation of processes)
One special admin-only managed path also exist, not accessible by ordinary users
Our tree may seems like this (where Repository dir is a root of repository)
z:\>dir /s /B
z:\Repository
z:\Repository\Users
z:\Repository\Template
z:\Repository\Users\Alpha
z:\Repository\Users\Bravo
For every user-path we use Path-based Authentication, which provides access for every and each user only to own subtree in repository,
Template contains (as name assumes) templates stub for all user's documents
Adding new users to repo, obviously, becomes simple and easy automated task:
svn copy Template into new user's dir
add rw permissions for created location for user in authz-file
tell user URL of his personal tree in repo
I don't think the VCS is the problem here. It looks like if you have a file whose contents are dependent on the local environment, you should auto-generate it with a script. This way, you ignore the generated file, but version the script and each developer still gets a perfectly valid copy of the config files at run time. This is the same approach that is used, for example, with user specific IDE settings: .suo files on Visual Studio for example.
Update:
If you specifically need a set of defaults, then the solution is this:
Add the defaults to the repository.
Each dev works in their own branch. This way, they can version the
changes to the config files.
When re-basing onto master and/or merging, the devs simply never
merge their customized configs.
You can always set up a hook to check if the default config has been modified, and if so, maybe email the dev. You simply view such a commit the same as you would view a commit that does not compile.
Devs are smart. Sure, they make mistakes. But never under-estimate the power of some simple communication.
Of course, when the default configs do get overwritten with the customized ones of Dev X, then you use the powers of git to fix that commit immediately.

Mercurial. Version control and deployment. Different config files. How to?

I have a setup as follows.
A private repository at bitbucket where I keep the 'master' repository.
A repository on my server which acts as the 'live' website.
A repository on my laptop which acts as my working copy.
My process is as follows. I make a change to a file in my local repository. I commit these locally. I push these changes to bitbucket. I then pull these changes from my bitbucket to the webserver.
The problem that I have however is that my local copy utilizes different configuration settings for databases, paths etc, ergo what I want is my 'config.php' file at bitbucket to contain the server settings, and the config.php on my local host to contain local settings.
I believe this can be achieved with .hgignore but i have had no success researching.
The problem i encounter is that i make my server settings file, push it to bitbucket, 'forget' the file in my local repository, create a .hgignore, and then recreate the file. However when i 'forget' the file TortoiseHG notices and asks me to commit the change to bitbucket....
Any ideas would be greatly appreciated.
Thanks
Additional Points.
Following the advice below I have developed a setup as follows:
I have my local repository on my laptop where i do my edits.
I have bitbucket which is essentially the 'main' repository - if any other developers join the team they clone this.
I have my live repository on my web host.
On my live repository I have a .hgignore file whichs ignores the respective config files.
As such when I do hg pull from my host, it pulls the repository as is with the localhost configuration files, but when i type hg update (to the live working copy), these files are ignored/not updated.
Could someone clarify as to if i have understood this correctly, and as to whether this is a suitable way of achieving what I want?
Thanks
.hgignore only ignores files if they are not versioned already, so I don’t think your idea in the question will work.
The common approach regarding local configuration is generally a variation on the same theme, like of one of the following:
Do not check in the config.php at all. You can check in a config.example.php with the most common settings, and document in the README that users have to copy it to config.php and then edit it.
Put any shared settings in config.php, and add an include statement to point to an unversioned file with settings specific to the machine, e.g. config.local.php. You can also provide an config.local.example.php-file for this.
Like 2, but the config.php contains all default settings and the local file has the ability to override them.
Check in a config.dev.php and config.server.php-file containing the settings for both environments, and then have an unversioned config.php which includes one of the above files. Advantage is that the configurations themselves are versioned and you can update them.
Which of these variations to pick, or whether you make another variation, depends on your environment.
The basic idea for working with version control and different configuration files is always the same, but I don't know enough PHP to give a detailed answer how you can do this in PHP.
I answered a similar question for .net/Visual Studio a few months ago, so I'll just give you the link to this answer and try to describe the basic idea again, but this time language-agnostic:
For your use case, the basic idea is to have two config files in the repository, one with your local data and one with your server data, for example like this:
config.local.php
config.server.php
The "real" config.php is not in the repository, and it should be in .hgignore, so it never will be in the repository either.
After pulling, you need to run something that copies one of these files (the "correct" one depending on the current environment, local or server) to config.php.
And exactly this last part is the part that I can not answer in detail, because I don't know how to do that in PHP and/or on a web server because I'm a .net/Windows guy.
As far as I know, deploying a PHP site is just copying the files on the web server, so there is no "build/compile" step where the copying/renaming of the config file could be done (where I would do it in .net). Correct me if I'm wrong...
EDIT:
Thomas, I'm not sure if I understood your edits correctly. Your "local" repository on your laptop and your "live" repository on your webserver are basically clones of your "main" repository on Bitbucket, correct?
If yes, are you saying that you have different .hgignore files in the different clones?? That's the part that confuses me.
No matter how you actually do it in the end (there are several possibilities to deal with configuration files, see below), the .hgignore file should be the same in all clones of your repository.
So all your repositories (no matter which clone on which machine) should all contain the same configuration file(s).
Then, you only need to make sure that different configurations are used in different environments. There's already an excellent list of different ways to achieve this in Lauren Holst's answer, so I'll just point you there.
As Laurens Holst already said, we can't tell which of these ways is the best for you - it depends on your environment.
You might want to check here. If both the config file and .hgignore are commited, the .hgignore will have no effect. You could also add a domain check conditional:
$domain = $_SERVER['HTTP_HOST'];
if ($domain=="localhost") {
//local copy config
}
else if ($domain=="yourdomain.com") {
//webserver config
}