Skip to content
Snippets Groups Projects
.gitlab-ci.yml 5.66 KiB
# Define rules for a job that should run for events related to a merge request
# - merge request is opened, a new commit is pushed to its branch, etc.  This
# definition does nothing by itself but can be referenced by jobs that want to
# run in this condition.
.merge_request_rules: &RUN_ON_MERGE_REQUEST
  rules:
    # If the pipeline is triggered by a merge request event then we should
    # run.
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

    # If the pipeline is triggered by anything else then we should not run.
    - when: "never"

# As above, but rules for running when the scheduler triggers the pipeline.
.schedule_rules: &RUN_ON_SCHEDULE
  rules:
    # There are multiple schedules so make sure this one is for us.  The
    # `SCHEDULE_TARGET` variable is explicitly, manually set by us in the
    # schedule configuration.
    - if: '$SCHEDULE_TARGET != $CI_JOB_NAME'
      when: "never"

    # Make sure this is actually a scheduled run
    - if: '$CI_PIPELINE_SOURCE != "schedule"'
      when: "never"

    # Conditions look good: run.
    - when: "always"

stages:
  - "build"
  - "deploy"

default:
  # Guide the choice of an appropriate runner for all these jobs.
  # https://docs.gitlab.com/ee/ci/runners/#runner-runs-only-tagged-jobs
  tags:
    - "nixos"
    - "shell"

variables:
  # https://docs.gitlab.com/ee/ci/runners/configure_runners.html#job-stages-attempts
  GET_SOURCES_ATTEMPTS: 10

docs:
  <<: *RUN_ON_MERGE_REQUEST
  stage: "build"
  script:
    - "nix-build --attr docs --out-link result-docs"
    # GitLab wants to lchown artifacts.  It can't do that to store paths.  Get
    # a copy of the docs outside of the store.
    - "cp --recursive --no-preserve=mode ./result-docs/docs ./docs-build/"
  artifacts:
    paths:
      - "./docs-build/"
    expose_as: "documentation"

unit-tests:
  <<: *RUN_ON_MERGE_REQUEST
  stage: "build"
  script:
    - "nix-build --attr unit-tests && cat result"

.morph-build: &MORPH_BUILD
  <<: *RUN_ON_MERGE_REQUEST
  timeout: "3 hours"
  stage: "build"
  script:
    - |
      # GRID is set in one of the "instantiations" of this job template.