1
1
mirror of https://github.com/nmattia/niv.git synced 2024-11-07 22:36:53 +03:00

Switch to CI to GitHub Actions

This commit is contained in:
Nicolas Mattia 2019-12-08 15:13:53 +01:00
parent 7edc0de265
commit 424662b47f
7 changed files with 61 additions and 83 deletions

View File

@ -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

21
.github/workflows/netlify.yml vendored Normal file
View File

@ -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

13
.github/workflows/test.yml vendored Normal file
View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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"

View File

@ -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".
''