From b203380a3c7af8d0660f75dceffd13a85ea8f2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Cervera?= Date: Sat, 23 Nov 2024 12:32:47 -0600 Subject: [PATCH] ci: stylua check --- .github/workflows/ci.yml | 23 ++++++++++++++++++++--- Makefile | 7 +++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a7d68d..0bb7a37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,25 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Install stylua + shell: bash + run: | + # To update the version of stylua refer to the releases page for the URL: + # https://github.com/JohnnyMorganz/StyLua/releases + curl -LO https://github.com/JohnnyMorganz/StyLua/releases/download/v2.0.1/stylua-linux-x86_64.zip + unzip stylua-linux-x86_64.zip + rm -rf /opt/stylua + mkdir -p /opt/stylua + mv stylua /opt/stylua + # Add the stylua binary to the system's path. + echo /opt/stylua >> ${GITHUB_PATH} + + - name: Run stylua check + run: make testfmt + - name: Install Neovim shell: bash run: | @@ -27,10 +46,8 @@ jobs: # Add the nvim binary to the system's path. echo /opt/nvim-linux64/bin >> ${GITHUB_PATH} - - name: Check out repository code - uses: actions/checkout@v4 - - name: Run tests + shell: bash run: | nvim --version make test diff --git a/Makefile b/Makefile index 3a255b3..696e157 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,13 @@ test: deps/lua/test.lua nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run()" +# Verify all files match the configured formatting +testfmt: +ifeq (, $(shell which stylua)) +$(error "No stylua found. Install from: https://github.com/JohnnyMorganz/StyLua") +endif + stylua --check lua/ scripts/ tests/ + # Formatting with https://github.com/JohnnyMorganz/StyLua fmt: ifeq (, $(shell which stylua))