Why is my .travis.yml file being ignored? - node.js

Here is my .travis.yml file:
language: node_js
node_js:
- "6.10"
- "6"
cache:
directories:
- node_modules
(It is also available on Github.)
Here is my build log on Travis, showing the wrong Node version:
And here is the versionless config for the same build:
Finally, here is the caching report for my build:
I have tried changing my .travis.yml file in numerous ways, including:
other version strings,
different indentations and line ending combinations,
with and without cache, etc.,
but nothing I do seems to have any effect.
I have enabled "Build only if .travis.yml is present", so apparently it is finding the file itself, just not what's in it. What am I missing?

It turns out there was hidden leading whitespace before my language key. A helpful Travis tech support specialist removed the whitespace and solved my problem.

I had the same problem, but the solution was, that I had a foder named .travis/ in the root directory. I had to rename it to something else and then travis notived the .travis.yml file again

Related

is it wrong to add folder like *folder in .gitignore file?

I have 3 flavours in android studio.
when I create any flavour apk then release folder with apk(+somefile) generated under respected flavour folder and this considers as an unversioned file for git.
because
I don't want in git so I added *release in .gitignore file
is it the wrong way to do?
will it create problem in future?
myApp
- .gradle
- .idea
- build
- app
- build
- flavour1
-release
-app-flavour1-release.apk
-output-metadata.json
- flavour2
-release
-app-flavour2-release.apk
-output-metadata.json
- libs
- src
- flavour1
- somefile
- flavour2
- somefile
- main
- test
- androidTest
- .gigignore
- build.gradle
- proguard-rules.pro
- releasekeystore.jks
- .gigignore
- build.gradle
- openCVLibrary3410
- build
- src
- .gigignore
- lint.xml
- scanlibrary
- build
- src
- .gigignore
- build.gradle
- .gigignore
- build.gradle
- somefile..
I wouldn't say it is wrong, but I would recommend you make sure the pattern in the gitignore file fits with your standard project layout as strictly as possible to avoid the case where someone makes a folder later and it is unexpectedly ignored.
\*release will ignore any file or folder ending in "release" within the same folder as the ignore file. In my projects I often hyphenate special folders like that such as "linux-release" so I would probably use"*-release" in that case to reduce the cases it would match as much as possible.
All this to say that what you have done shouldn't cause any problems but I would go the extra mile to make sure it is not unpredictable to the rest of your team by being more specific in the pattern now.
If you'd like, post a better example of your folder structure to offer more direct advice.
Example of a Different Practice:
In many projects i have worked on we put releases in build/release/android and build/release/ios folders. We have build/ in our .gitignore and use these subfolders of build specifically because every dev knows anything in that folder should be the result of a build or byproducts of it, which are not version conrtolled. So our devs know any folder named build, even in another non-src directory is not something probably shouldnt be used for storing files in git.

What could cause eslint-plugin-prettier to report error on CircleCI but be silent locally?

I have to migrate from CircleCI 1.0 to 2.0. After I have changed the old configuration to the new one, build failed because of eslint-plugin-prettier reported prettier spacing violations.
MyProject - is my GitHub repo and it contains a folder client which has all front-end code which I want to build on CI. In client folder there are
.eslintrc.json
...
"extends": ["airbnb", "prettier"],
"plugins": ["prettier"],
...
.prettierrc
{
"tabWidth": 4,
"trailingComma": "all",
"singleQuote": true
}
.gitattributes (I work on Windows 10) with the following code:
*.js text eol=crlf
*.jsx text eol=crlf
and of course package.json
New CircleCI configuration:
version: 2
jobs:
build:
working_directory: ~/MyProject
docker:
- image: circleci/node:6.14.3-jessie-browsers
steps:
- checkout
- run:
name: Install Packages
command: npm install
working_directory: client
- run:
name: Test
command: npm run validate
working_directory: client
Old CircleCI configuration:
## Customize dependencies
machine:
node:
version: 6.1.0
# Remove cache before new build. It takes much time
# but fixing a build which is broken long time ago (and not detected because of cache)
# is even more time consuming
dependencies:
post:
- rm -r ~/.npm
## Customize test commands
test:
override:
- npm run validate
general:
build_dir: client
The build fails due to linting problems (all are about the number of spaces):
So, what could cause these errors? I am out of ideas here. I first thought it might be because .prettierrc was not found. However, when I deleted it for an experiment and run locally I got errors in all files in total more than 1000. While on CI with .prettierrc in place there are were only 188 in few files.
I have finally figured it out.
My package.json file contained the following dependency on the Prettier:
"prettier": "^1.11.1".
I had to learn hard way the meaning of this little symbol ^. It allows installing any version of Prettier which is compatible with 1.11.1. In my case on CircleCI 2.0 it installed 1.14.2 which adds new features to Prettier.
I believe it did not break on CircleCI version 1.0 and locally because of cached node_modules which contained earlier Prettier versions compatible with 1.11.1
Here is nice video about semantic versioning.
In my case the problem was with the pattern.
The eslint src/**/*.{ts,tsx} command failed in GitLab CI, but not on local.
When I changed it to eslint src it failed both on local and CI.

Should I add yarn-error.log to my .gitignore file?

Yarn has created yarn.lock and yarn-error.log.
I have been told not to add yarn.lock to my .gitignore file because it locks down the packages.
Should I ignore the latter?
It makes sense to ignore the yarn-error.log—log files are only useful to debug your own copy of the code, so there's no need to upload it to the repository.
File should be uploaded to your repo when they are useful or needed to build your project. The yarn-error.log (as the name suggests) is an error log, so it's never read by Yarn. The whole point of it is that you read the log to find out what went wrong, and if you've not had any errors, it might not even exist at all.
gitignore.io, a service which generates .gitignore files, include yarn-error.log and yarn-debug.log in their .gitignore file for Node:
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
It may be wise to follow their example if you're not sure what you need—most pre-made .gitignore files have thought this issue through and concluded that logs should generally be ignored.
Since writing this I realise all log files are typically ignored in the .gitignore file with this entry:
*.log
Its system specific log file for the user. So it should be added to gitignore.
some times we find error that is "cannot find symbol" when build the project.
to solve that problem we add this file to our root project.
we can use it in our project where all all files and folder are available.
just above to yarn.log file

Travis-CI with jasmine-node

I'm trying to get travis-ci to test my nodejs module with jasmine-node. When I run the tests from the commandline, they all pass, but for whatever reason, Travis always reports my build as failing. My .travis.yml looks like this:
language: node_js
node_js:
- 0.6
- 0.8
and my package.json looks like this:
"scripts": {
"test": "jasmine-node tests/*.spec.js"
}
I've tried adding a before_script to my travis.yml
language: node_js
node_js:
- 0.6
- 0.8
before_script:
- "sudo npm i -g jasmine-node"
Any ideas?
After spending some time with the travis-ci lint web app, it looks like it just came down to a matter of formatting in my .travis.yml file. My text editor was inserting tabs, where it appears that yaml requires you only use spaces. I also added quotes around everything for good measure.
It now looks like this, after making sure I was only using single spaces and newlines:
language: node_js
node_js:
- "0.6"
- "0.8"
before_script:
- "npm i -g jasmine-node"
Here is a repository with a working exemple of a travis build launching jasmine-node tests: https://github.com/yosethegame/yosethegame.
Note that the package.json declares the jasmine-node dependency that travis will install in its npm install phase.
I had a similar problem some time ago, I was using at the time jasmine-node -g and since it was a simple kata I thought there was no need for adding a package.json in the folder, but when I moved onto integrating that same project with travis-ci, I went through hell to be able to configure it.
With time I've learnt that it is better to keep things nice and tight and use your friendly package.json instead of global installations (There is a good post talking about it here for example: Why to avoid global test runners )
My advice would be for you to add jasmine-node to the package.json, something as short as this
{
"name" : "XXX",
"version" : "1.0.0",
"devDependencies" : {
"jasmine-node" : "latest"
},
"scripts" : {
"test" : "jasmine-node specs/*spec.js"
}
}
Will surely save you a headache and tons of configuring time not only with travis-ci integration, and it may as well save someone else's time in case someone wants to reuse what you've done. ;)

Using Travis-CI for Node.js project

I'm trying to set up travis-ci for my node.js project hosted on github. For some reason travis keeps using ruby worker for building/testing the project.
My .travis.yml looks like:
language: node_js
node_js:
- 0.6
script:
- "make test"
What am I missing?
OK got it.
The .travis.yml file must not contain 'tab' characters. Instead I have replaced them with spaces.

Resources