From 9c945dbf4d30fdf654c4c7a6ace27277dc31c9dd Mon Sep 17 00:00:00 2001 From: kat witch Date: Sat, 15 May 2021 01:28:21 +0100 Subject: [PATCH] ci: Reorganising, shell: Fixes for CI functions --- .github/workflows/{nixfiles.yml => hosts.yml} | 12 +++--- ci.nix => ci/hosts.nix | 2 +- shell.nix | 38 +++++++++++-------- 3 files changed, 29 insertions(+), 23 deletions(-) rename .github/workflows/{nixfiles.yml => hosts.yml} (96%) rename ci.nix => ci/hosts.nix (97%) diff --git a/.github/workflows/nixfiles.yml b/.github/workflows/hosts.yml similarity index 96% rename from .github/workflows/nixfiles.yml rename to .github/workflows/hosts.yml index e1426096..9dcaf803 100644 --- a/.github/workflows/nixfiles.yml +++ b/.github/workflows/hosts.yml @@ -4,7 +4,7 @@ env: CI_PLATFORM: gh-actions jobs: ci-check: - name: nixfiles check + name: hosts check runs-on: ubuntu-latest steps: - id: checkout @@ -25,11 +25,11 @@ jobs: name: gh-actions compare uses: arcnmx/ci/actions/nix/run@master with: - args: -u .github/workflows/nixfiles.yml .ci/workflow.yml + args: -u .github/workflows/hosts.yml .ci/workflow.yml attrs: nixpkgs.diffutils command: diff host-athame: - name: nixfiles-host-athame + name: hosts-host-athame runs-on: ubuntu-latest steps: - id: checkout @@ -86,7 +86,7 @@ jobs: quiet: false stdin: ${{ runner.temp }}/ci.build.cache host-samhain: - name: nixfiles-host-samhain + name: hosts-host-samhain runs-on: ubuntu-latest steps: - id: checkout @@ -143,7 +143,7 @@ jobs: quiet: false stdin: ${{ runner.temp }}/ci.build.cache host-yule: - name: nixfiles-host-yule + name: hosts-host-yule runs-on: ubuntu-latest steps: - id: checkout @@ -199,7 +199,7 @@ jobs: command: ci-build-cache quiet: false stdin: ${{ runner.temp }}/ci.build.cache -name: nixfiles +name: hosts 'on': - push - pull_request diff --git a/ci.nix b/ci/hosts.nix similarity index 97% rename from ci.nix rename to ci/hosts.nix index 9815addc..707c9fc2 100644 --- a/ci.nix +++ b/ci/hosts.nix @@ -1,7 +1,7 @@ { lib, channels, env, ... }: with lib; let nixfiles = import ./.; in { - name = "nixfiles"; + name = "hosts"; ci.gh-actions.enable = true; ci.gh-actions.export = true; diff --git a/shell.nix b/shell.nix index 009f2832..d484e8cb 100644 --- a/shell.nix +++ b/shell.nix @@ -1,30 +1,36 @@ { }: let config = import ./default.nix; tf = config.deploy.tf {}; + gh-actions-generate = config.pkgs.writeShellScriptBin "gh-actions-generate" '' + #!/usr/bin/env bash + export CI_ROOT=./; + export CI_CONFIG_ROOT=./ci; + CI_CONFIG_FILES=($CI_CONFIG_ROOT/hosts.nix) + for f in "''${CI_CONFIG_FILES[@]}"; do + nix run --arg config $f ci.run.gh-actions-generate + done + ''; + test-all = config.pkgs.writeShellScriptBin "test-all" '' + #!/usr/bin/env bash + export CI_ROOT=./; + export CI_CONFIG_ROOT=./ci; + CI_CONFIG_FILES=($CI_CONFIG_ROOT/hosts.nix) + for f in "''${CI_CONFIG_FILES[@]}"; do + nix run --arg config $f ci.test || break + done + ''; inherit (config) pkgs; in pkgs.mkShell { - nativeBuildInputs = config.runners.lazy.nativeBuildInputs; + nativeBuildInputs = [ + gh-actions-generate + test-all + ] ++ config.runners.lazy.nativeBuildInputs; HISTFILE = toString (tf.terraform.baseDir + "/.history"); - CI_ROOT = toString ./.; - CI_CONFIG_ROOT = toString ./ci; - #CI_CONFIG = toString ./example/ci.nix CI_PLATFORM = "impure"; # use host's nixpkgs for more convenient testing shellHook = '' export HOME_HOSTNAME=$(hostname -s) export NIX_PATH="$NIX_PATH:nixfiles=${toString ./.}" - - CI_CONFIG_FILES=($CI_CONFIG_ROOT/hosts.nix) - gh-actions-generate() { - for f in "''${CI_CONFIG_FILES[@]}"; do - nix run --arg config $f ci.run.gh-actions-generate - done - } - test-all() { - for f in "''${CI_CONFIG_FILES[@]}"; do - nix run --arg config $f ci.test || break - done - } ''; }