diff --git a/.dev-kit b/.dev-kit new file mode 160000 index 0000000..646f903 --- /dev/null +++ b/.dev-kit @@ -0,0 +1 @@ +Subproject commit 646f903ef30dd44f07c0481b67d63507f703411e diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b24b4e2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,45 @@ +# .editorconfig — Shared editor settings for TaxCloud repos. +# +# Installed by .dev-kit/install.sh as .editorconfig in the repo root. +# Most editors (VS Code, JetBrains, vim, etc.) respect this natively +# or via plugin. See https://editorconfig.org +# +# Like .gitattributes, this is committed and applies to all contributors. + +root = true + +# Default: 2-space indent, UTF-8, LF, trim trailing whitespace +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +# Makefiles require tabs +[Makefile] +indent_style = tab + +[*.mk] +indent_style = tab + +# Awk: tabs (idiomatic) +[*.awk] +indent_style = tab + +# Go: tabs (gofmt standard) +[*.go] +indent_style = tab + +# Shell scripts: 4-space indent (Google style, widely adopted) +[*.sh] +indent_size = 4 + +# YAML: 2-space (standard) +[*.{yml,yaml}] +indent_size = 2 + +# Markdown: preserve trailing whitespace (line breaks) +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 82b7f42..89d2b37 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,114 @@ -# Exclude dev/CI files from git archive (GitHub release ZIPs) -.gitignore export-ignore -.gitattributes export-ignore -.github/ export-ignore -.cursorrules export-ignore -Test/ export-ignore -Makefile export-ignore -run-test.sh export-ignore -scripts/ export-ignore -docs/images/ export-ignore +# .gitattributes — Shared line-ending, diff, and merge settings. +# +# Installed by .dev-kit/install.sh as .gitattributes in the repo root. +# Committed to the repo, so these rules apply to all contributors +# regardless of their local git config. +# +# This file makes core.autocrlf largely irrelevant: the rules below +# override it on a per-path basis, which is more precise and portable. + +# ============================================================================= +# Line Endings +# ============================================================================= +# Normalize to LF on commit, use platform-native on checkout. +# This single rule prevents most cross-platform line-ending bugs. +* text=auto + +# Force LF for files that break with CRLF (scripts, configs, Makefiles). +# A Windows checkout with CRLF in a shell script is a runtime error. +*.sh text eol=lf +*.bash text eol=lf +*.awk text eol=lf +Makefile text eol=lf +*.mk text eol=lf +*.yml text eol=lf +*.yaml text eol=lf +*.json text eol=lf +*.toml text eol=lf +Dockerfile text eol=lf +*.dockerfile text eol=lf + +# ============================================================================= +# Binary Files +# ============================================================================= +# Prevent git from applying line-ending conversion or textual merge +# to files that aren't text. Without these rules, git may corrupt +# binaries by "fixing" line endings. + +# Images +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.webp binary +*.svg binary + +# Fonts +*.woff binary +*.woff2 binary +*.ttf binary +*.otf binary +*.eot binary + +# Archives +*.zip binary +*.tar binary +*.tar.gz binary +*.tgz binary +*.gz binary + +# Documents +*.pdf binary + +# Compiled binaries (extensionless) +# Go, Rust, and C projects typically output to bin/ or dist/. +# Mark these directories as binary to prevent line-ending corruption. +bin/** binary +dist/** binary +out/** binary + +# Other binary formats that lack common extensions +*.wasm binary +*.pb binary +*.pyc binary +*.so binary +*.dylib binary +*.dll binary +*.exe binary + +# ============================================================================= +# Better Diffs +# ============================================================================= +# Tell git which language driver to use for diff hunk headers. +# Instead of showing the nearest line, git shows the enclosing +# function/class name — much easier to orient yourself in a diff. +*.go diff=golang +*.py diff=python +*.rb diff=ruby +*.html diff=html +*.htm diff=html +*.css diff=css +*.md diff=markdown +*.markdown diff=markdown + +# ============================================================================= +# Lock Files +# ============================================================================= +# Generated lock files produce huge, unreadable diffs. Suppress the +# diff output (they still show as changed, just without the noise). +package-lock.json -diff +yarn.lock -diff +pnpm-lock.yaml -diff +go.sum -diff +Cargo.lock -diff +Gemfile.lock -diff +poetry.lock -diff +composer.lock -diff + +# Merge strategy: lock files should be regenerated, not merged. +# "ours" keeps the current branch's version; the developer then +# re-runs the package manager to reconcile. +package-lock.json merge=ours +yarn.lock merge=ours +pnpm-lock.yaml merge=ours diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c49bc07 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +# Dependabot configuration — generated by .dev-kit/ci/scaffold.sh +# Source: .dev-kit/ci/templates/dependabot.yml +# Keeps GitHub Actions and submodules up to date. + +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + groups: + actions: + patterns: ["*"] + + - package-ecosystem: gitsubmodule + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/auto-merge-devkit.yml b/.github/workflows/auto-merge-devkit.yml new file mode 100644 index 0000000..11e7bf9 --- /dev/null +++ b/.github/workflows/auto-merge-devkit.yml @@ -0,0 +1,32 @@ +# Auto-merge .dev-kit submodule updates — generated by .dev-kit/ci/scaffold.sh +# Source: .dev-kit/ci/templates/auto-merge-devkit.yml +# Automatically merges Dependabot PRs that bump the .dev-kit submodule +# after CI passes. Requires Dependabot to be configured (see dependabot.yml). + +name: Auto-merge .dev-kit + +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + auto-merge: + name: Auto-merge .dev-kit updates + if: github.actor == 'dependabot[bot]' + runs-on: ubuntu-latest + + steps: + - name: Dependabot metadata + id: meta + uses: dependabot/fetch-metadata@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Auto-merge .dev-kit submodule bumps + if: steps.meta.outputs.dependency-names == '.dev-kit' + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e4d1411 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +# CI workflow — generated by .dev-kit/ci/scaffold.sh +# Source: .dev-kit/ci/templates/ci.yml +# Runs lint, test, and build on every push and pull request. +# +# Relies on standard Make targets from .dev-kit/mk/common.mk. +# Customize behavior by defining _lint, _test, _build in your Makefile. + +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + ci: + name: Lint / Test / Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Lint + run: make lint + + - name: Test + run: make test + + - name: Build + run: make build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2a35cac --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +# Release workflow — generated by .dev-kit/ci/scaffold.sh +# Source: .dev-kit/ci/templates/release.yml +# Creates a GitHub release when a version tag is pushed. +# +# Tag format: v1.2.3 + +name: Release + +on: + push: + tags: ['v*'] + +permissions: + contents: write + +jobs: + release: + name: Create Release + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Build + run: make build + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5f04e2f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".dev-kit"] + path = .dev-kit + url = git@github.com:FedTax/.dev-kit.git diff --git a/Makefile b/Makefile index 0e055c5..76040c8 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,18 @@ -.PHONY: test test-local test-unit test-compatibility lint lint-fix help - -# Default target -help: - @echo "Available commands:" - @echo " make test - Run all tests using Docker" - @echo " make test-local - Run all tests locally (requires PHP)" - @echo " make test-unit - Run unit tests only" - @echo " make test-compatibility - Run Adobe Commerce 2.4.8-p1 compatibility tests" - @echo " make lint - Run PHP CodeSniffer linting" - @echo " make lint-fix - Auto-fix linting issues where possible" - @echo " make help - Show this help message" - -# Run all tests using Docker -test: +include .dev-kit/mk/common.mk + +.PHONY: _test _lint test-local test-unit test-compatibility lint-fix + +# -------------------------------------------------------------------------- +# Standard interface implementations +# -------------------------------------------------------------------------- + +##@ Testing + +_test: ## Run all tests using Docker @echo "Running all tests with Docker..." @./run-test.sh -# Run tests locally (requires PHP) -test-local: +test-local: ## Run all tests locally (requires PHP) @echo "Running all tests locally..." @vendor/bin/phpunit Test/Unit/ --testdox @for test_file in Test/Integration/*.php; do \ @@ -25,18 +20,17 @@ test-local: php "$$test_file"; \ done -# Run unit tests only -test-unit: +test-unit: ## Run unit tests only @echo "Running unit tests..." @vendor/bin/phpunit Test/Unit/ --testdox -# Run Adobe Commerce 2.4.8-p1 compatibility tests -test-compatibility: +test-compatibility: ## Run Adobe Commerce 2.4.8-p1 compatibility tests @echo "Running Adobe Commerce 2.4.8-p1 compatibility tests..." @php Test/Integration/AdobeCommerce248p1CompatibilityTest.php -# Run PHP CodeSniffer linting -lint: +##@ Code Quality + +_lint: ## Run PHP CodeSniffer linting @echo "Running PHP CodeSniffer..." @lint_output=$$(phpcs --standard=PSR2 --extensions=php Model/ Observer/ Logger/ Setup/ --ignore=Test/ 2>&1 || true); \ if echo "$$lint_output" | grep -q "FOUND [1-9][0-9]* ERROR"; then \ @@ -48,7 +42,6 @@ lint: echo "$$lint_output"; \ fi -# Auto-fix PHP CodeSniffer issues where possible -lint-fix: +lint-fix: ## Auto-fix PHP CodeSniffer issues where possible @echo "Auto-fixing PHP CodeSniffer issues..." @phpcbf --standard=PSR2 --extensions=php Model/ Observer/ Logger/ Setup/ --ignore=Test/