From da3dde3bcc70d924778d7abf62f9359cc5dff6ef Mon Sep 17 00:00:00 2001 From: Megabyte Labs Date: Tue, 27 Sep 2022 17:47:57 -0400 Subject: [PATCH] =?UTF-8?q?=E2=98=81=EF=B8=8F=20chore(automation):=20Apply?= =?UTF-8?q?ing=20changes=20from=20upstream=20repository.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/log | 89 +++++++++++--------- .config/taskfiles/ci/Taskfile-github.yml | 6 +- .config/taskfiles/docker/Taskfile-update.yml | 2 +- .config/taskfiles/release/Taskfile.yml | 1 - Taskfile.yml | 85 +++++++++++++++++-- meta/main.yml | 2 +- package.json | 10 ++- 7 files changed, 134 insertions(+), 61 deletions(-) diff --git a/.config/log b/.config/log index 1a04d239..37566fbd 100755 --- a/.config/log +++ b/.config/log @@ -111,6 +111,11 @@ if [ "${container:=}" != 'docker' ]; then fi fi +# @description Disable logging for Semantic Release because it tries to parse it as JSON +if [ -n "$SEMANTIC_RELEASE" ]; then + NO_LOGGING=true +fi + # @description Logs using Node.js # @example logger info "An informative log" logger() { @@ -208,12 +213,12 @@ confirm() { # @description Logs an error message # @example .config/log error "Something happened!" error() { - if [ -n "$SEMANTIC_RELEASE" ]; then - echo "ERROR $1" - elif [ -n "$ENHANCED_LOGGING" ]; then - logger error "$1" - else - echo -e "\e[1;41m ERROR \e[0m $(format "$1")\e[0;39m" + if [ -z "$NO_LOGGING" ]; then + if [ -n "$ENHANCED_LOGGING" ]; then + logger error "$1" + else + echo -e "\e[1;41m ERROR \e[0m $(format "$1")\e[0;39m" + fi fi } @@ -231,12 +236,12 @@ filter() { # @description Logs an info message # @example .config/log info "Here is some information" info() { - if [ -n "$SEMANTIC_RELEASE" ]; then - echo "INFO $1" - elif [ -n "$ENHANCED_LOGGING" ]; then - logger info "$1" - else - echo -e "\e[1;46m INFO \e[0m $(format "$1")\e[0;39m" + if [ -z "$NO_LOGGING" ]; then + if [ -n "$ENHANCED_LOGGING" ]; then + logger info "$1" + else + echo -e "\e[1;46m INFO \e[0m $(format "$1")\e[0;39m" + fi fi } @@ -283,12 +288,12 @@ password() { # @description Logs a message that describes a prompt # @example .config/log prompt "Enter text into the following prompt" prompt() { - if [ -n "$SEMANTIC_RELEASE" ]; then - echo "PROMPT $1" - elif [ -n "$ENHANCED_LOGGING" ]; then - logger prompt "$1" - else - echo -e "\e[1;104m PROMPT \e[0m $(format "$1")\e[0;39m" + if [ -z "$NO_LOGGING" ]; then + if [ -n "$ENHANCED_LOGGING" ]; then + logger prompt "$1" + else + echo -e "\e[1;104m PROMPT \e[0m $(format "$1")\e[0;39m" + fi fi } @@ -311,48 +316,48 @@ spin() { # @description Logs a message that starts with a star emoji # @example .config/log star "Congratulations" star() { - if [ -n "$SEMANTIC_RELEASE" ]; then - echo "STAR $1" - elif [ -n "$ENHANCED_LOGGING" ]; then - logger star "$1" - else - echo -e "\e[1;104m LINK \e[0m $(format "$1")\e[0;39m" + if [ -z "$NO_LOGGING" ]; then + if [ -n "$ENHANCED_LOGGING" ]; then + logger star "$1" + else + echo -e "\e[1;104m LINK \e[0m $(format "$1")\e[0;39m" + fi fi } # @description Logs a message at the beginning of a task # @example .config/log start "Starting the process.." start() { - if [ -n "$SEMANTIC_RELEASE" ]; then - echo "START $1" - elif [ -n "$ENHANCED_LOGGING" ]; then - logger start "$1" - else - echo -e "\e[1;46m START \e[0m $(format "$1")\e[0;39m" + if [ -z "$NO_LOGGING" ]; then + if [ -n "$ENHANCED_LOGGING" ]; then + logger start "$1" + else + echo -e "\e[1;46m START \e[0m $(format "$1")\e[0;39m" + fi fi } # @description Logs a success message # @example .config/log success "Yay!" success() { - if [ -n "$SEMANTIC_RELEASE" ]; then - echo "SUCCESS $1" - elif [ -n "$ENHANCED_LOGGING" ]; then - logger success "$1" - else - echo -e "\e[1;42m SUCCESS \e[0m $(format "$1")\e[0;39m" + if [ -z "$NO_LOGGING" ]; then + if [ -n "$ENHANCED_LOGGING" ]; then + logger success "$1" + else + echo -e "\e[1;42m SUCCESS \e[0m $(format "$1")\e[0;39m" + fi fi } # @description Logs a warning message # @example .config/log warn "Just so you know.." warn() { - if [ -n "$SEMANTIC_RELEASE" ]; then - echo "WARNING $1" - elif [ -n "$ENHANCED_LOGGING" ]; then - logger warn "$1" - else - echo -e "\e[1;43m WARNING \e[0m $(format "$1")\e[0;39m" + if [ -z "$NO_LOGGING" ]; then + if [ -n "$ENHANCED_LOGGING" ]; then + logger warn "$1" + else + echo -e "\e[1;43m WARNING \e[0m $(format "$1")\e[0;39m" + fi fi } diff --git a/.config/taskfiles/ci/Taskfile-github.yml b/.config/taskfiles/ci/Taskfile-github.yml index 9cba5de9..7137eb1b 100644 --- a/.config/taskfiles/ci/Taskfile-github.yml +++ b/.config/taskfiles/ci/Taskfile-github.yml @@ -26,12 +26,12 @@ tasks: synchronize: deps: - :install:software:git - env: - GITHUB_HTTP_REPO: - sh: jq -r '.blueprint.repository.github' package.json summary: | Forces a push to the GitHub master branch so that GitHub stays mirrored with the GitLab master branch. + env: + GITHUB_HTTP_REPO: + sh: jq -r '.blueprint.repository.github' package.json cmds: - cmd: | if [ "$GITHUB_HTTP_REPO" != 'null' ]; then diff --git a/.config/taskfiles/docker/Taskfile-update.yml b/.config/taskfiles/docker/Taskfile-update.yml index 68483015..e6e341b5 100644 --- a/.config/taskfiles/docker/Taskfile-update.yml +++ b/.config/taskfiles/docker/Taskfile-update.yml @@ -69,7 +69,7 @@ tasks: - grep 'org.opencontainers.image.documentation' Dockerfile # yamllint disable rule:line-length - # eslint-disable max-len + labels:update: vars: AUTHORS: diff --git a/.config/taskfiles/release/Taskfile.yml b/.config/taskfiles/release/Taskfile.yml index f4d81322..96c7b17a 100644 --- a/.config/taskfiles/release/Taskfile.yml +++ b/.config/taskfiles/release/Taskfile.yml @@ -146,7 +146,6 @@ tasks: status: - '[ "$SNAP_PACKAGE" == "null" ]' - # eslint-disable max-len analyze: summary: | | Command property | Description | diff --git a/Taskfile.yml b/Taskfile.yml index 240fcd95..2cb574a8 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,5 +1,6 @@ --- version: '3' + includes: ansible: taskfile: ./.config/taskfiles/ansible/Taskfile.yml @@ -310,7 +311,9 @@ includes: web:profile: taskfile: ./.config/taskfiles/web/Taskfile-profile.yml optional: true + output: interleaved + vars: DOCKERHUB_PROFILE: sh: | @@ -363,7 +366,11 @@ vars: GROUP_EXEC_ASYNC: 'false' # yamllint disable rule:line-length IGNORE_FOLDERS: >- - -path './.autodoc/*' -o -path './.cache/*' -o -path './.common*' -o -path './.config/*' -o -path './.git/*' -o -path './.modules/*' -o -path './.npm/*' -o -path './.pnpm-store/*' -o -path './.shared/*' -o -path './.task/*' -o -path './.venv/*' -o -path './.vscode/*' -o -path './build/*' -o -path './dist/*' -o -path './node_modules/*' -o -path './roles/*' -o -name pnpm-lock.yaml -o -name package-lock.json -o -name poetry.lock -o -name '.variables.json' -o -name '.git' + -path './.autodoc/*' -o -path './.cache/*' -o -path './.common*' -o -path './.config/*' -o -path './.git/*' -o + -path './.modules/*' -o -path './.npm/*' -o + -path './.pnpm-store/*' -o -path './.shared/*' -o -path './.task/*' -o -path './.venv/*' -o -path './.vscode/*' -o + -path './build/*' -o -path './dist/*' -o -path './node_modules/*' -o -path './roles/*' -o -name pnpm-lock.yaml -o + -name package-lock.json -o -name poetry.lock -o -name '.variables.json' -o -name '.git' INIT_SCRIPT: https://gitlab.com/megabyte-labs/gitlab-ci/-/raw/master/scripts/update-init.sh LOG_FIX: sh: chmod +x .config/log @@ -395,13 +402,34 @@ vars: fi PYTHON_VIRTUALENV: true REPOSITORY_SUBTYPE: - sh: if type jq &> /dev/null && [ -f package.json ]; then VER="$(jq -r .blueprint.subgroup package.json)"; if [ "$VER" == null ]; then echo "$REPOSITORY_TYPE"; else echo "$VER"; fi; else echo "$REPOSITORY_TYPE"; fi + sh: | + if [ -n "$REPOSITORY_TYPE" ]; then REPO_SUBTYPE="$REPOSITORY_TYPE"; fi + if type jq &> /dev/null && [ -f package.json ]; then + VER="$(jq -r '.blueprint.subgroup' package.json)" + if [ "$VER" == 'null' ]; then + if [ -n "$REPO_SUBTYPE" ]; then echo "$REPO_SUBTYPE"; else echo "misc"; fi + else + echo "$VER" + fi + else + if [ -n "$REPO_SUBTYPE" ]; then echo "$REPO_SUBTYPE"; else echo "misc"; fi + fi REPOSITORY_TYPE: - sh: if type jq &> /dev/null && [ -f package.json ]; then VER="$(jq -r .blueprint.group package.json)"; if [ "$VER" == null ]; then echo "$GROUP_TYPE"; else echo "$VER"; fi; else echo "$GROUP_TYPE"; fi + sh: | + if [ -n "$GROUP_TYPE" ]; then REPO_TYPE="$GROUP_TYPE"; fi + if type jq &> /dev/null && [ -f package.json ]; then + VER="$(jq -r '.blueprint.group' package.json)" + if [ "$VER" == 'null' ]; then + if [ -n "$REPO_TYPE" ]; then echo "$REPO_TYPE"; else echo "misc"; fi + else + echo "$VER" + fi + else + if [ -n "$REPO_TYPE" ]; then echo "$REPO_TYPE"; else echo "misc"; fi + fi SEMANTIC_CONFIG: semantic-release-config TIMEZONE: America/New_York - includes: - common:start: ./.config/taskfiles/common/Taskfile-start.yml + env: GOPATH: sh: | @@ -434,6 +462,7 @@ env: fi VOLTA_HOME: sh: echo "$HOME/.volta" + profile: | if [[ "$OSTYPE" == 'linux-gnu'* ]] || [[ "$OSTYPE" == 'linux-musl'* ]]; then if [ -f /home/linuxbrew/.linuxbrew/bin/brew ] && ! type brew > /dev/null; then @@ -452,6 +481,7 @@ profile: | if [ -f .venv/bin/activate ]; then . .venv/bin/activate fi + tasks: build: deps: @@ -480,6 +510,7 @@ tasks: else [[ $- == *i* ]] && task prepare || (.config/log error '{{.NONINTERACTIVE_MISSING_BUILD_CMD}}' && exit 1) fi + clean: desc: Removes optional folders that are cached during various tasks summary: | @@ -490,11 +521,13 @@ tasks: which will re-generate the project from scratch. Ideally, this task and the reset task should never be necessary. The `start` task should be used instead. vars: - CLEAN_TARGETS: .autodoc .cache .task .venv node_modules tsconfig.tsbuildinfo venv .variables.json + CLEAN_TARGETS: .autodoc .cache .task .venv node_modules tsconfig.tsbuildinfo venv + .variables.json cmds: - task: common:clean vars: CLEAN_TARGETS: '{{.CLEAN_TARGETS}}' + commit: desc: Lint staged files, report spelling errors, and open a _required_ commit dialoge summary: | @@ -511,6 +544,7 @@ tasks: to your regular `git commit -m` command to bypass the pre-commit hook. cmds: - task: common:commit + commit:all: deps: - install:software:git @@ -548,6 +582,7 @@ tasks: git add --all git commit {{end}} + commit:quick: deps: - ci:commit:config @@ -555,13 +590,16 @@ tasks: - | task --list > /dev/null || (echo "ERROR: Invalid Taskfiles!" && exit 1) git add --all - - "HUSKY=0 git commit -m '\U0001F527 chore(tweak)": quick minor update' --no-verify + - HUSKY=0 git commit -m '🔧 chore(tweak): quick minor update' --no-verify - git push origin master + devcontainer: deps: - install:npm:devcontainer - install:software:docker + donothing: 'true' + fix: desc: Run code auto-fixers / auto-formatters summary: | @@ -572,6 +610,7 @@ tasks: an error so the auto-fixes still have to be validated. cmds: - task: fix:all + fresh: summary: Initialize a new project with only the Taskfile.yml present cmds: @@ -583,6 +622,7 @@ tasks: - TMP="$(mktemp)" && jq -r 'del(.blueprint)' package.json > "$TMP" && mv "$TMP" package.json - bash start.sh - task: prepare + get:links: deps: - install:software:jq @@ -595,6 +635,7 @@ tasks: cmds: - .config/log info 'GitHub -----> `{{.GITHUB_URL}}`' - .config/log info 'GitLab -----> `{{.GITLAB_URL}}`' + group:exec: desc: Execute group commands on any GitLab group (including repositories in sub-groups) summary: | @@ -615,6 +656,7 @@ tasks: Be sure to wrap the command in quotes or you might observe some odd behavior. cmds: - task: git:gitlab:group:exec + init: deps: - install:software:jq @@ -647,10 +689,12 @@ tasks: - git init - task: repair - task: prepare + jumpusb: desc: Creates a JumpUSB (https://jumpusb.com) cmds: - task: install:ventoy + lint: desc: Lints the project using all linters summary: | @@ -664,6 +708,7 @@ tasks: `task lint` cmds: - task: lint:all + livereload: deps: - install:npm:nodemon @@ -703,10 +748,12 @@ tasks: .config/log error '`Taskfile-project.yml` must exist and have a `livereload` task to use with `nodemon`' && exit 1 fi - nodemon --config {{if .CLI_ARGS}}{{.CLI_ARGS}}{{else}}.config/nodemon.json{{end}} + new:project: desc: Create a new project cmds: - task: prepare + preload: desc: Set up your workstation in advance by installing commonly used programs summary: | @@ -749,6 +796,7 @@ tasks: - task: install:pipx:bundle - task: install:python:requirements - task: install:modules:local + prepare: desc: Prepares the project for the normal start command summary: | @@ -765,6 +813,7 @@ tasks: cmds: - task: boilerplate:check:package - task: boilerplate:clean + publish: desc: Publish a semantic release via `semantic-release` summary: | @@ -812,6 +861,7 @@ tasks: success: Successfully ran `semantic-release` via `task publish` cmds: - task: publish:semantic-release + publish:force: desc: Force a `semantic-release` even if there are no new eligible commits summary: | @@ -837,8 +887,10 @@ tasks: start: Publishing `semantic-release` update via `task publish:force` success: Successfully published update via `task publish:force` cmds: - - "HUSKY=0 git commit -a --allow-empty -m '\U0001F528 chore(bump): Forced semantic-release {{.UPDATE_LEVEL}}' -n\n" + - | + HUSKY=0 git commit -a --allow-empty -m '🔨 chore(bump): Forced semantic-release {{.UPDATE_LEVEL}}' -n - task: publish + pull:upstream: desc: Pull from upstream repositories summary: | @@ -855,6 +907,7 @@ tasks: success: Successfully pulled from `upstreamRemotes` cmds: - task: common:update:upstream:remotes:pull + repair: cmds: - task: common:repair @@ -865,6 +918,7 @@ tasks: else curl -sSL {{.INIT_SCRIPT}} > "$TMP" && bash "$TMP" && rm "$TMP" fi + reset: desc: Resets the project by removing all caches and then re-generating templated files summary: | @@ -876,6 +930,7 @@ tasks: updates, it re-generates any templated files. cmds: - task: common:reset + reset:force: desc: 'Aggressively reset the project (**WARNING** This will wipe uncommitted work)' summary: | @@ -894,6 +949,7 @@ tasks: answer: cmds: - task: common:reset:force + scripts: interactive: true deps: @@ -911,6 +967,7 @@ tasks: start: Running `NTL_RUNNER={{.NPM_PROGRAM}} ntl` cmds: - NTL_RUNNER={{.NPM_PROGRAM}} ntl + services: desc: Update elements of the repository that require API access summary: | @@ -923,6 +980,7 @@ tasks: - task: common:update:services status: - '[ -n "$GITLAB_CI" ] && [ "$REPOSITORY_UPDATE" != "true" ]' + shell: desc: Start a terminal session using Docker with any Linux operating system compile: | @@ -956,11 +1014,13 @@ tasks: * ubuntu-21.04 cmds: - task: common:shell + ssh-keys: deps: - cloud:heroku:ssh-keys - git:github:ssh-keys - git:gitlab:ssh-keys + start: desc: Start the project by installing / updating dependencies, repairing issues, and opening a tutorial summary: | @@ -984,6 +1044,7 @@ tasks: success: Project started! cmds: - task: common:start + synchronize: desc: Set up the project and refresh it with the latest changes summary: | @@ -1004,6 +1065,7 @@ tasks: success: Successfully synchronized the project with upstream file changes and also bootstrapped the project cmds: - task: upstream:{{.PROJECT_TYPE}} + tag:deps: desc: Inject a new command in the `Taskfile.yml` that includes all tasks matching a given tag as deps summary: | @@ -1032,6 +1094,7 @@ tasks: ``` cmds: - task: common:util:task:tag:deps + template: deps: - install:npm:liquidjs @@ -1053,6 +1116,7 @@ tasks: preconditions: - sh: test -f .variables.json msg: This task requires that you have already spun up the project by running `task start` + test: deps: - install:software:jq @@ -1083,6 +1147,7 @@ tasks: else [[ $- == *i* ]] && task prepare || (.config/log error '{{.NONINTERACTIVE_MISSING_TEST_CMD}}' && exit 1) fi + update: desc: Fully update the repository summary: | @@ -1109,7 +1174,9 @@ tasks: cmds: - task: common:start env: - UPDATE_PROJECT: "true" + UPDATE_PROJECT: 'true' + - task: common:update:finish + yubikey: desc: Create an OpenGPG-enabled YubiKey summary: | diff --git a/meta/main.yml b/meta/main.yml index 0dd6fc20..44765981 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -7,7 +7,7 @@ galaxy_info: company: Megabyte Labs issue_tracker_url: https://gitlab.com/megabyte-labs/ansible-roles/rust/-/issues license: license (MIT) - min_ansible_version: 2.10 + min_ansible_version: 2.1 platforms: - name: Mac versions: diff --git a/package.json b/package.json index 3a23083a..a43fadd1 100644 --- a/package.json +++ b/package.json @@ -45,14 +45,14 @@ }, "optionalDependencies": {}, "devDependencies": { + "@commitlint/config-conventional": "latest", "eslint-config-strict-mode": "latest", "git-cz-emoji": "latest", + "handlebars-helpers": "latest", "prettier": "^2.4.1", "prettier-config-sexy-mode": "latest", "semantic-release-config": "latest", - "typescript": "^4.5.5", - "@commitlint/config-conventional": "latest", - "handlebars-helpers": "latest" + "typescript": "^4.5.5" }, "keywords": [ "ansible", @@ -118,7 +118,9 @@ "showAuthor": true }, "commitlint": { - "extends": [], + "extends": [ + "@commitlint/config-conventional" + ], "helpUrl": "https://megabyte.space/docs/contributing/commits" }, "eslintConfig": {