Skip to content

Commit

Permalink
M: initial version
Browse files Browse the repository at this point in the history
to be included locally in repos
no registry handling
copy/paste distribution
  • Loading branch information
pdesjardins90 committed Jun 21, 2024
1 parent 29c988a commit 7d1484f
Show file tree
Hide file tree
Showing 25 changed files with 722 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
rules:
body-leading-blank:
- 1
- always
body-max-line-length:
- 2
- always
- 96
footer-leading-blank:
- 1
- always
footer-max-line-length:
- 2
- always
- 96
header-max-length:
- 2
- always
- 72 # github hides text beyond this length behind an ellipsis
subject-case:
- 2
- always
- - lower-case
- kebab-case
- snake-case
subject-empty:
- 2
- never
subject-full-stop:
- 2
- never
- .
type-empty:
- 2
- never

# Semver commit type convention
#
# M (MAJOR) => Incompatible change
# m (MINOR) => Backward compatible feature
# p (PATCH) => Backward compatible bug fix
# r (REVISION/REFACTOR) => Backward compatible improvement
# x (MISCELLANEOUS) => Neutral change (documentation, ci/cd, dev dependencies, etc.)
type-enum:
- 2
- always
- - M
- m
- p
- r
- x
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 96
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @logisparte/homoioi
28 changes: 28 additions & 0 deletions .github/workflows/ci-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: ci-branch

on:
pull_request:
branches:
- master

env:
DOCKER_BUILDKIT: true

jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4

- name: Initialize development environment
run: ./docker/env.sh init

- name: Start development environment
run: ./docker/env.sh up

- name: Lint project
run: ./docker/env.sh exec ./scripts/lint.sh all

- name: Stop development environment
run: ./docker/env.sh down
4 changes: 4 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
default: true
MD013:
line_length: 96
code_blocks: false
2 changes: 2 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
printWidth: 96
proseWrap: always
1 change: 1 addition & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable=SC1090,SC1091
46 changes: 46 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# syntax=docker/dockerfile:1
FROM ubuntu:24.04 AS base

LABEL org.opencontainers.image.authors="@logisparte"
LABEL org.opencontainers.image.source="https://github.com/logisparte/docker-env"

RUN <<EOF
DEBIAN_FRONTEND=noninteractive \
apt-get update && apt-get install --yes --quiet --no-install-recommends \
apt-transport-https \
bash \
ca-certificates \
curl \
git \
gnupg2 \
software-properties-common \
ssh-client \
sudo \
vim \
wget \
zsh
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF

ENV EDITOR="/usr/bin/vim"

FROM base AS project

RUN <<EOF
curl --silent --fail --show-error --location https://deb.nodesource.com/setup_lts.x \
| bash -
DEBIAN_FRONTEND=noninteractive \
apt-get update && apt-get install --yes --quiet --no-install-recommends \
nodejs \
shellcheck \
shfmt
npm config --location=global set update-notifier=false fund=false
npm install --location=global --omit=dev --omit=optional \
markdownlint-cli \
prettier \
@commitlint/cli
npm cache clean --force
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF
1 change: 1 addition & 0 deletions docker/compose.yaml
1 change: 1 addition & 0 deletions docker/env.sh
7 changes: 7 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# docker-env

Containerized development environments

## License

This repository is distributed under the terms of the [Apache 2.0 license](/LICENSE)
3 changes: 3 additions & 0 deletions hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh -e

commitlint --edit "$@"
4 changes: 4 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh -e

./scripts/format.sh staged
./scripts/lint.sh staged
54 changes: 54 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh -e

. ./scripts/utils/colorize.sh
. ./scripts/utils/git/list_all_files.sh
. ./scripts/utils/git/list_dirty_files.sh
. ./scripts/utils/git/list_staged_files.sh
. ./scripts/utils/report.sh

FILTER="${1:-dirty}"

case "$FILTER" in
dirty)
report --info "[format] Formatting dirty files only"
FILES="$(list_dirty_files)"
;;

staged)
report --info "[format] Formatting staged files only"
FILES=$(list_staged_files)
;;

all)
report --info "[format] Formatting all files"
FILES="$(list_all_files)"
;;

*)
report --error "[format] Unknown filter: '$FILTER'"
exit 1
;;
esac

# Skip symbolic links
FILES="$({
for FILE in $FILES; do
[ -L "$FILE" ] && continue
echo "$FILE"
done
})"

PRETTIER_FILES="$(echo "$FILES" | grep -e "\.md$" -e "\.yml$" -e "\.yaml$" || true)"
if [ -n "$PRETTIER_FILES" ]; then
report --info "Markdown and yaml files >>"
echo "$PRETTIER_FILES" | xargs prettier --write
fi

SHFMT_FILES="$(echo "$FILES" | grep -e "\.sh$" || true)"
if [ -n "$SHFMT_FILES" ]; then
report --info "Shell files >>"
report "$(colorize --gray "$SHFMT_FILES")"
echo "$SHFMT_FILES" | xargs shfmt -p -w -bn -ci -sr -kp -i 2
fi

report --success "[format] Done"
55 changes: 55 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh -e

. ./scripts/utils/colorize.sh
. ./scripts/utils/git/list_all_files.sh
. ./scripts/utils/git/list_dirty_files.sh
. ./scripts/utils/git/list_staged_files.sh
. ./scripts/utils/report.sh

FILTER="${1:-dirty}"

case "$FILTER" in
dirty)
report --info "[lint] Linting dirty files only"
FILES="$(list_dirty_files)"
;;

staged)
report --info "[lint] Linting staged files only"
FILES=$(list_staged_files)
;;

all)
report --info "[lint] Linting all files"
FILES="$(list_all_files)"
;;

*)
report --error "[lint] Unknown filter: '$FILTER'"
exit 1
;;
esac

# Skip symbolic links
FILES="$({
for FILE in $FILES; do
[ -L "$FILE" ] && continue
echo "$FILE"
done
})"

MARKDOWN_FILES="$(echo "$FILES" | grep -e "\.md$" || true)"
if [ -n "$MARKDOWN_FILES" ]; then
report --info "Markdown files >>"
report "$(colorize --gray "$MARKDOWN_FILES")"
echo "$MARKDOWN_FILES" | xargs markdownlint
fi

SHELLCHECK_FILES="$(echo "$FILES" | grep -e "\.sh$" || true)"
if [ -n "$SHELLCHECK_FILES" ]; then
report --info "Shell files >>"
report "$(colorize --gray "$SHELLCHECK_FILES")"
echo "$SHELLCHECK_FILES" | xargs shellcheck
fi

report --success "[lint] Done"
7 changes: 7 additions & 0 deletions scripts/postclone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh -e

. ./scripts/utils/report.sh

report --info "[postclone] Configuring git hooks"
git config --local core.hooksPath "$PWD/hooks"
report --success "[postclone] Done"
Loading

0 comments on commit 7d1484f

Please sign in to comment.