Problem: mapping.lua can silently fall behind the ya2s/nonicons font repo with no indication that new icons are available. Solution: add a mapping-sync job that fetches nonicon.json from upstream, generates the expected mapping.lua, and fails the check if they differ.
115 lines
3.1 KiB
YAML
115 lines
3.1 KiB
YAML
name: quality
|
|
|
|
on:
|
|
workflow_call:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
changes:
|
|
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'
|
|
|
|
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 .
|
|
|
|
mapping-sync:
|
|
name: Mapping Sync Check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Check mapping against upstream
|
|
run: |
|
|
curl -sL https://raw.githubusercontent.com/ya2s/nonicons/main/src/template/nonicon.json \
|
|
| jq -S 'to_entries | map({key: (.key | sub("-16$"; "")), value: .value}) | from_entries' \
|
|
> /tmp/upstream.json
|
|
|
|
{
|
|
echo '---@type table<string, integer>'
|
|
echo 'local M = {'
|
|
jq -r 'to_entries | sort_by(.key) | .[] | " ['"'"'\(.key)'"'"'] = \(.value),"' /tmp/upstream.json
|
|
echo '}'
|
|
echo 'return M'
|
|
} > /tmp/expected.lua
|
|
|
|
if ! diff -u lua/nonicons/mapping.lua /tmp/expected.lua; then
|
|
echo ''
|
|
echo '::warning::mapping.lua is out of sync with ya2s/nonicons upstream'
|
|
echo 'Run the sync script or update lua/nonicons/mapping.lua manually.'
|
|
exit 1
|
|
fi
|