# Rules for where jobs can run

.run_on_code_change:
  # The following rules are intended to include all files and directories
  # except the `Documentation` directory.
  rules:
      changes: &code_change
        - '!Documentation/**/*'
        - '**/*'
        - '.*'                # any hidden file is touched
        - '.*/**/*'           # any file within a hidden directory
      when: on_success


.run_automatically:
    rules:
        - if: '$CI_MERGE_REQUEST_ID'
          changes: *code_change
          when: on_success
        - if: '$CI_PROJECT_PATH == "vtk/vtk"'
          changes: *code_change
          when: on_success
        - when: never

.scheduled_only:
    rules:
        - if: '$CI_MERGE_REQUEST_ID'
          when: never
        - if: '$CI_COMMIT_TAG && $CI_PROJECT_PATH == "vtk/vtk"'
          changes: *code_change
          when: on_success
        - if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_PATH == "vtk/vtk"'
          changes: *code_change
          when: on_success
        - when: never

.run_manually:
    rules:
        - if: '$CI_MERGE_REQUEST_ID'
          changes: *code_change
          when: manual
        - if: '$CI_PROJECT_PATH == "vtk/vtk" && $CI_PIPELINE_SOURCE == "schedule"'
          changes: *code_change
          when: on_success
        - if: '$CI_PROJECT_PATH == "vtk/vtk"'
          changes: *code_change
          when: delayed
          start_in: 4 hours
        - when: never

.merged_only:
    rules:
        - if: '$CI_MERGE_REQUEST_ID'
          when: never
        - if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_PATH == "vtk/vtk"'
          changes: *code_change
          when: on_success
        - if: '$CI_PROJECT_PATH == "vtk/vtk"'
          changes: *code_change
          when: delayed
          start_in: 4 hours
        - when: never

.release_only:
    rules:
      - if: '$CI_COMMIT_TAG && $CI_PROJECT_PATH == "vtk/vtk"'
        when: on_success
      - when: never

.upload_only:
    rules:
      - if: '$RSYNC_UPLOAD_ENABLE == "true"'
        when: on_success
      - when: never

.weekly_upload_only:
    rules:
        - if: '$CI_MERGE_REQUEST_ID'
          when: never
        - if: '$CI_PROJECT_PATH == "vtk/vtk" && $CI_COMMIT_TAG'
          when: on_success
        - if: '$PYPI_WEEKLY_UPLOAD == "true"'
          when: on_success
        - when: never

.tag_only:
    rules:
        - if: '$CI_MERGE_REQUEST_ID'
          when: never
        - if: '$CI_PROJECT_PATH == "vtk/vtk" && $CI_COMMIT_TAG'
          when: on_success
        - when: never
