Skip to content

Commit

Permalink
feat: expand linted file types to markdown and shell
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Doster <[email protected]>
  • Loading branch information
vladdoster committed Apr 17, 2022
1 parent 704f4be commit 96fe03f
Show file tree
Hide file tree
Showing 9 changed files with 732 additions and 752 deletions.
65 changes: 28 additions & 37 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
name: 👮 linting
on: [push, pull_request, workflow_dispatch]
name: Lint

on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

jobs:
build-matrix:

lint:
name: Lint
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: "📡 Check out repository code"
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: "💬 Set matrix output"
id: set-matrix
- name: install dependencies
run: |
MATRIX="$(find . -type d -name 'doc' -prune -o -type f -iname '*.zsh' -print | jq -ncR '{"include": [{"file": inputs}]}')"
echo "MATRIX=${MATRIX}" >&2
echo "::set-output name=matrix::${MATRIX}"
brew install shellcheck shfmt zsh
pip3 install --user linkify-it-py mdformat mdformat-config mdformat-gfm mdformat-shfmt mdformat-tables mdformat-toc
lint:
runs-on: ubuntu-latest
needs: build-matrix
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.build-matrix.outputs.matrix) }}
- name: run mdformat
run: find . -name '*.md' -type f -print0 | xargs -0 -n1 -P4 python3 -m mdformat --check --wrap 120

steps:
- name: "📡 Check out repository code"
uses: actions/checkout@v3
- name: run shfmt
run: find . -name '*.sh' -type f -print0 | xargs -0 -n1 -P4 shfmt -bn -ci -d -i 2 -ln bash -s -sr

- name: "📦 Install dependencies"
run: |
sudo apt install -y zsh
- name: run shellcheck
run: find . -name '*.sh' -type f -print0 | xargs -0 -n1 -P4 shellcheck

- name: "👓 zsh -n ${{ matrix.file }}"
env:
ZSH_FILE: ${{ matrix.file }}
run: |
zsh -n "${ZSH_FILE}"
- name: "run zsh"
run: find . -name '*.zsh' -type f -print0 | xargs -0 -n1 -P4 zsh -n

- name: "💎 zcompile ${{ matrix.file }}"
env:
ZSH_FILE: ${{ matrix.file }}
run: |
zsh -fc "zcompile ${ZSH_FILE}"
rc=$?
ls -al "${ZSH_FILE}.zwc"
exit "$rc"
- name: "run zcompile"
run: find . -name '*.zsh' -type f -exec zsh -fc "zcompile {}" \;
445 changes: 216 additions & 229 deletions README.md

Large diffs are not rendered by default.

705 changes: 365 additions & 340 deletions doc/CHANGELOG.md

Large diffs are not rendered by default.

41 changes: 20 additions & 21 deletions doc/HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,32 @@
## README: Update the table of content

1. Install [doctoc](https://github.com/thlorenz/doctoc)
2. To update the TOC run the following command:
1. To update the TOC run the following command:

```zsh
doctoc --github README.md
```

## Update asciidoc and/or zshelldoc

1. Make sure you have [docker](https://www.docker.com/) or
[podman](https://podman.io/) installed.
2. From the root of the repo, run:
1. Make sure you have [docker](https://www.docker.com/) or [podman](https://podman.io/) installed.
1. From the root of the repo, run:

```zsh
make doc-container
```

If for some reason you want to build the zshelldocs or the PDF manually, you'll
need:
If for some reason you want to build the zshelldocs or the PDF manually, you'll need:

1. Patience, zsd is very finicky about locales. You have been warned.
2. [zshelldoc (zsd)](https://github.com/zdharma-continuum/zshelldoc)
3. [asciidoc](https://asciidoc.org/)
4. `make doc`
1. [zshelldoc (zsd)](https://github.com/zdharma-continuum/zshelldoc)
1. [asciidoc](https://asciidoc.org/)
1. `make doc`

## Generate the manpage (doc/zinit.1)

1. Install [pandoc](https://pandoc.org/)
2. From the root of the repo run:
1. From the root of the repo run:

```zsh
pandoc --standalone --to man README.md -o doc/zinit.1
Expand All @@ -39,17 +37,18 @@ pandoc --standalone --to man README.md -o doc/zinit.1
## Updating the gh-pages (zdharma-continuum.github.io)

1. Check out the [documentation branch](https://github.com/zdharma-continuum/zinit/tree/documentation)

```shell
git fetch origin documentation
git checkout documentation
```
2. Do your modifications and push your changes
3. Keep an eye on [the CI logs](https://github.com/zdharma-continuum/zinit/actions/workflows/gh-pages.yaml)
4. If all went well you can head to https://zdharma-continuum.github.io/ to see your changes live.

**NOTE:** If you really **need** to push directly, without CI please refer to
[the README in the documentation]https://github.com/zdharma-continuum/zinit/blob/documentation/README.md
2. Do your modifications and push your changes
1. Keep an eye on [the CI logs](https://github.com/zdharma-continuum/zinit/actions/workflows/gh-pages.yaml)
1. If all went well you can head to https://zdharma-continuum.github.io/ to see your changes live.

**NOTE:** If you really **need** to push directly, without CI please refer to \[the README in the
documentation\]https://github.com/zdharma-continuum/zinit/blob/documentation/README.md

# Testing

Expand Down Expand Up @@ -115,13 +114,12 @@ zunit --verbose tests/your_test.zunit

## Debugging tests

If you ever need to inspect the `ZINIT[HOME_DIR]` dir, where zinit's internal
data is stored you can do so by commenting out the `@teardown` section in your
test. Then you can re-run said test and head over to
`${TMPDIR:-/tmp}/zunit-zinit`. Good luck!

If you ever need to inspect the `ZINIT[HOME_DIR]` dir, where zinit's internal data is stored you can do so by commenting
out the `@teardown` section in your test. Then you can re-run said test and head over to `${TMPDIR:-/tmp}/zunit-zinit`.
Good luck!

# Misc

## Get the list of supported ices

To get the list in a quick-and-dirty fashion you issue:
Expand All @@ -130,5 +128,6 @@ To get the list in a quick-and-dirty fashion you issue:
zinit --help | tail -1
```

See [zinit-autoload.zsh](https://github.com/zdharma-continuum/zinit/blob/2feb41cf70d2f782386bbaa6fda691e3bdc7f1ac/zinit-autoload.zsh#L3445-L3447)
See
[zinit-autoload.zsh](https://github.com/zdharma-continuum/zinit/blob/2feb41cf70d2f782386bbaa6fda691e3bdc7f1ac/zinit-autoload.zsh#L3445-L3447)
for implementation details.
26 changes: 15 additions & 11 deletions doc/zsdoc/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# Code documentation

Here is `Asciidoc` code documentation generated using [Zshelldoc](https://github.com/zdharma-continuum/zshelldoc).
There are `4` Zinit's source files, the main one is [zinit.zsh](zinit.zsh.adoc). The documentation
lists all functions, interactions between them, their comments and features used.
Here is `Asciidoc` code documentation generated using [Zshelldoc](https://github.com/zdharma-continuum/zshelldoc). There
are `4` Zinit's source files, the main one is [zinit.zsh](zinit.zsh.adoc). The documentation lists all functions,
interactions between them, their comments and features used.

Github allows to directly view `Asciidoc` documents:
* [zinit.zsh](zinit.zsh.adoc) – always loaded, in `.zshrc` ([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit.zsh))
* [zinit-side.zsh](zinit-side.zsh.adoc) – common functions, loaded by `*-install` and `*-autoload` scripts ([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit-side.zsh))
* [zinit-install.zsh](zinit-install.zsh.adoc) – functions used only when installing a plugin or snippet ([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit-install.zsh))
* [zinit-autoload.zsh](zinit-autoload.zsh.adoc) – functions used only in interactive `Zinit` invocations ([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit-autoload.zsh/))

- [zinit.zsh](zinit.zsh.adoc) – always loaded, in `.zshrc`
([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit.zsh))
- [zinit-side.zsh](zinit-side.zsh.adoc) – common functions, loaded by `*-install` and `*-autoload` scripts
([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit-side.zsh))
- [zinit-install.zsh](zinit-install.zsh.adoc) – functions used only when installing a plugin or snippet
([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit-install.zsh))
- [zinit-autoload.zsh](zinit-autoload.zsh.adoc) – functions used only in interactive `Zinit` invocations
([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit-autoload.zsh/))

# PDFs, man pages, etc.

Formats other than `Asciidoc` can be produced by using provided Makefile. For example, issuing
`make pdf` will create and populate a new directory `pdf` (requires `asciidoctor`, install with
`gem install asciidoctor-pdf --pre`). `make man` will create man pages (requires package `asciidoc`,
uses its command `a2x`, which is quite slow).
Formats other than `Asciidoc` can be produced by using provided Makefile. For example, issuing `make pdf` will create
and populate a new directory `pdf` (requires `asciidoctor`, install with `gem install asciidoctor-pdf --pre`).
`make man` will create man pages (requires package `asciidoc`, uses its command `a2x`, which is quite slow).
25 changes: 12 additions & 13 deletions scripts/docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env bash

build() {
cd "$(cd "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" || exit 9
cd "$(
cd "$(dirname "$0")" > /dev/null 2>&1
pwd -P
)" || exit 9

local image_name="${1:-zinit}"
local tag="${2:-latest}"
Expand All @@ -10,15 +13,14 @@ build() {

local dockerfile="../docker/Dockerfile"

if [[ -n "$zsh_version" ]]
then
if [[ -n $zsh_version ]]; then
tag="zsh${zsh_version}-${tag}"
fi

echo -e "\e[34mBuilding image: ${image_name}\e[0m" >&2

local -a args
[[ -n "$NO_CACHE" ]] && args+=(--no-cache "$@")
[[ -n $NO_CACHE ]] && args+=(--no-cache "$@")

if docker build \
--build-arg "PUSERNAME=$(id -u -n)" \
Expand All @@ -29,8 +31,7 @@ build() {
--file "$dockerfile" \
--tag "${image_name}:${tag}" \
"${args[@]}" \
"$(realpath ..)"
then
"$(realpath ..)"; then
{
echo -e "\e[34mTo use this image for zunit tests run: \e[0m"
echo -e "\e[34mexport CONTAINER_IMAGE=\"${image_name}\" CONTAINER_TAG=\"${tag}\"\e[0m"
Expand All @@ -42,25 +43,23 @@ build() {
fi
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]
then
if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then
BUILD_ZSH_VERSION="${BUILD_ZSH_VERSION:-}"
CONTAINER_IMAGE="${CONTAINER_IMAGE:-ghcr.io/zdharma-continuum/zinit}"
CONTAINER_TAG="${CONTAINER_TAG:-latest}"
NO_CACHE="${NO_CACHE:-}"

while [[ -n "$*" ]]
do
while [[ -n $* ]]; do
case "$1" in
--image|-i)
--image | -i)
CONTAINER_IMAGE="$2"
shift 2
;;
--no-cache|-N)
--no-cache | -N)
NO_CACHE=1
shift
;;
--zsh-version|-zv|--zv)
--zsh-version | -zv | --zv)
BUILD_ZSH_VERSION="${2}"
shift 2
;;
Expand Down
Loading

0 comments on commit 96fe03f

Please sign in to comment.