diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d0910b1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,27 @@ +# flyctl launch added from .gitignore +**/bin +**/Thumbs.db +**/.DS_Store +**/.gradle +**/build +**/target +**/out +**/.micronaut +**/.idea +**/*.iml +**/*.ipr +**/*.iws +**/.project +**/.settings +**/.classpath +**/.factorypath + +# Added from .idea/.gitignore +# Default ignored files +.idea/shelf +.idea/workspace.xml +# Editor-based HTTP Client requests +.idea/httpRequests +# Datasource local storage ignored files +.idea/dataSources +.idea/dataSources.local.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f6d6629 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*.{kt,kts}] +ktlint_code_style = intellij_idea +indent_size = 4 +indent_style = space + +max_line_length = 120 \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d0be464 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 0000000..f60b2be --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,71 @@ +# +# Configuration for Github App Settings: +# https://github.com/apps/settings +# +--- +repository: + name: project-starter + description: "UFPE / Liber / project-starter" + homepage: "http://www.liber.ufpe.br/project-starter/" + private: true + has_issues: true + has_projects: true + has_wiki: false + default_branch: main + allow_squash_merge: false + allow_merge_commit: true + allow_rebase_merge: true + delete_branch_on_merge: true + enable_automated_security_fixes: true + enable_vulnerability_alerts: true + +labels: + - name: "bug" + description: "Something isn't working" + color: "#D73A4A" + - name: "documentation" + description: "Improvements or additions to documentation" + color: "#0075CA" + - name: "duplicate" + description: "This issue or pull request already exists" + color: "#CFD3D7" + - name: "enhancement" + description: "New feature or request" + color: "#A2EEEF" + - name: "good first issue" + description: "Good for newcomers" + color: "#7057FF" + - name: "help wanted" + description: "Extra attention is needed" + color: "#008672" + - name: "invalid" + description: "This doesn't seem right" + color: "#E4E669" + - name: "question" + description: "Further information is requested" + color: "#D876E3" + - name: "wontfix" + description: "This will not be worked on" + color: "#FFFFFF" + - name: "dependencies" + description: "Pull requests that update a dependency file" + color: "#0366D6" + - name: "github_actions" + description: "Pull requests that update GitHub Actions code" + color: "#000000" + - name: "java" + description: "Pull requests that update Java code" + color: "#FFA221" + +branches: + - name: main + protection: + enforce_admins: true + required_linear_history: true + required_pull_request_reviews: + required_approving_review_count: 1 + dismiss_stale_reviews: false + require_code_owner_reviews: false + required_status_checks: + strict: true + context: ["Build / compile", "Tests / test"] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..646a346 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,115 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +permissions: + contents: read + +jobs: + compile: + name: Build / compile + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Liber-UFPE/spring-gradle-build-action@v1 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Run testCompile + run: ./gradlew compileTestKotlin + + detekt: + name: Code Analysis / detekt + runs-on: ubuntu-latest + needs: + - compile + steps: + - uses: actions/checkout@v4 + - name: detekt report + uses: natiginfo/action-detekt-all@1.23.1 + with: + args: | + --report md:build/reports/detekt/detekt.md + - name: Detekt Summary + run: cat build/reports/detekt/detekt.md >> $GITHUB_STEP_SUMMARY + + ktlint: + name: Code Analysis / ktlint + runs-on: ubuntu-latest + needs: + - compile + steps: + - uses: actions/checkout@v4 + - uses: nbadal/action-ktlint-setup@v1 + - name: ktlint version + run: ktlint --version + - name: run ktlin + run: ktlint --relative >> $GITHUB_STEP_SUMMARY + +# diktat: +# name: Code Analysis / diktat +# runs-on: ubuntu-latest +# needs: +# - compile +# steps: +# - uses: actions/checkout@v4 +# - uses: Liber-UFPE/spring-gradle-build-action@v1 +# - name: Run diktatCheck +# run: ./gradlew diktatCheck mergeDiktatReports + + test: + name: Tests / test + runs-on: ubuntu-latest + needs: + - detekt + - ktlint + # - diktat + steps: + - uses: actions/checkout@v4 + - uses: Liber-UFPE/spring-gradle-build-action@v1 + - name: Run tests + run: ./gradlew test + - name: Coverage HTML Report + run: ./gradlew koverHtmlReport + - name: Setup Pandoc + uses: r-lib/actions/setup-pandoc@v2 + - name: Output Kover summary + # Adapted from https://github.com/Kotlin/kotlinx-kover/issues/419#issuecomment-1632572084 + run: | + pandoc build/reports/kover/html/index.html -f html -t gfm | \ + sed -n '/# project-starter: Overall Coverage Summary/,/<\/div>/p' | \ + grep -v "" >> $GITHUB_STEP_SUMMARY + - name: Test Summary Report + uses: phoenix-actions/test-reporting@v12 + if: always() + with: + name: Kotest Report + path: "build/test-results/test/TEST-*.xml" + reporter: java-junit + output-to: "step-summary" + only-summary: "true" + + build: + name: Package / build + runs-on: ubuntu-latest + needs: + - test + steps: + - uses: actions/checkout@v4 + - uses: Liber-UFPE/spring-gradle-build-action@v1 + - name: Run build + run: ./gradlew build + + build-docker: + name: Package / Docker / build + runs-on: ubuntu-latest + needs: + - test + steps: + - uses: actions/checkout@v4 + - uses: Liber-UFPE/spring-gradle-build-action@v1 + - name: Run dockerBuild + run: ./gradlew dockerBuild diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..2a027ef --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,58 @@ +name: Main + +on: + workflow_run: + workflows: [CI] + branches: [main] + types: + - completed + +jobs: + on-ci-workflow-failure: + name: CI / Failure + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + runs-on: ubuntu-latest + steps: + # `false` makes this step fail, which is what we want + # since no code coverage will be reported. + - run: | + echo 'The triggering workflow failed' && false + + on-ci-workflow-success: + name: CI / Success + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Triggering Workflow Summary + run: | + echo "## CI Build Summary" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Summary for the workflow that triggered this deploy." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY + echo "|:------|:------|" >> $GITHUB_STEP_SUMMARY + echo "| Id | ${{ github.event.workflow_run.id }} |" >> $GITHUB_STEP_SUMMARY + echo "| Title | ${{ github.event.workflow_run.display_title }} |" >> $GITHUB_STEP_SUMMARY + echo "| URL | <${{ github.event.workflow_run.html_url }}> |" >> $GITHUB_STEP_SUMMARY + echo "| Started at | ${{ github.event.workflow_run.created_at }} |" >> $GITHUB_STEP_SUMMARY + echo "| Finished at | ${{ github.event.workflow_run.updated_at }} |" >> $GITHUB_STEP_SUMMARY + echo "| Who | [${{ github.event.workflow_run.actor.login }}](${{ github.event.workflow_run.actor.html_url}}) |" >> $GITHUB_STEP_SUMMARY + + code-coverage: + name: Test / code coverage + runs-on: ubuntu-latest + needs: + - on-ci-workflow-success + steps: + - uses: actions/checkout@v4 + - uses: Liber-UFPE/spring-gradle-build-action@v1 + - name: Run tests + run: ./gradlew test + - name: Coverage XML Report + run: ./gradlew koverXmlReport + - name: Report results to DeepSource + run: | + curl https://deepsource.io/cli | sh + ./bin/deepsource report --analyzer test-coverage --key kotlin --value-file build/reports/kover/report.xml + env: + DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a386cda --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +.gradle +**/build/ +!src/**/build/ + +bin + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Avoid ignore Gradle wrappper properties +!gradle-wrapper.properties + +# Cache of project +.gradletasknamecache + +# Eclipse Gradle plugin generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath +Thum +bs.db +.DS_Store +out/ +.micronaut/ +.idea +*.iml +*.ipr +*.iws +.settings +.factorypath diff --git a/README.md b/README.md new file mode 100644 index 0000000..4afafab --- /dev/null +++ b/README.md @@ -0,0 +1,153 @@ +# Project Starter + +![CI Workflow](https://github.com/Liber-UFPE/project-starter/actions/workflows/build.yml/badge.svg?branch=main) +![Main Workflow](https://github.com/Liber-UFPE/project-starter/actions/workflows/main.yml/badge.svg?branch=main) +![Deploy Workflow](https://github.com/Liber-UFPE/project-starter/actions/workflows/deploy.yml/badge.svg?branch=main) + +This is a project starter template. There are a few things you need to do after creating your repository using this template: + +- [ ] Replace `project-starter` with your project's name +- [ ] Edit `src/main/resources/public/stylesheets/main.css` as needed (different colors, fonts, etc.) +- [ ] Edit `src/main/jte/layout.kte` as necessary to support your project's navigation + +## Adding a new page + +To add a new page, you need to edit a few files: + +### 1. View + +Add a new template such as `src/main/jte/my-new-page.kte` that uses the project layout: + +```html +@template.layout( + title = "Page title", + content = @` + @template.sections.top( + title = "Main top section title", + subtext = @` + Main top section content. It may be just regular HTML. + ` + ) + @template.sections.main( + content = @` +
Secondary section HTML
+