Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.89 KiB
Newer Older
  # 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

Florian Sesser's avatar
Florian Sesser committed
docs:
Florian Sesser's avatar
Florian Sesser committed
  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"
Florian Sesser's avatar
Florian Sesser committed

unit-tests:
Florian Sesser's avatar
Florian Sesser committed
  script:
    - "nix-build --attr unit-tests && cat result"
.morph-build: &MORPH_BUILD
  timeout: "3 hours"
      # GRID is set in one of the "instantiations" of this job template.
      nix-shell --run "morph build --show-trace morph/grid/${GRID}/grid.nix"

morph-build-localdev:
  <<: *MORPH_BUILD
  variables:
    GRID: "local"

  before_script:
    - |
      # The local grid configuration is *almost* complete enough to build.  It
      # just needs this tweak.
      echo '{}' > morph/grid/${GRID}/public-keys/users.nix

morph-build-testing:
  <<: *MORPH_BUILD
  variables:
    GRID: "testing"


morph-build-production:
  <<: *MORPH_BUILD
  variables:
    GRID: "production"


vulnerability-scan:
  stage: "test"
  script:
    - "ci-tools/vulnerability-scan security-report.json"
Jean-Paul Calderone's avatar
Jean-Paul Calderone committed
    - "ci-tools/count-vulnerabilities <security-report.json"
  artifacts:
    paths:
Jean-Paul Calderone's avatar
Jean-Paul Calderone committed
      - "security-report.json"
    expose_as: "security report"
Florian Sesser's avatar
Florian Sesser committed
system-tests:
  stage: "test"
  timeout: "3 hours"
Florian Sesser's avatar
Florian Sesser committed
  script:
    - "nix-build --attr system-tests"
# A template for a job that can update one of the grids.
.update-grid: &UPDATE_GRID
  stage: "deploy"
    env --ignore-environment - \
      NIX_PATH="$NIX_PATH" \
      GITLAB_USER_LOGIN="$GITLAB_USER_LOGIN" \
      CI_JOB_NAME="$CI_JOB_NAME" \
      CI_PIPELINE_SOURCE="$CI_PIPELINE_SOURCE" \
      CI_COMMIT_BRANCH="$CI_COMMIT_BRANCH" \
      ./ci-tools/update-grid-servers "${PRIVATESTORAGEIO_SSH_DEPLOY_KEY_PATH}" "${CI_ENVIRONMENT_NAME}"
# Update the staging deployment - only on a commit to the develop branch.
update-staging:
  <<: *UPDATE_GRID
  # https://docs.gitlab.com/ee/ci/yaml/#rules
  rules:
    # https://docs.gitlab.com/ee/ci/yaml/index.html#rulesif
    # https://docs.gitlab.com/ee/ci/jobs/job_control.html#cicd-variable-expressions
    # https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
    - if: '$CI_COMMIT_BRANCH == "develop"'
    # You can find some status information about environments in GitLab at
    # https://whetstone.privatestorage.io/privatestorage/PrivateStorageio/-/environments.
    # The URL controls where the "View Deployment" button for this environment
    # will take you.  The main website isn't controlled by this codebase so we
    # don't point there.  The monitoring system *is* controlled by this
    # codebase and it also tells us lots of stuff about other things
    # controlled by this codebase so that seems like a good place to land.
    # Not that I make it a habit to visit the deployment using the GitLab
    # button...  Still, discoverability or something.
    url: "https://monitoring.privatestorage-staging.com/"
# Update the production deployment - only on a commit to the production branch.
deploy-to-production:
  # https://docs.gitlab.com/ee/ci/yaml/#rules
  rules:
    # https://docs.gitlab.com/ee/ci/yaml/index.html#rulesif
    # https://docs.gitlab.com/ee/ci/jobs/job_control.html#cicd-variable-expressions
    # https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
    - if: '$CI_COMMIT_BRANCH == "production"'

    name: "production"
    url: "https://monitoring.private.storage/"