From 8267f5e7d89c81301f174c91f5460db92e366e7b Mon Sep 17 00:00:00 2001 From: "Daniel A. A. Pelsmaeker" Date: Wed, 31 Jul 2024 23:07:08 +0200 Subject: [PATCH] Add GitHub issue template --- .../org/metaborg/repoman/GenerateCommand.kt | 8 ++ .../org/metaborg/repoman/meta/RepoMetadata.kt | 17 +++- .../ISSUE_TEMPLATE/20-report-a-bug.yml.kte | 80 +++++++++++++++++++ .../github/ISSUE_TEMPLATE/config.yml.kte | 22 +++++ 4 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 repoman/src/main/resources/templates/github/ISSUE_TEMPLATE/20-report-a-bug.yml.kte create mode 100644 repoman/src/main/resources/templates/github/ISSUE_TEMPLATE/config.yml.kte diff --git a/repoman/src/main/kotlin/org/metaborg/repoman/GenerateCommand.kt b/repoman/src/main/kotlin/org/metaborg/repoman/GenerateCommand.kt index c6ca570..66e839c 100644 --- a/repoman/src/main/kotlin/org/metaborg/repoman/GenerateCommand.kt +++ b/repoman/src/main/kotlin/org/metaborg/repoman/GenerateCommand.kt @@ -67,6 +67,7 @@ object GenerateCommand: CliktCommand( generator.generateGradleWrapper() generator.generateGradleRootProject() generator.generateGithubWorkflows() + generator.generateGithubIssueTemplates() println("Done!") } @@ -142,6 +143,13 @@ object GenerateCommand: CliktCommand( } } + fun generateGithubIssueTemplates() { + val generate = metadata.files.githubIssueTemplates.generate + val update = metadata.files.githubIssueTemplates.update || forceUpdate + generate("github/ISSUE_TEMPLATE/config.yml", generate, update, path = ".github/ISSUE_TEMPLATE/config.yml") + generate("github/ISSUE_TEMPLATE/20-report-a-bug.yml", generate, update, path = ".github/ISSUE_TEMPLATE/20-report-a-bug.yml") + } + private fun generate(templateName: String, generate: Boolean, update: Boolean, path: String = templateName) { val outputFile = repoDir.resolve(path) val outputFileExisted = outputFile.exists() diff --git a/repoman/src/main/kotlin/org/metaborg/repoman/meta/RepoMetadata.kt b/repoman/src/main/kotlin/org/metaborg/repoman/meta/RepoMetadata.kt index 04b73e8..7efa883 100644 --- a/repoman/src/main/kotlin/org/metaborg/repoman/meta/RepoMetadata.kt +++ b/repoman/src/main/kotlin/org/metaborg/repoman/meta/RepoMetadata.kt @@ -73,6 +73,8 @@ data class Files( val gradleRootProject: GradleRootProject = GradleRootProject(), /** The metadata for the GitHub workflows. */ val githubWorkflows: GithubWorkflows = GithubWorkflows(), + /** The metadata for GitHub issue templates. */ + val githubIssueTemplates: GithubIssueTemplates = GithubIssueTemplates(), ) /** Metadata for the README.md file. */ @@ -186,6 +188,19 @@ data class GithubWorkflows( val buildDocs: Boolean = false, ) +/** Metadata for GitHub issue templates. */ +@Serializable +data class GithubIssueTemplates( + /** Whether to generate the files. */ + val generate: Boolean = true, + /** Whether to update the file. */ + val update: Boolean = true, + /** Whether to automatically assign developers to issues. */ + val assignDevelopers: Boolean = true, + /** Whether to use the GitHub Discussions tab. */ + val useDiscussions: Boolean = true, +) + /** A Maven artifact. */ @Serializable data class MavenArtifact( @@ -209,7 +224,7 @@ data class GradlePlugin( /** A person. */ @Serializable data class Person( - /** The ID of the person, usually their GitHub nickname. */ + /** The GitHub nickname of the person. */ val id: String? = null, /** The (full) name of the person. */ val name: String, diff --git a/repoman/src/main/resources/templates/github/ISSUE_TEMPLATE/20-report-a-bug.yml.kte b/repoman/src/main/resources/templates/github/ISSUE_TEMPLATE/20-report-a-bug.yml.kte new file mode 100644 index 0000000..7ac510c --- /dev/null +++ b/repoman/src/main/resources/templates/github/ISSUE_TEMPLATE/20-report-a-bug.yml.kte @@ -0,0 +1,80 @@ +@import org.metaborg.repoman.meta.RepoMetadata +@param meta: RepoMetadata +--- +@if(meta.files.gradleRootProject.update) +# !! THIS FILE WAS GENERATED USING repoman !! +# Modify `repo.yaml` instead and use `repoman` to update this file +# See: https://github.com/metaborg/metaborg-gradle/ + +@endif +name: "🐞 Report a Bug" +description: File a bug report or issue for any project in ${meta.title}. +title: "[Bug]: " +labels: ["bug", "triage"] +@if(meta.files.githubIssueTemplates.assignDevelopers) +assignees: + @for(person in meta.developers) + - ${person.id} + @endfor +@endif +body: + @if(meta.files.gradleRootProject.includedBuilds.isNotEmpty() || meta.files.gradleRootProject.includedProjects.isNotEmpty()) + - type: dropdown + id: project + attributes: + label: For which project in this repository does the issue occur? + multiple: true + options: + @for(project in meta.files.gradleRootProject.includedProjects) + - "${project.name}" + @endfor + @for(build in meta.files.gradleRootProject.includedBuilds) + - "${build.name}" + @endfor + @else + - type: textarea + attributes: + label: Project + description: For which project in this repository does the issue occur? + validations: + required: false + @endif + - type: textarea + attributes: + label: Version + description: The version of Spoofax or the commit of this project where the issue occurs. + validations: + required: false + - type: textarea + attributes: + label: Describe the issue + description: A clear and concise description of what the bug is. + validations: + required: false + - type: textarea + attributes: + label: Expected Behavior + description: A concise description of what you expected to happen. + validations: + required: false + - type: textarea + attributes: + label: Actual Behavior + description: A concise description of what happened instead. + validations: + required: false + - type: textarea + attributes: + label: Steps To Reproduce + description: Steps to reproduce the behavior. + validations: + required: false + - type: textarea + attributes: + label: Anything else? + description: | + Links? References? Anything that will give us more context about the issue you are encountering! + + Tip: You can attach images, log files, or an example project by clicking this area to highlight it and then dragging files in. + validations: + required: false diff --git a/repoman/src/main/resources/templates/github/ISSUE_TEMPLATE/config.yml.kte b/repoman/src/main/resources/templates/github/ISSUE_TEMPLATE/config.yml.kte new file mode 100644 index 0000000..596d137 --- /dev/null +++ b/repoman/src/main/resources/templates/github/ISSUE_TEMPLATE/config.yml.kte @@ -0,0 +1,22 @@ +@import org.metaborg.repoman.meta.RepoMetadata +@param meta: RepoMetadata +--- +blank_issues_enabled: false +contact_links: + - name: 📚 Spoofax Documentation + url: https://www.spoofax.dev/ + about: Documentation about Spoofax and all included Meta-Languages. + - name: ⁉️ Spoofax Support Page + url: https://www.spoofax.dev/support + about: Information on Spoofax Support, and how to get in touch. + - name: 🙋🏽 Spoofax Users Channel + url: https://slde.slack.com/archives/C7254SF60 + about: The Spoofax Users channel on Slack. See the Spoofax Support Page on how to gain access. + @if(meta.files.githubIssueTemplates.useDiscussions) + - name: 💬 Discussions + url: https://github.com/${meta.repoOwner}/${meta.repoName}/discussions/ + about: Alternatively, ask questions in the Discussions tab. + @endif + - name: 🛡️ Security issue + url: https://github.com/${meta.repoOwner}/${meta.repoName}/security/advisories/new + about: Security issue? Do not report security issues publicly, but create a private advisory.