diff --git a/.github/DISCUSSION_TEMPLATE/ideas.yml b/.github/DISCUSSION_TEMPLATE/ideas.yml new file mode 100644 index 0000000..d075373 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/ideas.yml @@ -0,0 +1,31 @@ +title: "[Idea]: " +labels: ["enhancement"] +body: + - type: markdown + attributes: + value: | + Share an idea, workflow improvement, or experiment proposal before opening a formal feature request or PR. + + - type: textarea + id: summary + attributes: + label: Idea Summary + description: What would you like to build, add, or change? + placeholder: Briefly describe the idea... + validations: + required: true + + - type: textarea + id: motivation + attributes: + label: Problem or Motivation + description: Why is this useful, and what pain point does it solve? + placeholder: Explain the use case... + validations: + required: true + + - type: textarea + id: context + attributes: + label: Design Notes or Alternatives + description: Optional sketches, CLI/UI examples, or trade-offs to consider. diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml new file mode 100644 index 0000000..6fef4ce --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -0,0 +1,26 @@ +title: "[Question]: " +labels: ["question"] +body: + - type: markdown + attributes: + value: | + Ask a question about setup, usage, architecture, or troubleshooting. + + - type: textarea + id: question + attributes: + label: Question + description: What are you trying to do or understand? + placeholder: Describe your question clearly... + validations: + required: true + + - type: textarea + id: context + attributes: + label: Context and Environment + description: Relevant project version, OS, configuration, or commands already tried. + placeholder: | + - Project / version: + - OS: + - What I tried: diff --git a/.github/labels.json b/.github/labels.json new file mode 100644 index 0000000..c02cf1b --- /dev/null +++ b/.github/labels.json @@ -0,0 +1,82 @@ +[ + { + "name": "bug", + "color": "d73a4a", + "description": "Something is not working as expected" + }, + { + "name": "enhancement", + "color": "a2eeef", + "description": "New feature or improvement request" + }, + { + "name": "documentation", + "color": "0075ca", + "description": "Improvements or additions to documentation" + }, + { + "name": "duplicate", + "color": "cfd3d7", + "description": "This issue or pull request already exists" + }, + { + "name": "good first issue", + "color": "7057ff", + "description": "Good starting point for newcomers" + }, + { + "name": "help wanted", + "color": "008672", + "description": "Extra attention or community help is welcome" + }, + { + "name": "invalid", + "color": "e4e669", + "description": "Does not appear valid or actionable" + }, + { + "name": "question", + "color": "d876e3", + "description": "Further information or clarification requested" + }, + { + "name": "wontfix", + "color": "ffffff", + "description": "This will not be worked on" + }, + { + "name": "needs-triage", + "color": "fbca04", + "description": "Awaiting maintainer review and categorization" + }, + { + "name": "dependencies", + "color": "0366d6", + "description": "Dependency version updates" + }, + { + "name": "security", + "color": "b60205", + "description": "Security vulnerability, hardening, or advisory" + }, + { + "name": "ci", + "color": "1d76db", + "description": "Continuous integration, release, or workflow changes" + }, + { + "name": "github-actions", + "color": "2088ff", + "description": "GitHub Actions workflow updates" + }, + { + "name": "go", + "color": "00add8", + "description": "Go code or toolchain" + }, + { + "name": "rust", + "color": "dea584", + "description": "Rust code or toolchain" + } +] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e124f6c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: Validate Shared Config + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: validate-${{ github.ref }} + cancel-in-progress: true + +jobs: + validate: + name: Validate templates, labels, and workflows + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - name: Validate labels.json schema + run: | + set -euo pipefail + jq -e ' + type == "array" and length > 0 and + all(.[]; + (.name | type == "string" and length > 0) and + (.color | type == "string" and test("^[0-9a-fA-F]{6}$")) and + (.description | type == "string" and length <= 100) + ) + ' .github/labels.json > /dev/null + + - name: Validate YAML files and discussion form keys + run: | + set -euo pipefail + ruby -ryaml -e ' + files = Dir.glob(["*.yml", "ISSUE_TEMPLATE/*.yml", ".github/DISCUSSION_TEMPLATE/*.yml", ".github/workflows/*.yml"]) + raise "No YAML files matched" if files.empty? + files.each do |f| + data = YAML.load_file(f) + raise "#{f} parsed to nil" if data.nil? + end + Dir.glob(".github/DISCUSSION_TEMPLATE/*.yml").each do |f| + data = YAML.load_file(f) + extra = data.keys - ["title", "labels", "body"] + raise "#{f} contains unsupported top-level keys: #{extra.join(", ")}" unless extra.empty? + end + puts "Validated #{files.length} YAML files" + ' + + - name: Set up Go for actionlint + uses: actions/setup-go@v7 + with: + go-version: "stable" + + - name: Install and run actionlint + run: | + set -euo pipefail + go install github.com/rhysd/actionlint/cmd/actionlint@latest + actionlint -color diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..050bb39 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,34 @@ +name: Dependency Review + +on: + workflow_call: + inputs: + fail-on-severity: + description: "Minimum vulnerability severity that fails the check (low, moderate, high, critical)" + required: false + type: string + default: "moderate" + allow-licenses: + description: "Comma-separated list of SPDX license identifiers allowed in dependencies" + required: false + type: string + default: "MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, 0BSD, MPL-2.0" + +permissions: + contents: read + pull-requests: write + +jobs: + dependency-review: + name: Dependency Review + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Dependency Review + uses: actions/dependency-review-action@v5 + with: + fail-on-severity: ${{ inputs.fail-on-severity }} + comment-summary-in-pr: always + allow-licenses: ${{ inputs.allow-licenses }} diff --git a/.github/workflows/docs-pages.yml b/.github/workflows/docs-pages.yml new file mode 100644 index 0000000..9e138f0 --- /dev/null +++ b/.github/workflows/docs-pages.yml @@ -0,0 +1,86 @@ +name: Docs Pages + +on: + workflow_call: + inputs: + working-directory: + description: "Directory containing package.json and pnpm-lock.yaml" + required: false + type: string + default: "docs" + artifact-path: + description: "Built static site output directory to upload to GitHub Pages" + required: false + type: string + default: "docs/dist" + node-version: + description: "Node.js version to use for building the site" + required: false + type: string + default: "22" + build-command: + description: "Build command executed inside working-directory" + required: false + type: string + default: "pnpm build" + deploy: + description: "Deploy the uploaded artifact to GitHub Pages (set false on pull_request checks)" + required: false + type: boolean + default: true + +permissions: + contents: read + pages: write + id-token: write + +jobs: + build: + name: Build site + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Set up Node + uses: actions/setup-node@v7 + with: + node-version: ${{ inputs.node-version }} + + - name: Enable corepack + run: corepack enable + + - name: Install dependencies + working-directory: ${{ inputs.working-directory }} + run: pnpm install --frozen-lockfile + + - name: Build static site + working-directory: ${{ inputs.working-directory }} + env: + BUILD_CMD: ${{ inputs.build-command }} + run: | + set -euo pipefail + eval "$BUILD_CMD" + + - name: Configure Pages + if: inputs.deploy + uses: actions/configure-pages@v6 + + - name: Upload Pages artifact + if: inputs.deploy + uses: actions/upload-pages-artifact@v5 + with: + path: ${{ inputs.artifact-path }} + + deploy: + name: Deploy to GitHub Pages + if: inputs.deploy + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy artifact + id: deployment + uses: actions/deploy-pages@v5 diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml new file mode 100644 index 0000000..35f2836 --- /dev/null +++ b/.github/workflows/go-ci.yml @@ -0,0 +1,193 @@ +name: Go CI + +on: + workflow_call: + inputs: + go-version-file: + description: "Path to go.mod or .go-version used to select the Go toolchain" + required: false + type: string + default: "go.mod" + build-tags: + description: "Optional comma-separated Go build tags (for example 'nodbus')" + required: false + type: string + default: "" + build-packages: + description: "Go package pattern to compile in the build job" + required: false + type: string + default: "./..." + golangci-args: + description: "Arguments passed to golangci-lint" + required: false + type: string + default: "--timeout=5m" + generate-check-paths: + description: "Optional space-separated paths that must stay clean after running 'go generate ./...'" + required: false + type: string + default: "" + trivy-severity: + description: "Comma-separated Trivy severities to scan for" + required: false + type: string + default: "CRITICAL,HIGH" + trivy-exit-code: + description: "Exit code returned by Trivy when vulnerabilities are found ('1' fails CI, '0' reports only)" + required: false + type: string + default: "1" + os-matrix: + description: "JSON array of GitHub-hosted runner OS labels for test and build jobs" + required: false + type: string + default: '["ubuntu-latest","macos-latest","windows-latest"]' + secrets: + CODECOV_TOKEN: + description: "Optional Codecov upload token" + required: false + +permissions: + contents: read + security-events: write + +jobs: + test: + name: Test (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ${{ fromJson(inputs.os-matrix) }} + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Set up Go + uses: actions/setup-go@v7 + with: + go-version-file: ${{ inputs.go-version-file }} + + - name: Download and verify dependencies + run: | + go mod download + go mod verify + + - name: Run tests + shell: bash + env: + BUILD_TAGS: ${{ inputs.build-tags }} + run: | + set -euo pipefail + if [ -n "$BUILD_TAGS" ]; then + go test -v -race "-tags=${BUILD_TAGS}" -coverprofile=coverage.txt -covermode=atomic ./... + else + go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... + fi + + - name: Upload coverage to Codecov + if: matrix.os == 'ubuntu-latest' + uses: codecov/codecov-action@v7 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.txt + fail_ci_if_error: false + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Set up Go + uses: actions/setup-go@v7 + with: + go-version-file: ${{ inputs.go-version-file }} + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v9 + with: + version: latest + args: ${{ inputs.golangci-args }} + + generate: + name: Generated Files Check + if: inputs.generate-check-paths != '' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Set up Go + uses: actions/setup-go@v7 + with: + go-version-file: ${{ inputs.go-version-file }} + + - name: Verify generated files are up to date + env: + CHECK_PATHS: ${{ inputs.generate-check-paths }} + run: | + set -euo pipefail + go generate ./... + # shellcheck disable=SC2086 + if ! git diff --exit-code -- $CHECK_PATHS || [ -n "$(git status --porcelain -- $CHECK_PATHS)" ]; then + echo "::error::Generated files are out of date. Run 'go generate ./...' and commit the result." + exit 1 + fi + + security: + name: Security Scan + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@v0.36.0 + with: + scan-type: "fs" + scan-ref: "." + format: "sarif" + output: "trivy-results.sarif" + severity: ${{ inputs.trivy-severity }} + exit-code: ${{ inputs.trivy-exit-code }} + + - name: Upload Trivy results to GitHub Security tab + if: always() + uses: github/codeql-action/upload-sarif@v4 + with: + sarif_file: "trivy-results.sarif" + + build: + name: Build (${{ matrix.os }}) + needs: [test, lint, security] + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ${{ fromJson(inputs.os-matrix) }} + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Set up Go + uses: actions/setup-go@v7 + with: + go-version-file: ${{ inputs.go-version-file }} + + - name: Build packages + shell: bash + env: + BUILD_TAGS: ${{ inputs.build-tags }} + BUILD_PACKAGES: ${{ inputs.build-packages }} + run: | + set -euo pipefail + if [ -n "$BUILD_TAGS" ]; then + # shellcheck disable=SC2086 + go build -v "-tags=${BUILD_TAGS}" $BUILD_PACKAGES + else + # shellcheck disable=SC2086 + go build -v $BUILD_PACKAGES + fi diff --git a/.github/workflows/go-release.yml b/.github/workflows/go-release.yml new file mode 100644 index 0000000..a3642c5 --- /dev/null +++ b/.github/workflows/go-release.yml @@ -0,0 +1,191 @@ +name: Go Release + +on: + workflow_call: + inputs: + go-version-file: + description: "Path to go.mod or .go-version used to select the Go toolchain" + required: false + type: string + default: "go.mod" + build-tags: + description: "Optional comma-separated Go build tags passed to pre-release tests" + required: false + type: string + default: "" + run-tests: + description: "Run 'go test -race ./...' before tagging and running GoReleaser" + required: false + type: boolean + default: true + initial-tag: + description: "Tag to create when the repository has no existing v*.*.* tags" + required: false + type: string + default: "v0.1.0" + tag: + description: "Explicit existing tag to release (leave empty to compute and push from conventional commits)" + required: false + type: string + default: "" + goreleaser-version: + description: "GoReleaser version constraint" + required: false + type: string + default: "~> v2" + goreleaser-args: + description: "Arguments passed to GoReleaser" + required: false + type: string + default: "release --clean" + secrets: + HOMEBREW_TOKEN: + description: "PAT with push access to techquestsdev/homebrew-tap" + required: false + RELEASE_TOKEN: + description: "Optional PAT or GitHub App token used for tag creation and GitHub Releases (defaults to github.token)" + required: false + +permissions: + contents: write + +jobs: + version: + name: Compute release version + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.version.outputs.tag }} + created_new: ${{ steps.version.outputs.created_new }} + steps: + - name: Checkout repository history + uses: actions/checkout@v7 + with: + fetch-depth: 0 + token: ${{ secrets.RELEASE_TOKEN || github.token }} + + - name: Resolve or compute next semver tag + id: version + env: + EXPLICIT_TAG: ${{ inputs.tag }} + HEAD_MSG: ${{ github.event.head_commit.message }} + INITIAL_TAG: ${{ inputs.initial-tag }} + run: | + set -euo pipefail + + if [ -n "$EXPLICIT_TAG" ]; then + echo "Using explicit tag ${EXPLICIT_TAG}" + { + echo "tag=${EXPLICIT_TAG}" + echo "created_new=false" + } >> "$GITHUB_OUTPUT" + exit 0 + fi + + if grep -Fq '[skip release]' <<<"$HEAD_MSG"; then + echo "Head commit contains [skip release]; skipping release" + { + echo "tag=" + echo "created_new=false" + } >> "$GITHUB_OUTPUT" + exit 0 + fi + + latest=$(git tag -l 'v*.*.*' | sort -V | tail -n1) + if [ -z "$latest" ]; then + echo "No existing tag found; starting at ${INITIAL_TAG}" + { + echo "tag=${INITIAL_TAG}" + echo "created_new=true" + } >> "$GITHUB_OUTPUT" + exit 0 + fi + + range="${latest}..HEAD" + subjects=$(git log "$range" --format='%s') + bodies=$(git log "$range" --format='%b') + + bump="none" + if grep -qE '^[a-z]+(\([^)]+\))?!:' <<<"$subjects" || grep -qiE '^BREAKING[ -]CHANGE:' <<<"$bodies"; then + bump="major" + elif grep -qE '^feat(\([^)]+\))?:' <<<"$subjects"; then + bump="minor" + elif grep -qE '^(fix|perf)(\([^)]+\))?:' <<<"$subjects"; then + bump="patch" + fi + + if [ "$bump" = "none" ]; then + echo "No feat/fix/perf/breaking commits since ${latest}; skipping release" + { + echo "tag=" + echo "created_new=false" + } >> "$GITHUB_OUTPUT" + exit 0 + fi + + IFS='.' read -r major minor patch <<< "${latest#v}" + case "$bump" in + major) next="v$((major + 1)).0.0" ;; + minor) next="v${major}.$((minor + 1)).0" ;; + patch) next="v${major}.${minor}.$((patch + 1))" ;; + esac + + echo "Computed ${next} (${bump} bump from ${latest})" + { + echo "tag=${next}" + echo "created_new=true" + } >> "$GITHUB_OUTPUT" + + release: + name: Build and publish release + needs: version + if: needs.version.outputs.tag != '' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + with: + ref: ${{ needs.version.outputs.created_new == 'false' && needs.version.outputs.tag || '' }} + fetch-depth: 0 + token: ${{ secrets.RELEASE_TOKEN || github.token }} + + - name: Set up Go + uses: actions/setup-go@v7 + with: + go-version-file: ${{ inputs.go-version-file }} + + - name: Run pre-release tests + if: inputs.run-tests + env: + BUILD_TAGS: ${{ inputs.build-tags }} + run: | + set -euo pipefail + if [ -n "$BUILD_TAGS" ]; then + go test -race "-tags=${BUILD_TAGS}" ./... + else + go test -race ./... + fi + + - name: Create and push tag + if: needs.version.outputs.created_new == 'true' + env: + NEW_TAG: ${{ needs.version.outputs.tag }} + run: | + set -euo pipefail + if git rev-parse -q --verify "refs/tags/${NEW_TAG}" >/dev/null; then + echo "Tag ${NEW_TAG} already exists on origin; skipping tag creation" + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "$NEW_TAG" -m "Release $NEW_TAG" + git push origin "$NEW_TAG" + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v7 + with: + distribution: goreleaser + version: ${{ inputs.goreleaser-version }} + args: ${{ inputs.goreleaser-args }} + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }} + HOMEBREW_TOKEN: ${{ secrets.HOMEBREW_TOKEN }} diff --git a/.github/workflows/semver-tag.yml b/.github/workflows/semver-tag.yml new file mode 100644 index 0000000..949cd5b --- /dev/null +++ b/.github/workflows/semver-tag.yml @@ -0,0 +1,124 @@ +name: Semver Tag + +on: + workflow_call: + inputs: + initial-tag: + description: "Tag to create when the repository has no existing v*.*.* tags" + required: false + type: string + default: "v0.1.0" + push-tag: + description: "Create and push the computed tag to origin" + required: false + type: boolean + default: true + secrets: + RELEASE_TOKEN: + description: "Optional PAT or GitHub App token so tag pushes trigger downstream tag workflows (defaults to github.token)" + required: false + outputs: + tag: + description: "Computed vX.Y.Z tag, or empty string when skipped" + value: ${{ jobs.tag.outputs.tag }} + bump: + description: "Detected bump level: major, minor, patch, or none" + value: ${{ jobs.tag.outputs.bump }} + skipped: + description: "Whether tagging was skipped ('true' or 'false')" + value: ${{ jobs.tag.outputs.skipped }} + +permissions: + contents: write + +jobs: + tag: + name: Compute and push semver tag + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.version.outputs.tag }} + bump: ${{ steps.version.outputs.bump }} + skipped: ${{ steps.version.outputs.skipped }} + steps: + - name: Checkout repository history + uses: actions/checkout@v7 + with: + fetch-depth: 0 + token: ${{ secrets.RELEASE_TOKEN || github.token }} + + - name: Compute next version from conventional commits + id: version + env: + HEAD_MSG: ${{ github.event.head_commit.message }} + INITIAL_TAG: ${{ inputs.initial-tag }} + run: | + set -euo pipefail + + if grep -Fq '[skip release]' <<<"$HEAD_MSG"; then + echo "Head commit contains [skip release]; skipping" + { + echo "tag=" + echo "bump=none" + echo "skipped=true" + } >> "$GITHUB_OUTPUT" + exit 0 + fi + + latest=$(git tag -l 'v*.*.*' | sort -V | tail -n1) + if [ -z "$latest" ]; then + echo "No existing tag found; starting at ${INITIAL_TAG}" + { + echo "tag=${INITIAL_TAG}" + echo "bump=initial" + echo "skipped=false" + } >> "$GITHUB_OUTPUT" + exit 0 + fi + + range="${latest}..HEAD" + subjects=$(git log "$range" --format='%s') + bodies=$(git log "$range" --format='%b') + + bump="none" + if grep -qE '^[a-z]+(\([^)]+\))?!:' <<<"$subjects" || grep -qiE '^BREAKING[ -]CHANGE:' <<<"$bodies"; then + bump="major" + elif grep -qE '^feat(\([^)]+\))?:' <<<"$subjects"; then + bump="minor" + elif grep -qE '^(fix|perf)(\([^)]+\))?:' <<<"$subjects"; then + bump="patch" + fi + + if [ "$bump" = "none" ]; then + echo "No feat/fix/perf/breaking commits since ${latest}; skipping release" + { + echo "tag=" + echo "bump=none" + echo "skipped=true" + } >> "$GITHUB_OUTPUT" + exit 0 + fi + + IFS='.' read -r major minor patch <<< "${latest#v}" + case "$bump" in + major) next="v$((major + 1)).0.0" ;; + minor) next="v${major}.$((minor + 1)).0" ;; + patch) next="v${major}.${minor}.$((patch + 1))" ;; + esac + + echo "Computed ${next} (${bump} bump from ${latest})" + { + echo "tag=${next}" + echo "bump=${bump}" + echo "skipped=false" + } >> "$GITHUB_OUTPUT" + + - name: Create and push tag + if: inputs.push-tag && steps.version.outputs.skipped != 'true' && steps.version.outputs.tag != '' + env: + NEW_TAG: ${{ steps.version.outputs.tag }} + run: | + set -euo pipefail + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "$NEW_TAG" -m "Release $NEW_TAG" + git push origin "$NEW_TAG" diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..5364891 --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,84 @@ +name: Sync Labels + +on: + workflow_call: + inputs: + prune: + description: "Delete repository labels that are not in the canonical labels.json list" + required: false + type: boolean + default: false + secrets: + LABELS_TOKEN: + description: "Optional PAT with repo/issues write access (defaults to github.token)" + required: false + workflow_dispatch: + inputs: + target: + description: "Repository slug (techquestsdev/repo) or 'all' to sync every non-archived org repo" + required: false + type: string + default: "techquestsdev/.github" + prune: + description: "Delete repository labels that are not in the canonical labels.json list" + required: false + type: boolean + default: false + +permissions: + contents: read + issues: write + +jobs: + sync: + name: Sync canonical labels + runs-on: ubuntu-latest + steps: + - name: Checkout canonical label definitions + uses: actions/checkout@v7 + with: + repository: techquestsdev/.github + path: org-github + + - name: Upsert labels + env: + GH_TOKEN: ${{ secrets.LABELS_TOKEN || github.token }} + EVENT_NAME: ${{ github.event_name }} + CALLER_REPO: ${{ github.repository }} + DISPATCH_TARGET: ${{ inputs.target }} + PRUNE: ${{ inputs.prune }} + run: | + set -euo pipefail + + labels_file="org-github/.github/labels.json" + jq empty "$labels_file" + + if [ "$EVENT_NAME" = "workflow_dispatch" ] && [ -n "$DISPATCH_TARGET" ]; then + if [ "$DISPATCH_TARGET" = "all" ]; then + mapfile -t repos < <(gh repo list techquestsdev --limit 200 --no-archived --json nameWithOwner --jq '.[].nameWithOwner') + else + repos=("$DISPATCH_TARGET") + fi + else + repos=("$CALLER_REPO") + fi + + for repo in "${repos[@]}"; do + echo "Syncing labels for ${repo}..." + jq -c '.[]' "$labels_file" | while IFS= read -r item; do + name=$(jq -r '.name' <<<"$item") + color=$(jq -r '.color' <<<"$item") + desc=$(jq -r '.description' <<<"$item") + gh label create "$name" --repo "$repo" --color "$color" --description "$desc" --force + done + + if [ "$PRUNE" = "true" ]; then + canonical=$(jq -r '.[].name' "$labels_file") + gh label list --repo "$repo" --limit 200 --json name --jq '.[].name' | while IFS= read -r existing; do + if ! grep -Fxq "$existing" <<<"$canonical"; then + echo "Pruning extra label '${existing}' from ${repo}" + gh label delete "$existing" --repo "$repo" --yes + fi + done + fi + done diff --git a/ISSUE_TEMPLATE/bug_report.yml b/ISSUE_TEMPLATE/bug_report.yml index c7c2c03..1f6c933 100644 --- a/ISSUE_TEMPLATE/bug_report.yml +++ b/ISSUE_TEMPLATE/bug_report.yml @@ -25,10 +25,9 @@ body: label: Steps to Reproduce description: Steps to reproduce the behavior placeholder: | - 1. Go to '...' - 2. Click on '....' - 3. Enter cron expression '...' - 4. See error + 1. Run or open '...' + 2. Perform '...' + 3. See error validations: required: true @@ -54,7 +53,7 @@ body: id: version attributes: label: Version - description: What version of crontab-guru are you running? + description: What version of the project are you running? placeholder: v1.0.0 or commit hash validations: required: true diff --git a/ISSUE_TEMPLATE/config.yml b/ISSUE_TEMPLATE/config.yml index a37ae0e..28591c3 100644 --- a/ISSUE_TEMPLATE/config.yml +++ b/ISSUE_TEMPLATE/config.yml @@ -3,6 +3,6 @@ contact_links: - name: Discussions url: https://github.com/techquestsdev/blog/discussions about: Ask questions and discuss ideas with the community - - name: Documentation - url: https://github.com/techquestsdev/blog#readme - about: Read the documentation for help and examples + - name: Projects & Documentation + url: https://techquests.dev/projects + about: Browse Tech Quests projects, guides, and documentation diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0e08c4 --- /dev/null +++ b/README.md @@ -0,0 +1,206 @@ +# techquestsdev/.github + +Organization-wide GitHub configuration, community health files, canonical issue labels, and reusable GitHub Actions workflows for [Tech Quests](https://github.com/techquestsdev) repositories. + +Note: `profile/README.md` renders on the public `https://github.com/techquestsdev` organization profile page. This root `README.md` documents how individual repositories inherit or call the shared configuration in this repository. + +## 1. Automatically Inherited Community Health Files + +Any repository under `techquestsdev` automatically inherits the files below **only when that repository does not define its own local copy** in root, `docs/`, or `.github/`: + +| Path in `techquestsdev/.github` | Scope | Notes | +| --- | --- | --- | +| `CODE_OF_CONDUCT.md` | Org-wide | Contributor Covenant 2.1 | +| `CONTRIBUTING.md` | Org-wide | Conventional Commits and PR guidelines | +| `SECURITY.md` | Org-wide | Private vulnerability reporting policy | +| `FUNDING.yml` | Org-wide | Sponsor links | +| `pull_request_template.md` | Org-wide | Generic PR checklist (works for Go, Rust, Tauri, and web repos) | +| `ISSUE_TEMPLATE/bug_report.yml` | Org-wide | Structured bug report form (`bug`, `needs-triage`) | +| `ISSUE_TEMPLATE/feature_request.yml` | Org-wide | Structured feature request form (`enhancement`, `needs-triage`) | +| `ISSUE_TEMPLATE/config.yml` | Org-wide | Disables blank issues and links to Discussions and docs | +| `.github/DISCUSSION_TEMPLATE/q-a.yml` | Org-wide | Q&A discussion category form | +| `.github/DISCUSSION_TEMPLATE/ideas.yml` | Org-wide | Ideas discussion category form | + +### Migrating an existing repo to inherit templates + +GitHub replaces the entire default `ISSUE_TEMPLATE` directory if a repository has *any* file inside its own `.github/ISSUE_TEMPLATE/`. To inherit the shared templates in a `techquestsdev` repository, delete the local duplicates: + +```bash +git rm -rf --ignore-unmatch .github/ISSUE_TEMPLATE .github/DISCUSSION_TEMPLATE .github/pull_request_template.md pull_request_template.md CONTRIBUTING.md CODE_OF_CONDUCT.md SECURITY.md +``` + +## 2. Canonical Labels (`sync-labels.yml`) + +GitHub does not inherit issue labels from `.github` automatically. Canonical labels are defined in `.github/labels.json` (`bug`, `enhancement`, `documentation`, `duplicate`, `good first issue`, `help wanted`, `invalid`, `question`, `wontfix`, `needs-triage`, `dependencies`, `security`, `ci`, `github-actions`, `go`, `rust`). + +### Option A: Sync from here via `workflow_dispatch` + +Run the **Sync Labels** workflow in the Actions tab of `techquestsdev/.github`: +- Set `target` to `techquestsdev/` (or `all` to sync every non-archived repo in the org). +- Configure a `LABELS_TOKEN` secret in `techquestsdev/.github` with `repo` (or fine-grained `Issues: Read and write` + `Metadata: Read`) permissions across the org when targeting other repositories. + +### Option B: Call from an individual repository + +Add `.github/workflows/labels.yml` in the target repo (uses the repo's built-in `GITHUB_TOKEN`, no PAT needed): + +```yaml +name: Sync Labels + +on: + workflow_dispatch: + schedule: + - cron: "0 6 * * 1" + +permissions: + contents: read + issues: write + +jobs: + labels: + uses: techquestsdev/.github/.github/workflows/sync-labels.yml@main +``` + +## 3. Reusable Workflows + +All reusable workflows live under `.github/workflows/` and are versioned on `main`. Public repositories outside `techquestsdev` (for example staging repos before org transfer) can also call them directly via `techquestsdev/.github/.github/workflows/.yml@main`. + +### `go-ci.yml` (Go test, lint, Trivy security scan, 3-OS build) + +Standard Go CI caller (`.github/workflows/ci.yml`): + +```yaml +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + security-events: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + ci: + uses: techquestsdev/.github/.github/workflows/go-ci.yml@main + secrets: inherit +``` + +Optional inputs for repos with build tags or generated-file drift checks (for example `gdash`): + +```yaml + ci: + uses: techquestsdev/.github/.github/workflows/go-ci.yml@main + with: + build-tags: "nodbus" + golangci-args: "--config=.golangci.yml --build-tags=nodbus --timeout=5m" + generate-check-paths: "docs/public/schema.json" + secrets: inherit +``` + +### `go-release.yml` (Conventional-commit auto-semver + GoReleaser) + +Computes the next semantic version across all commits since the latest `v*.*.*` tag (`feat:` -> minor, `fix:`/`perf:` -> patch, `type!:` or `BREAKING CHANGE:` -> major, `[skip release]` or `chore:`/`docs:`/`ci:`-only -> skipped), pushes the annotated tag, runs `go test -race`, and executes GoReleaser v2. + +Caller `.github/workflows/release.yml`: + +```yaml +name: Release + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: write + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +jobs: + release: + uses: techquestsdev/.github/.github/workflows/go-release.yml@main + secrets: + HOMEBREW_TOKEN: ${{ secrets.HOMEBREW_TOKEN }} +``` + +Required repository secret when publishing formulas or casks to `techquestsdev/homebrew-tap`: `HOMEBREW_TOKEN`. + +### `semver-tag.yml` (Language-neutral conventional-commit tagger) + +For non-Go repositories (Rust, Tauri, C, Node) that have their own build/release matrix after tagging: + +```yaml +name: Tag Release + +on: + push: + branches: [main] + +permissions: + contents: write + +jobs: + tag: + uses: techquestsdev/.github/.github/workflows/semver-tag.yml@main + secrets: + RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} +``` + +Note on GitHub Actions loop prevention: if downstream release builds live in a separate workflow triggered by `on: push: tags:`, pass a `RELEASE_TOKEN` PAT or GitHub App token (tags pushed with the default `GITHUB_TOKEN` do not trigger new workflow runs). Otherwise, call your build job in the same workflow with `needs: tag` and `if: needs.tag.outputs.skipped != 'true'`. + +### `dependency-review.yml` (PR vulnerability and license gate) + +Caller `.github/workflows/dependency-review.yml`: + +```yaml +name: Dependency Review + +on: + pull_request: + branches: [main] + +permissions: + contents: read + pull-requests: write + +jobs: + dependency-review: + uses: techquestsdev/.github/.github/workflows/dependency-review.yml@main +``` + +### `docs-pages.yml` (pnpm static docs build and GitHub Pages deploy) + +Caller `.github/workflows/docs.yml`: + +```yaml +name: Docs + +on: + push: + branches: [main] + paths: + - "docs/**" + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + docs: + uses: techquestsdev/.github/.github/workflows/docs-pages.yml@main +``` diff --git a/pull_request_template.md b/pull_request_template.md index f297a9f..214217b 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -32,10 +32,10 @@ Related to #(issue number) ## Testing -- [ ] Existing tests pass (`make test`) +- [ ] Existing tests pass - [ ] New tests added (if applicable) - [ ] Manual testing performed -- [ ] Linter passes (`make lint`) +- [ ] Linter and formatter checks pass ### Test Coverage