diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index abc30c2..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,80 +0,0 @@ -version: 2 - -jobs: - build-nix: - - machine: - enabled: true - - steps: - - - run: - name: Prepare nix directories - command: | - sudo mkdir -p /nix - sudo chown circleci /nix - - sudo mkdir -p /etc/nix - - # Enable sandbox - echo "sandbox = true" | sudo tee -a /etc/nix/nix.conf - - # Keep derivations and their outputs for better caching - echo "keep-outputs = true" | sudo tee -a /etc/nix/nix.conf - echo "keep-derivations = true" | sudo tee -a /etc/nix/nix.conf - - # Set a new TMP because /run/user is (1) pretty small and (2) - # mounted with noexec - new_tmp=$HOME/tmp - mkdir -p $new_tmp - echo "export TMPDIR=$new_tmp" >> $BASH_ENV - - - run: - name: Install Nix - command: | - until bash <(curl https://nixos.org/nix/install) - do - echo "Nix install failed, retrying" - sudo rm -rf /nix - sudo mkdir -p /nix - sudo chown circleci /nix - done - echo '. /home/circleci/.nix-profile/etc/profile.d/nix.sh' >> $BASH_ENV - - - checkout - - - run: - name: Nix build - command: ./script/test - - - run: - name: "Update Node.js and npm (master only)" - command: | - if [ "$CIRCLE_BRANCH" == "master" ]; then - nix-env -f ./nix -iA nodejs-10_x - fi - - run: - name: "Install netlify-cli (master only)" - command: | - if [ "$CIRCLE_BRANCH" == "master" ]; then - npm install netlify-cli - fi - - - run: - name: "Netlify deploy (master only)" - command: | - if [ "$CIRCLE_BRANCH" == "master" ]; then - echo "Deploying to production" - ./node_modules/netlify-cli/bin/run deploy \ - --dir=./site \ - --message="$CIRCLE_SHA1" --prod - else - echo "Not deploying" - fi - -workflows: - version: 2 - build: - jobs: - - build-nix: - context: niv-netlify diff --git a/.github/workflows/netlify.yml b/.github/workflows/netlify.yml new file mode 100644 index 0000000..98b4e25 --- /dev/null +++ b/.github/workflows/netlify.yml @@ -0,0 +1,21 @@ +name: "netlify deploy" +on: + push: + branches: + - master +jobs: + netlify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: cachix/install-nix-action@v6 + - name: "deploy to netlify" + env: + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + run: | + nix-env -f ./nix -iA nodejs-10_x + npm install netlify-cli + ./node_modules/netlify-cli/bin/run deploy \ + --dir=./site \ + --message="$GITHUB_SHA" --prod diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..df4cda0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,13 @@ +name: "Test" +on: + push: +jobs: + tests: + strategy: + matrix: + os: [ubuntu-18.04, macos] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v1 + - uses: cachix/install-nix-action@v6 + - run: ./script/test diff --git a/README.md b/README.md index 9ea6506..ef308ba 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # niv -[![CircleCI](https://circleci.com/gh/nmattia/niv.svg?style=svg)](https://circleci.com/gh/nmattia/niv) +![GitHub Actions](https://github.com/nmattia/niv/workflows/Test/badge.svg?branch=master) [![Netlify Status](https://api.netlify.com/api/v1/badges/48532eaa-259f-4ca2-aadf-67f7c6b957fd/deploy-status)](https://niv.nmattia.com) Painless dependencies for [Nix] projects. Read more in the [Getting started](#getting-started) section below. diff --git a/README.tpl.md b/README.tpl.md index 951b1ee..6351b73 100644 --- a/README.tpl.md +++ b/README.tpl.md @@ -1,6 +1,6 @@ # niv -[![CircleCI](https://circleci.com/gh/nmattia/niv.svg?style=svg)](https://circleci.com/gh/nmattia/niv) +![GitHub Actions](https://github.com/nmattia/niv/workflows/Test/badge.svg?branch=master) [![Netlify Status](https://api.netlify.com/api/v1/badges/48532eaa-259f-4ca2-aadf-67f7c6b957fd/deploy-status)](https://niv.nmattia.com) Painless dependencies for [Nix] projects. Read more in the [Getting started](#getting-started) section below. diff --git a/script/test b/script/test index 4fb850b..28e3193 100755 --- a/script/test +++ b/script/test @@ -13,7 +13,23 @@ export NIX_PATH="nixpkgs=./nix" echo "Building" +nixargs=( + "--no-link" + "--max-jobs" "10" +) + + +if [[ ! $OSTYPE =~ darwin ]]; then + echo "Not testing on darwin" + echo "Enabling sandbox, running all tests" + nixargs+=("--sandbox") +else + echo "Testing on darwin" + echo "Not enabling sandbox, not running integration" + nixargs+=("-A" "niv-test") +fi + # Build and create a root -nix-build --sandbox --no-link --max-jobs 10 +nix-build ${nixargs[@]} echo "all good" diff --git a/tests/git/default.nix b/tests/git/default.nix index 67e307e..b1dc07f 100644 --- a/tests/git/default.nix +++ b/tests/git/default.nix @@ -5,6 +5,14 @@ pkgs.runCommand "git-test" { nativeBuildInputs = [ pkgs.git niv pkgs.nix pkgs.jq ]; } ( + + # make sure the tests run smoothly in multi-user install + # https://github.com/NixOS/nix/issues/3258 + '' + export NIX_STATE_DIR=$TMPDIR + export NIX_LOG_DIR=$TMPDIR + export HOME=$TMPDIR + '' + # First we create a dummy git repo with one commit on master, and one commit # on "branch". ''