Skip to content
Snippets Groups Projects
config.yml 3.95 KiB
# Copyright 2019 PrivateStorage.io, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: 2

jobs:
  test:
    docker:
      - image: "nixos/nix:2.2.1"
    steps:
      - run:
          name: "Install Git"
          command: |
            # Required for the checkout step
            nix-env -i git openssh

      - "checkout"

      - run:
          name: "Run Tests"
          command: |
            export NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/$(cat nixpkgs.rev).tar.gz
            nix-build nixos/unit-tests.nix && cat result

  system-tests-driver:
    # Cannot actually run the system tests on CircleCI but we can build
    # everything that makes them up.  This by itself can catch a lot of
    # problems.
    docker:
      - image: "nixos/nix:2.2.1"
    steps:
      - run:
          name: "Install Git"
          command: |
            # Required for the checkout step
            nix-env -i git openssh

      - restore_cache:
          # Get all of Nix's state relating to the particular revision of
          # nixpkgs we're using.  It will always be the same.  CircleCI
          # artifacts and nixpkgs store objects are probably mostly hosted in
          # the same place (S3) so there's not a lot of difference for
          # anything that's pre-built.  For anything we end up building
          # ourselves, though, this saves us all of the build time (less the
          # download time).
          #
          # Read about caching dependencies: https://circleci.com/docs/2.0/caching/
          name: "Restore Nix Store Paths"
          keys:
            # Construct cache keys that allow sharing as long as nixpkgs
            # revision is unchanged.
            #
            # If nixpkgs changes then potentially a lot of cached packages for
            # the base system will be invalidated so we may as well drop them
            # and make a new cache with the new packages.
            - privatestorageio-nix-store-v1-{{ checksum "nixpkgs.rev" }}
            - privatestorageio-nix-store-v1-

      - "checkout"