Skip to content

Commit

Permalink
Merge pull request #1 from vdbe/ci/init
Browse files Browse the repository at this point in the history
ci: init
  • Loading branch information
vdbe authored May 19, 2024
2 parents 8019bcf + 71868e6 commit 548bea4
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 5 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]

name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11

- name: Setup cache
uses: DeterminateSystems/magic-nix-cache-action@v6

- name: Run build
run: |
nix build --print-build-logs
check:
name: Check flake
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11

- name: Run check
run: |
nix flake check --print-build-logs --show-trace
6 changes: 4 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
pluginSources = mapAttrs' (n: v: {
name = namePlugin n;
value = v;
}) (import ./npins);
}) (import ./nix/npins);

mkPlugins = buildVimPlugin: (builtins.mapAttrs (n: v:
buildVimPlugin {
Expand All @@ -34,6 +34,8 @@
})
pluginSources);
in {
checks = forAllSystems (pkgs: import ./nix/checks.nix {inherit pkgs self;});

devShells = forAllSystems (pkgs: {
default = pkgs.mkShellNoCC {
packages =
Expand All @@ -57,7 +59,7 @@
packages = forAllSystems (pkgs: let
inherit (self.legacyPackages.${pkgs.system}) vimPlugins;

mynvim = import ./neovim.nix {
mynvim = import ./nix/neovim.nix {
inherit self vimPlugins pkgs;
};
in {
Expand Down
62 changes: 62 additions & 0 deletions nix/checks.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
pkgs,
self,
}: let
inherit (pkgs) lib;
nvim = self.packages.${pkgs.system}.default;
in {
check-headless = pkgs.runCommand "check-headless" {} ''
mkdir -p $out/{.config, .local/state, .local/share, .cache}
XDG_CONFIG_HOME="$out/.config" \
XDG_STATE_HOME="$out/.local/state" \
XDG_CACHE_HOME="$out/.cache" \
XDG_DATA_HOME="$out/.local/share" \
${lib.getExe nvim} --headless +qa 2>"$out/messages.txt"
cat "$out/messages.txt"
test -s "$out/messages.txt" && exit 1
exit 0
'';

# check-health = pkgs.runCommand "check-lazy-health" {} ''
# mkdir -p $out{.config, .local/state, .local/share, .cache}
# XDG_CONFIG_HOME="$out/.config" \
# XDG_STATE_HOME="$out/.local/state" \
# XDG_CACHE_HOME="$out/.cache" \
# XDG_DATA_HOME="$out/.local/share" \
# ${lib.getExe nvim} --headless "+checkhealth" "+w!$out/health.log" +qa
#
# cat "$out/health.log"
#
# cat "$out/health.log" | ${lib.getExe pkgs.gawk} '
# {
# if (/ERROR/) {
# type = "error";
# title = "Error";
# } else if (/WARNING/) {
# type = "warning";
# title = "Warning";
# } else {
# next;
# }
#
# start_line = NR;
# message = $0;
# getline;
# while ($0 ~ /^- (ERROR|WARNING)/) {
# message = message "\n" $0;
# getline;
# }
# message = message "\n" $0;
# end_line = NR - 1;
#
# # Print the GitHub Actions command
# printf "::%s file=health.log,line=%d,endLine=%d,title=%s::%s\n", type, start_line, end_line, title, message;
# }
# ' > "$out/health.error"
#
# cat "$out/health.error"
# test -s "$out/health.error" && exit 1
# '';
}
6 changes: 3 additions & 3 deletions neovim.nix → nix/neovim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
version = self.shortRev or self.dirtyShortRev or "unknown-dirty";

src = fileset.toSource {
root = ./.;
root = ../.;
fileset = fileset.unions [
./lua
./plugin
../lua
../plugin
];
};
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 548bea4

Please sign in to comment.