0

.gitlab-ci.yml with

stages:
  - test

jobs:
  lint:
    stage: test
    image: python:3.8  # Assuming same image for both jobs
    script:
      - pip install black
      - black --check .  
    allow_failure: false 

  testcov:
    stage: test
    image: python:3.8
    script:
      - pip install pytest pytest-cov
      - pytest --cov api/
      - curl -Os https://cli.codecov.io/latest/linux/codecov
      - chmod +x codecov
      - ./codecov upload-process -t $CODECOV_TOKEN

fails with

This GitLab CI configuration is invalid: jobs jobs config should implement a script: or a trigger: keyword

However the same without jobs and stages is valid and works

lint:
  image: python:3.8  # Assuming same image for both jobs
  script:
    - pip install black
    - black --check .  
  allow_failure: false 

testcov:
  image: python:3.8
  script:
    - pip install pytest pytest-cov
    - pytest --cov api/
    - curl -Os https://cli.codecov.io/latest/linux/codecov
    - chmod +x codecov
    - ./codecov upload-process -t $CODECOV_TOKEN

is there something that missing in stages version of code?

1 Answer 1

0

In GitLab CI version 13.0 and later, the script keyword should be nested within a before_script or after_script section e.g. for the code above the middle must be replaced with

  before_script:
    - pip install black
  script:
    - black --check .
  allow_failure: false 

testcov:
  stage: test
  image: python:3.8
  before_script:
    - pip install pytest pytest-cov

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.