travis-ci / beta-features

The perfect place to leave feedback and comments on newly released Beta Features.
56 stars 68 forks source link

Use of Build Stages and missing top-level stanzas #42

Closed gmr closed 6 years ago

gmr commented 6 years ago

It appears that if I have a config as such using build stages:

sudo: false
language: python
python:
 - 2.7
 - 3.4
 - 3.5
 - 3.6
 - pypy
 - pypy3
stages:
 - test
 - name: upload_coverage
   if: branch = master
 - name: deploy
   if: tag IS present
jobs:
  include:
   - stage: test
     install:
      - pip install awscli
      - pip install -r requires/testing.txt
      - python setup.py develop
     services:
      - postgres
     script: nosetests
     after_success:
       - aws s3 cp ...
   - stage: upload coverage
     python: 3.6
     install:
     - pip install awscli coverage codecov
     script:
      - echo "Hello"
     after_success: codecov
   - stage: deploy
     python: 3.6
     deploy:
       distributions: sdist bdist_wheel

That no action will be taken as part of the install, script, or after_success steps unless the top-level install`,script, andafter_success`` stanzas are defined.

My expectation was that by defining them under the job stanzas it would work but my guess is there's per-job munging that occurs between the top level value and the values in the list and if there is no top level entry for that stanza it is ignored.

iriberri commented 6 years ago

Hi @gmr,

Thanks for reporting this issue!

When some steps aren't explicitly configured, Travis will automatically run default commands depending on the language that you're using. In the case of Python (https://docs.travis-ci.com/user/languages/python/) the default behavior is to run the following install command:

pip install -r requirements.txt

If you need to skip these default steps, you can use install: skip or install: true either in the top level section or inside the jobs that don't need to run anything in the install section.

Does this help?

gmr commented 6 years ago

I've got a test right now running with:

before_install: true
install: true
before_script: true
script: true
after_success: true

at the top level stanza, will report back shortly. If that works, then I think it would be valuable to update the example documentation to explain the expected behavior of the merging/overwriting of non-declared implied configuration directives. (That is if you're relying on the implied top level behavior, you can not overwrite it in a stage).

gmr commented 6 years ago

Ok, I think what's going on is if i try and define the "test" stage under the jobs > include stanza, it is ignored. I shifted my structure to something similar to the following and it now works as expected across all stages. Seems a bit backwards from what I'd expect.

language: python

env:
  global:
   - PATH=$HOME/.local/bin:$PATH

stages:
- test
- coverage
- name: deploy
  if: tag IS present

services:
- rabbitmq

before_install:
- python --version
- pip --version

install:
- pip install -r test-requirements.txt

before_script:
- pip freeze
- sudo rabbitmqctl status

script: nosetests

after_success:
- aws s3 cp .coverage "s3://com-gavinroy-travis/pika/$TRAVIS_BUILD_NUMBER/.coverage.${TRAVIS_PYTHON_VERSION}"

jobs:
  include:
   - python: 2.7
   - python: 3.4
   - python: 3.5
   - python: 3.6
   - stage: coverage
     python: 3.6
     before_install: true
     install:
     - pip install awscli coverage codecov
     brefore_script: true
     script:
     - mkdir coverage
     - aws s3 cp --recursive s3://com-gavinroy-travis/pika/$TRAVIS_BUILD_NUMBER/ coverage
     - cd coverage
     - coverage combine
     - cd ..
     - mv coverage/.coverage .
     - coverage report
     after_success: codecov
   - stage: deploy
     python: 3.6
     before_install: true
     install: true
     before_script: true
     script: true
     after_success: true
     deploy:
       distributions: sdist bdist_wheel
joshk commented 6 years ago

Thanks for the feedback @gmr

As Stages is now released and GA, I'm going to close this issue.

If you have any feedback on improvements we should consider, please feel free to add a discussion in our new Community forum: https://travis-ci.community/c/product

Happy building

Josh