From c0e15e7a59cc2b4b929895b889fafd74847a675b Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 20 Apr 2026 17:35:51 -0400 Subject: [PATCH] ci: adopt nix flake and just-based quality checks Bring http-codes.nvim in line with the rest of the Neovim plugin repos: - Add flake.nix with the standard dev shell: just, stylua, prettier, selene, neovim, lua-language-server, and the nixpkgs-packaged vimdoc-language-server. - Add a justfile with format/lint/ci recipes, mirroring the shared pattern (nix fmt, stylua, prettier, selene, lua-language-server, vimdoc-language-server). - Replace the multi-job quality workflow with a single Quality job that runs 'just format' and 'just lint' inside the ci dev shell, and drop the redundant ci.yaml workflow. --- .github/workflows/ci.yaml | 61 ------------------------ .github/workflows/quality.yaml | 84 +++------------------------------- flake.lock | 43 +++++++++++++++++ flake.nix | 48 +++++++++++++++++++ justfile | 15 ++++++ 5 files changed, 113 insertions(+), 138 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 justfile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 83cc1c7..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,61 +0,0 @@ -name: ci -on: - workflow_call: - pull_request: - branches: [main] - push: - branches: [main] - -jobs: - changes: - runs-on: ubuntu-latest - outputs: - lua: ${{ steps.changes.outputs.lua }} - steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - lua: - - 'lua/**' - - 'plugin/**' - - '*.lua' - - '.luarc.json' - - 'stylua.toml' - - 'selene.toml' - - lua-format: - runs-on: ubuntu-latest - needs: changes - if: ${{ needs.changes.outputs.lua == 'true' }} - steps: - - uses: actions/checkout@v4 - - uses: JohnnyMorganz/stylua-action@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: 2.1.0 - args: --check . - - lua-lint: - runs-on: ubuntu-latest - needs: changes - if: ${{ needs.changes.outputs.lua == 'true' }} - steps: - - uses: actions/checkout@v4 - - uses: NTBBloodbath/selene-action@v1.0.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --display-style quiet . - - lua-typecheck: - runs-on: ubuntu-latest - needs: changes - if: ${{ needs.changes.outputs.lua == 'true' }} - steps: - - uses: actions/checkout@v4 - - uses: mrcjkb/lua-typecheck-action@v0 - with: - checklevel: Warning - directories: lua - configpath: .luarc.json diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index bac492d..bff1966 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -7,83 +7,13 @@ on: branches: [main] jobs: - changes: + quality: + name: Quality runs-on: ubuntu-latest - outputs: - lua: ${{ steps.changes.outputs.lua }} - markdown: ${{ steps.changes.outputs.markdown }} steps: - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - lua: - - 'lua/**' - - 'plugin/**' - - '*.lua' - - '.luarc.json' - - '*.toml' - markdown: - - '*.md' - - 'doc/**/*.md' - - lua-format: - name: Lua Format Check - runs-on: ubuntu-latest - needs: changes - if: ${{ needs.changes.outputs.lua == 'true' }} - steps: - - uses: actions/checkout@v4 - - uses: JohnnyMorganz/stylua-action@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: 2.1.0 - args: --check . - - lua-lint: - name: Lua Lint Check - runs-on: ubuntu-latest - needs: changes - if: ${{ needs.changes.outputs.lua == 'true' }} - steps: - - uses: actions/checkout@v4 - - name: Lint with Selene - uses: NTBBloodbath/selene-action@v1.0.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --display-style quiet . - - lua-typecheck: - name: Lua Type Check - runs-on: ubuntu-latest - needs: changes - if: ${{ needs.changes.outputs.lua == 'true' }} - steps: - - uses: actions/checkout@v4 - - name: Run Lua LS Type Check - uses: mrcjkb/lua-typecheck-action@v0 - with: - checklevel: Warning - directories: lua - configpath: .luarc.json - - markdown-format: - name: Markdown Format Check - runs-on: ubuntu-latest - needs: changes - if: ${{ needs.changes.outputs.markdown == 'true' }} - steps: - - uses: actions/checkout@v4 - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 8 - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: "20" - - name: Install prettier - run: pnpm add -g prettier@3.1.0 - - name: Check markdown formatting with prettier - run: prettier --check . + - uses: cachix/install-nix-action@v31 + - name: Format + run: nix develop .#ci --command just format + - name: Lint + run: nix develop .#ci --command just lint diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9ca5e88 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1776329215, + "narHash": "sha256-a8BYi3mzoJ/AcJP8UldOx8emoPRLeWqALZWu4ZvjPXw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b86751bc4085f48661017fa226dee99fab6c651b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..43b5861 --- /dev/null +++ b/flake.nix @@ -0,0 +1,48 @@ +{ + description = "http-codes.nvim — HTTP status code reference for Neovim"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + systems.url = "github:nix-systems/default"; + }; + + outputs = + { + nixpkgs, + systems, + ... + }: + let + forEachSystem = + f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system}); + in + { + formatter = forEachSystem (pkgs: pkgs.nixfmt-tree); + + devShells = forEachSystem (pkgs: { + default = pkgs.mkShell { + packages = [ + pkgs.just + pkgs.prettier + pkgs.stylua + pkgs.neovim + pkgs.selene + pkgs.lua-language-server + pkgs.vimdoc-language-server + ]; + }; + + ci = pkgs.mkShell { + packages = [ + pkgs.just + pkgs.prettier + pkgs.stylua + pkgs.neovim + pkgs.selene + pkgs.lua-language-server + pkgs.vimdoc-language-server + ]; + }; + }); + }; +} diff --git a/justfile b/justfile new file mode 100644 index 0000000..0f49266 --- /dev/null +++ b/justfile @@ -0,0 +1,15 @@ +default: + @just --list + +format: + nix fmt -- --ci + stylua --check . + prettier --check . + +lint: + git ls-files '*.lua' | xargs selene --display-style quiet + lua-language-server --check . --configpath "$(pwd)/.luarc.json" --checklevel=Warning + vimdoc-language-server check doc/ + +ci: format lint + @: