From 5b49f7c930c6ade6d517bc6b31aa8ae5007c3bb5 Mon Sep 17 00:00:00 2001 From: Megabyte Labs Date: Mon, 21 Mar 2022 05:02:17 -0400 Subject: [PATCH] =?UTF-8?q?=E2=A4=B5=EF=B8=8F=20automation(synchronize)=20?= =?UTF-8?q?Applying=20changes=20from=20upstream=20repository.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/codeclimate.yml | 2 + Taskfile.yml | 93 ++++++++++++++++++++++++++++++++--------- meta/main.yml | 2 +- package.json | 14 +++++-- 4 files changed, 87 insertions(+), 24 deletions(-) diff --git a/.config/codeclimate.yml b/.config/codeclimate.yml index 278e3288..a451d1ec 100644 --- a/.config/codeclimate.yml +++ b/.config/codeclimate.yml @@ -8,6 +8,8 @@ plugins: enabled: true eslint: enabled: true + jscpd: + enabled: true shellcheck: enabled: true yamllint: diff --git a/Taskfile.yml b/Taskfile.yml index 9fff4ce4..24457b49 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,5 +1,6 @@ --- version: '3' + includes: ansible: ./.config/taskfiles/ansible/Taskfile.yml ansible:ansibler: ./.config/taskfiles/ansible/Taskfile-ansibler.yml @@ -85,7 +86,9 @@ includes: web:ionic: ./.config/taskfiles/web/Taskfile-ionic.yml web:nx: ./.config/taskfiles/web/Taskfile-nx.yml web:profile: ./.config/taskfiles/web/Taskfile-profile.yml + output: interleaved + vars: DOCKERHUB_PROFILE: sh: | @@ -136,7 +139,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 './.github/*' -o -path './.gitlab/*' -o -path './.husky/*' -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' + -path './.autodoc/*' -o -path './.cache/*' -o -path './.common*' -o -path './.config/*' -o -path './.git/*' -o + -path './.github/*' -o -path './.gitlab/*' -o -path './.husky/*' -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' INIT_SCRIPT: https://gitlab.com/megabyte-labs/gitlab-ci/-/raw/master/scripts/update-init.sh LOG_FIX: sh: chmod +x .config/log @@ -175,27 +182,41 @@ vars: # yamllint enable rule:line-length PYTHON_HANDLE: sh: | - if [ -n "$NO_INSTALL_POETRY" ] || ! type poetry > /dev/null; then - echo '' - else + if type poetry > /dev/null; then echo 'poetry run ' + else + echo '' 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 - SEMANTIC_CONFIG: semantic-release-config - TIMEZONE: America/New_York - NPX_PACKAGE: sh: | - if type pnpx &> /dev/null; then - echo 'pnpx' - elif type pnpm &> /dev/null; then - echo 'pnpm' + 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 - includes: - common:start: ./.config/taskfiles/common/Taskfile-start.yml + SEMANTIC_CONFIG: semantic-release-config + TIMEZONE: America/New_York + env: OSTYPE: sh: | @@ -209,6 +230,7 @@ env: sh: | DSN="$(jq -r '.blueprint.sentryDSN' package.json)" if [ "$DSN" != 'null' ]; then echo "$DSN"; fi + profile: | PATH="$PATH:$HOME/.local/bin:$HOME/.poetry/bin" if [[ "$OSTYPE" == 'linux-gnu'* ]] || [[ "$OSTYPE" == 'linux-musl'* ]]; then @@ -228,6 +250,7 @@ profile: | if [ -f .venv/bin/activate ]; then . .venv/bin/activate fi + tasks: build: deps: @@ -252,6 +275,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: | @@ -262,11 +286,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: | @@ -283,6 +309,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 @@ -320,6 +347,7 @@ tasks: git add --all git commit {{end}} + commit:quick: deps: - ci:commit:config @@ -327,13 +355,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: | @@ -344,6 +375,7 @@ tasks: an error so the auto-fixes still have to be validated. cmds: - task: fix:all + get:links: deps: - install:software:jq @@ -356,6 +388,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: | @@ -376,6 +409,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 @@ -408,6 +442,7 @@ tasks: - git init - task: repair - task: prepare + lint: desc: Lints the project using all linters summary: | @@ -421,6 +456,7 @@ tasks: `task lint` cmds: - task: lint:all + livereload: deps: - install:npm:nodemon @@ -460,10 +496,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: | @@ -506,6 +544,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: | @@ -522,6 +561,7 @@ tasks: cmds: - task: boilerplate:check:package - task: boilerplate:clean + publish: desc: Publish a semantic release via `semantic-release` summary: | @@ -569,6 +609,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: | @@ -594,8 +635,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 build(version bump): semantic-release {{.UPDATE_LEVEL}}' -n\n" + - | + HUSKY=0 git commit -a --allow-empty -m '🔨 build(version bump): semantic-release {{.UPDATE_LEVEL}}' -n - task: publish + pull:upstream: desc: Pull from upstream repositories summary: | @@ -612,6 +655,7 @@ tasks: success: Successfully pulled from `upstreamRemotes` cmds: - task: common:update:upstream:remotes:pull + repair: cmds: - task: common:repair @@ -621,6 +665,7 @@ tasks: else bash <(curl -sSL {{.INIT_SCRIPT}}) fi + reset: desc: Resets the project by removing all caches and then re-generating templated files summary: | @@ -632,6 +677,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: | @@ -650,6 +696,7 @@ tasks: answer: cmds: - task: common:reset:force + scripts: interactive: true deps: @@ -667,6 +714,7 @@ tasks: start: Running `NTL_RUNNER={{.NPM_PROGRAM}} {{.NPX_HANDLE}}ntl` cmds: - NTL_RUNNER={{.NPM_PROGRAM}} {{.NPX_HANDLE}}ntl + services: desc: Update elements of the repository that require API access summary: | @@ -679,6 +727,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: | @@ -712,6 +761,7 @@ tasks: * ubuntu-21.04 cmds: - task: common:shell + start: desc: Start the project by installing / updating dependencies, repairing issues, and opening a tutorial summary: | @@ -735,6 +785,7 @@ tasks: success: Project started! cmds: - task: common:start + synchronize: desc: Set up the project and refresh it with the latest changes summary: | @@ -755,6 +806,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: | @@ -783,6 +835,7 @@ tasks: ``` cmds: - task: common:util:task:tag:deps + template: deps: - install:npm:liquidjs @@ -804,6 +857,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 @@ -834,6 +888,7 @@ tasks: else [[ $- == *i* ]] && task prepare || (.config/log error '{{.NONINTERACTIVE_MISSING_TEST_CMD}}' && exit 1) fi + update: desc: Fully update the repository summary: | @@ -860,4 +915,4 @@ tasks: cmds: - task: common:start env: - UPDATE_PROJECT: "true" + UPDATE_PROJECT: 'true' 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 dba4341d..9eb6597e 100644 --- a/package.json +++ b/package.json @@ -40,13 +40,13 @@ "dependencies": {}, "optionalDependencies": {}, "devDependencies": { + "@commitlint/config-conventional": "latest", "eslint-config-strict-mode": "latest", "git-cz-emoji": "latest", + "handlebars-helpers": "latest", "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", @@ -109,7 +109,9 @@ "showAuthor": true }, "commitlint": { - "extends": [], + "extends": [ + "@commitlint/config-conventional" + ], "helpUrl": "https://megabyte.space/docs/contributing/commits" }, "eslintConfig": { @@ -128,6 +130,10 @@ "url": "https://www.patreon.com/ProfessorManhattan" } ], + "jscpd": { + "gitignore": true, + "threshold": 0.1 + }, "lint-staged": { "(Brewfile|composer.lock|Gemfile|Gopkg.lock|Pipfile.lock)": [ "task fix:prettier --"