-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from rynkowsg/g/embrace-sosh
refactor: Embrace sosh
- Loading branch information
Showing
27 changed files
with
864 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
# orb info: https://circleci.com/developer/orbs/orb/rynkowsg/asdf | ||
asdf: rynkowsg/[email protected] | ||
# orb info: https://circleci.com/developer/orbs/orb/rynkowsg/checkout | ||
checkout: rynkowsg/[email protected] | ||
# orb info: https://circleci.com/developer/orbs/orb/rynkowsg/rynkowsg | ||
rynkowsg: rynkowsg/[email protected] | ||
|
||
jobs: | ||
checks: | ||
executor: rynkowsg/docker_x86_cimg_base | ||
steps: | ||
- checkout/checkout: {depth: 1} | ||
- asdf/install: {version: 0.14.0} | ||
- restore_cache: | ||
name: asdf - restore cache (partial) | ||
keys: | ||
- asdf-{{ checksum ".tool-versions" }} | ||
- run: | ||
name: asdf - add plugin | ||
command: | | ||
set -x | ||
cd /tmp | ||
git config --global advice.detachedHead false | ||
asdf plugin add babashka https://github.com/fredZen/asdf-babashka.git | ||
asdf plugin add java https://github.com/halcyon/asdf-java.git | ||
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git | ||
asdf plugin add shfmt https://github.com/luizm/asdf-shfmt.git | ||
- run: | ||
name: asdf - install tools | ||
command: | | ||
set -x | ||
bash --version | ||
asdf install | ||
bb --version | ||
java --version | ||
shellcheck --version | ||
shfmt --version | ||
- save_cache: | ||
name: asdf - save cache (partial) | ||
key: asdf-{{ checksum ".tool-versions" }} | ||
paths: | ||
- ~/.asdf/installs | ||
- ~/.asdf/plugins | ||
- ~/.asdf/shims | ||
- rynkowsg/install_sosh: { version: "v0.2.0" } | ||
- run: make lint | ||
- run: make format-check | ||
|
||
workflows: | ||
lint_and_format: | ||
jobs: | ||
- checks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,10 @@ on: | |
push: | ||
branches: | ||
- main | ||
- dev | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] # https://github.com/actions/checkout/releases | ||
- uses: asdf-vm/actions/[email protected] # https://github.com/asdf-vm/actions/releases | ||
- run: scripts/lint.bash | ||
|
||
actionlint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ on: | |
push: | ||
branches: | ||
- main | ||
- dev | ||
pull_request: | ||
|
||
jobs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
.idea | ||
# JetBrains IDEs | ||
/.idea/* | ||
!/.idea/codeStyles/ | ||
!/.idea/copyright/ | ||
!/.idea/dictionaries/ | ||
!/.idea/fileTemplates/ | ||
!/.idea/repl-commands.xml | ||
!/.idea/runConfigurations/ | ||
*.iml | ||
|
||
# MacOS | ||
.DS_Store | ||
|
||
# sosh | ||
/.github_deps |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
# PLUGIN: https://github.com/fredZen/asdf-babashka | ||
# RELEASES: https://github.com/babashka/babashka/releases | ||
babashka 1.3.189 | ||
|
||
# required for: sosh | ||
# PLUGIN: https://github.com/halcyon/asdf-java | ||
java openjdk-11.0.2 | ||
|
||
# PLUGIN: https://github.com/luizm/asdf-shellcheck | ||
# RELEASES: https://github.com/koalaman/shellcheck/releases | ||
shellcheck 0.9.0 | ||
|
||
# PLUGIN: https://github.com/luizm/asdf-shfmt | ||
# RELEASES: https://github.com/mvdan/sh/releases | ||
shfmt 3.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2024 Greg Rynkowski. All rights reserved. | ||
# License: MIT License | ||
|
||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
# | ||
# Validates/corrects format | ||
# | ||
# Example: | ||
# | ||
# - check: @bin/format.bash check | ||
# - apply: @bin/format.bash apply | ||
# | ||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|
||
# Bash Strict Mode Settings | ||
set -euo pipefail | ||
# Path Initialization | ||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P || exit 1)" | ||
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd -P || exit 1)" | ||
export SHELL_GR_DIR="${ROOT_DIR}/.github_deps/rynkowsg/shell-gr@1a30383" # needed for shell-gr to resolve paths | ||
# Library Sourcing | ||
source "${ROOT_DIR}/.github_deps/rynkowsg/shell-gr@1a30383/lib/tool/format.bash" # format_with_env | ||
|
||
main() { | ||
local format_cmd_type="${1:-"apply"}" | ||
local error=0 | ||
format_with_env "${format_cmd_type}" bash \ | ||
< <( | ||
find "${ROOT_DIR}" \( -type f \( -name '*.bash' -o -name '*.sh' \) -o -path '*/bin/*' \) \ | ||
| grep -v -E '(.github_deps|/gen/)' \ | ||
| sort | ||
) \ | ||
|| ((error += $?)) | ||
format_with_env "${format_cmd_type}" bats < <(find "${ROOT_DIR}" -type f -name '*.bats' | sort) || ((error += $?)) | ||
if ((error > 0)); then | ||
exit "$error" | ||
fi | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2024 Greg Rynkowski. All rights reserved. | ||
# License: MIT License | ||
|
||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
# | ||
# Lint bash source files | ||
# | ||
# Example: | ||
# | ||
# @bin/lint.bash | ||
# | ||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|
||
# Bash Strict Mode Settings | ||
set -euo pipefail | ||
# Path Initialization | ||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P || exit 1)" | ||
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd -P || exit 1)" | ||
export SHELL_GR_DIR="${ROOT_DIR}/.github_deps/rynkowsg/shell-gr@1a30383" # needed for shell-gr to resolve paths | ||
# Library Sourcing | ||
source "${ROOT_DIR}/.github_deps/rynkowsg/shell-gr@1a30383/lib/tool/lint.bash" # lint | ||
|
||
main() { | ||
local error=0 | ||
lint bash \ | ||
< <( | ||
find "${ROOT_DIR}" \( -type f \( -name '*.bash' -o -name '*.sh' \) -o -path '*/bin/*' \) \ | ||
| grep -v -E '(.github_deps|/gen/)' \ | ||
| sort | ||
) \ | ||
|| ((error += $?)) | ||
lint bats < <(find "${ROOT_DIR}" -type f -name '*.bats' | sort) || ((error += $?)) | ||
if ((error > 0)); then | ||
exit "$error" | ||
fi | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.PHONY: deps-clean _format_deps format-check format _lint_deps lint | ||
|
||
SCRIPTS := $(wildcard bin/*) | ||
deps: $(SCRIPTS) | ||
@$(foreach script,$^,echo "Fetching for $(script)"; sosh fetch $(script);) | ||
|
||
deps-clean: | ||
rm -rf lib/.github_deps | ||
make deps | ||
|
||
_format_deps: @bin/format.bash | ||
sosh fetch @bin/format.bash | ||
|
||
format-check: _format_deps | ||
\@bin/format.bash check | ||
|
||
format: _format_deps | ||
\@bin/format.bash apply | ||
|
||
_lint_deps: @bin/lint.bash | ||
sosh fetch @bin/lint.bash | ||
|
||
lint: _format_deps _lint_deps deps | ||
\@bin/lint.bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.