how to run commands separately with tox-travis - travis-ci

I am trying to run lint and tests separately with tox-travis, but I cannot seem to get the right combo.
Here are the two base files:
tox.ini
[tox]
envlist = py27, py34, py35, py36, lint
[travis]
python =
3.6: py36
3.5: py35
3.4: py34
2.7: py27
[travis:env]
LINT =
yes: py36, lint
[testenv:lint]
....
[testenv]
...
commands =
pip install -U pip
py.test --basetemp={envtmpdir}
travis.yml
language: python
python:
- 3.6, lint
- 3.5
- 3.4
- 2.7
matrix:
include:
- python: 3.6
env:
- LINT=yes
install: pip install -U tox-travis
script: tox
When python={3.6,3.5,3.4,2.7} and LINT is not set only tests are
run. (correct).
When python=3.6 and LINT=yes it runs NEITHER lint
or tests. (incorrect)
Setting
LINT =
yes: lint
When python={3.6,3.5,3.4,2.7} and LINT is not set only tests are
run. (correct).
When python=3.6 and LINT=yes it runs neither
tests or lint. (incorrect)
Setting: 3.6: py36,lint and yes: lint runs lint whenever python=3.6 regardless of LINT value.
What am I doing wrong here?

Related

Private Azure PYPI not reachable in azure pipelines run

I have a project A managed with pipenv that depends on another project B built with pipenv too. The project B is published in the private PYPI. My Pipfile looks like
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[[source]]
url = "https://${USERNAME}:${TOKEN}#MyPrivateRepoUrl"
verify_ssl = true
name = "MyRepoPYPI"
When I install A locally I have not problems and every works fine (declaring environment variables with export command). I have configured an azure-pipelines.yml with 2 jobs, first install A and testing, and the second one is to build and publish the docker image to the ACR. When I trigger the pipeline, the first job fails with this error:
FAIL
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/resolver.py", line 741, in _main
[ResolutionFailure]: resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/resolver.py", line 709, in resolve_packages
[ResolutionFailure]: requirements_dir=requirements_dir,
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/resolver.py", line 692, in resolve
[ResolutionFailure]: req_dir=requirements_dir
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/utils.py", line 1403, in resolve_deps
[ResolutionFailure]: req_dir=req_dir,
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/utils.py", line 1108, in actually_resolve_deps
[ResolutionFailure]: resolver.resolve()
[ResolutionFailure]: File "/home/adminroot/.local/lib/python3.7/site-packages/pipenv/utils.py", line 833, in resolve
[ResolutionFailure]: raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: Could not find a version that matches pymooslotting (from -r /tmp/pipenvzsh1c47crequirements/pipenv-y37q7d_w-constraints.txt (line 11))
No versions found
Were https://pypi.org/simple or https://MyUsername:***#MyPrivateRepoUrl reachable?
I'm pretty sure the credentials are set correctly.
The amazing thing is that if I run the second job, the docker image is built correctly, therefore it is telling me that the credentials to install B are being passed correctly.
here is the part of the pipelines where I install A
steps:
- task: UsePythonVersion#0
inputs:
versionSpec: '3.7'
architecture: 'x64'
- script: |
python -m pip install --user --upgrade pip
python -m pip install --user pipenv
displayName: Install Pipenv
- script: |
pipenv lock --clear
pipenv install --system
displayName: Install Dev Dependencies
- bash: pytest -rf
displayName: Unit test
I'm not commiting the lock file, but I have done many tests that include the lock in the repo.
Here is the command for docker Publish (that works fine and do the job)
- task: Docker#2
displayName: Build Docker Image
inputs:
command: build
containerRegistry: $(acrRepository)
repository: samples/execslotting
inputs:
tags: |
latest
$(tag)
arguments: '--build-arg USERNAME=$(MyUserName) --build-arg TOKEN=$(MyToken)'
The docker image is installing B, so in the build I pass USERNAME and TOKEN vars.
OBS: The error message No versions found Were https://pypi.org/simple or https://MyUsername:***#MyPrivateRepoUrl reachable? tells me that the envars are correctly read in the execution of the installation job.
the docs specify a different push and pull endpoint urls for pip... Try appending /pypi/simple to the repo description where you are pulling from.
full url: https://<your-feed-name>:<your-PAT-key>#pkgs.dev.azure.com/<your-organization-name>/<your-project-name>/_packaging/<your-feed-name>/pypi/simple/

How can I configure Travis CI to test correct loading a library repo under PlatformIO?

I have a library used by a number of Arduino projects. I use PlatformIO as my build system, so I've created a library.json file in the root of the library to identify dependent libraries that should be loaded when I include this library in a project. All good.
Sometimes the dependent libraries get changed - PlatformIO is particularly sensitive to renaming them in the Arduino library.properties file. It is a pain when I discover that my library is broken only when I try to build a project that uses it.
I'd like to configure Travis to run periodically (thanks, Travis cron jobs!) and confirm that I can load all dependent libaries.
pio ci does not really apply to libraries. pio test requires a PlatformIO subscription (highly recommended, but not always an option).
Put the following in .travis.yml:
```
PlatformIO dependency test
- language: python
python: 2.7
install:
- pip install -U platformio
script:
- mkdir test_platformio_deps
- cd test_platformio_deps
- echo "[env:adafruit_feather_m0]" > platformio.ini
- echo "platform = atmelsam" >> platformio.ini
- echo "board = adafruit_feather_m0" >> platformio.ini
- echo "framework = arduino" >> platformio.ini
- if [ "${TRAVIS_PULL_REQUEST_SLUG}" = "" ]; then echo "lib_deps = SPI, https://github.com/${TRAVIS_REPO_SLUG}" ; else echo "lib_deps = SPI, https://github.com/${TRAVIS_PULL_REQUEST_SLUG}#${TRAVIS_PULL_REQUEST_BRANCH}" ; fi >> platformio.ini
- cat platformio.ini
- mkdir src
- echo "int main() {}" > src/main.cpp
- platformio run
cache:
directories:
- "~/.platformio"
```
It will create a simple project that depends on your library and then attempt to build it. If all dependencies load, it will succeed.
The tricky line with TRAVIS_PULL_REQUEST_SLUG handles running the test within a PR.

Grails: command not found with Travis-CI

I want to use Travis-CI with my Grails 3.0.9 app. For this I created a .travis.yml file:
language: groovy
jdk:
- oraclejdk7
before_install:
- curl -s get.sdkman.io | bash
- source "$HOME/.sdkman/bin/sdkman-init.sh"
- sdk install grails 3.0.9
- sdk default grails 3.0.9
script: grails test-app --stacktrace
When the Travis-CI service wants to build my application, it ends up with this error:
$ export GRAILS_HOME=/home/travis/.sdkman/candidates/grails/3.0.9/
$ export PATH=$PATH:$GRAILS_HOME/bin
$ ./gradlew assemble
...
(downloading a lot of gradle dependencies)
...
BUILD SUCCESSFUL
$ grails test-app
/home/travis/build.sh: line 45: grails: command not found
So do I have to install Grails somehow else or is it because of a missing/wrong path variable?
I've found a working .travis.yml here:
language: groovy
jdk:
- oraclejdk7
before_install:
- curl -s http://get.sdkman.io | bash
- echo sdkman_auto_answer=true > ~/.sdkman/etc/config
- source "/home/travis/.sdkman/bin/sdkman-init.sh"
- sdk install grails 3.0.9
script: grails test-app --stacktrace
Update:
Use get.sdkman.io since get.gvmtool.net doesn't work anymore.

Travis build stucks on jacoco

This is my travis.yml
language: java
sudo: required
jdk:
- oraclejdk8
install: true
script:
- sudo apt-get update && sudo apt-get install oracle-java8-installer
- java -version
after_success:
- ./gradlew test jacocoTestReport coveralls
And this is the travis output:
[...]
:processTestResources
:testClasses
:test
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.7.5.201505241946/org.jacoco.agent-0.7.5.201505241946.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.build/0.7.5.201505241946/org.jacoco.build-0.7.5.201505241946.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.7.5.201505241946/org.jacoco.agent-0.7.5.201505241946.jar
No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.
The build has been terminated
I have no idea why and how I can debug this :\ any hints?
Works on my machine.
It turned out it has nothing to do with jacoco. I'm using JavaFX with TestFX and, of course, it needs a frame buffer. It works after enabling xvfb:
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"

I am having trouble understanding what is wrong with my travis build

I am playing with travis-ci for the first time and have run into an error thats confusing me.
Below is my .travis.yml which validates when linted.
language: node_js
node_js:
- 0.8
after_script:
- echo "Hello World"
The following is my travis build output:
$ git clone --depth=50 --branch=master git://github.com/iancrowther/travis-experiment.git iancrowther/travis-experiment
Cloning into 'iancrowther/travis-experiment'...
remote: Counting objects: 27, done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 27 (delta 2), reused 20 (delta 0)
Receiving objects: 100% (27/27), done.
Resolving deltas: 100% (2/2), done.
$ cd iancrowther/travis-experiment
git.2
$ git checkout -qf xxx
$ nvm use 0.8
Now using node v0.8.22
$ node --version
v0.8.22
$ npm --version
1.2.14
$ make test
make: *** No rule to make target `test'. Stop.
The command "make test" exited with 2.
after_script
$ echo "Hello World"
Hello World
Done. Your build exited with 1.
How can i prevent the make file being executed?
Any help would be great, I cant seem to ind the errors explained in the doc's
Ian
ps. does anyone have any links to a guide about styling code??
UPDATE
when #User re-formatted the question, they added the following comment: "used {} button to make the code visible".
change after_script to script
Have a look at this .travis.yml :
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq python3.2 python2.7
python:
- "2.7"
script: ./run_build.sh
The last line is the important one.
script is the command that runs the test.
before is something that enables the test to run
and after is something to clean up.
It is the same pattern you may know from unittests. Setup, Test, Teardown
Since Travis does not find a script: I guess it takes a default option for testing.

Resources