Yii2: Skip CI or js tests depending on changed files

Created on 14 Nov 2016  路  14Comments  路  Source: yiisoft/yii2

Even we can include [skip ci] in commit message to skip Travis build, many users do not know about it or just forget to add it (I found myself forget to add it multiple times when editing the docs).

Even it's not something crucial, we can have a custom hook to scan changed files, and if it contains only .md files - add [skip ci] in case if it's missing. But there is also [ci skip] alias and skipping build can not be limited to editing only .md files. Such changes can involve PHPDoc comments, regular comments, etc.

But even adding it only for .md related changes can be useful.

In the same manner we can analyze and automatically add [skip js] (#12992) in case there are no .js files in changed files list.

P.S. However maybe it's not worth implementing and it's just me overcomplicating things.

This is just a raw idea, decided to share it.

ready for adoption test

Most helpful comment

Script that prints files modified by commit/PR: https://github.com/melpa/melpa/blob/master/travis-changed-files
Related bug: https://github.com/travis-ci/travis-ci/issues/5133

It does not look so hard to do. We could grep results from this script, filter by file extension and:

  • skip PHP tests if only .md or .js files have been modified;
  • skip JS tests if only .md and .php files have been modified;

It will not prevent triggering build, but we could skip tests and some installation steps.

All 14 comments

It's nice to have and we can accept a pull request with it. Any idea about implementation?

The current idea is to use custom git hook and somehow pass this info to Travis, via environment variable maybe. Will try to think of a better solution.

https://github.com/yiisoft/yii2/issues/12992#issuecomment-260281581

It will pollute log messages much. Is there a way to do it w/o marking commit messages with it?

For js - do it vice versa (not mark everything with [skip js] but to mark only nesessary with [test js] for example)

@SDKiller Yes, initially I wanted to suggest this option as alternative, but forgot to mention it as a result.

The disadvantage is that in case of human factor (person forgets to include it) js tests will not be executed at all. It can be revealed during PR's code review though. But we can cover it (at least partially) with automatic checks.

Another thing regarding js.
I recall some time ago it was suggested to separate all js stuff from framework in 2.1 (@creocoder suggested, if I'm not mistaken).
I suppose it will also be helpful for testing purposes - as different travis setup could be configured for this separate repo.

Yes, it will be even better and easier for testing and Travis CI setup. We can register bower / npm package and include it along with other dependencies.

@arogachev, what's the status of this topic?

I do not see a reliable way to trigger this. There must be some kind of native support from travis to support this as far as I see. I am for closing it. The idea is great in general but a solution seems not easy to implement.

Script that prints files modified by commit/PR: https://github.com/melpa/melpa/blob/master/travis-changed-files
Related bug: https://github.com/travis-ci/travis-ci/issues/5133

It does not look so hard to do. We could grep results from this script, filter by file extension and:

  • skip PHP tests if only .md or .js files have been modified;
  • skip JS tests if only .md and .php files have been modified;

It will not prevent triggering build, but we could skip tests and some installation steps.

Good find! If someone wants to work on this. PR welcome :)

@cebe I'll work on this.

Note that now Code Climate will run regardless of [skip ci] presence. When editing just .md files it's a bit annoying. Is there a separate option for skipping it too?

I could not find any way to skip code climate in their docs. Lets focus on travis for now.

Not needed anymore since we've switched from Travis to GitHub actions.

Was this page helpful?
0 / 5 - 0 ratings