SCP19: Non-root stack

What it does

Finds stack keys that are defined outside the root level of the scrapinghub.yml shub configuration file, including stacks.default usage.

Why is this bad?

The stack key should always be defined at the root level of the scrapinghub.yml file to ensure that your code base uses the same software stack (Docker image, Python version) in all Scrapy Cloud projects.

While stacks.default is a valid way to define a stack, using a root stack key is more readable and follows the recommended best practice. The root stack key is more explicit and consistent with other root-level configuration options.

Examples

Non-root stack in projects:

projects:
  default:
    id: 12345
    stack: scrapy:2.12-20241202

Instead use:

stack: scrapy:2.12-20241202
projects:
  default:
    id: 12345

Using stacks.default:

projects:
  prod: 12345
  dev: 345
requirements:
  file: requirements.txt
stacks:
  default: "scrapy:2.8"

Instead use:

projects:
  prod: 12345
  dev: 345
requirements:
  file: requirements.txt
stack: "scrapy:2.8"