├── .adr.json ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── new-framework-support.md └── workflows │ └── ci.yaml ├── .gitignore ├── .idea └── icon.png ├── LICENSE ├── README.md ├── ROADMAP.md ├── assets └── codedb.svg ├── build.gradle.kts ├── client ├── client-api │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── org │ │ └── archguard │ │ └── codedb │ │ └── client │ │ └── CodeDBHttpClient.kt ├── codedb-cli │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── org │ │ └── archguard │ │ └── codedb │ │ └── cli │ │ └── Runner.kt ├── codedb-clui │ ├── README.md │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── kotlin │ │ └── org │ │ │ └── archguard │ │ │ └── codedb │ │ │ └── clui │ │ │ ├── CodeDB.kt │ │ │ ├── CodeDBApplication.kt │ │ │ ├── CodeDBApplicationState.kt │ │ │ ├── common │ │ │ ├── AppResources.kt │ │ │ ├── Constants.kt │ │ │ └── Settings.kt │ │ │ ├── util │ │ │ ├── Compose.kt │ │ │ └── Dialogs.kt │ │ │ └── window │ │ │ ├── CodeDBWindow.kt │ │ │ └── CodeDBWindowState.kt │ │ └── resources │ │ └── logback.xml └── codedb-gradle-plugin │ ├── build.gradle.kts │ └── src │ └── main │ └── kotlin │ └── org │ └── archguard │ └── codedb │ └── gradle │ └── CodeDBPlugin.kt ├── codedb-ui ├── .editorconfig ├── .eslintrc.json ├── .gitignore ├── .npmrc ├── .prettierrc.json ├── .storybook │ ├── main.js │ └── preview.js ├── LICENSE ├── README.md ├── craco.config.js ├── lerna.json ├── package-lock.json ├── package.json ├── packages │ └── README.md ├── plugins │ ├── README.md │ └── plugin-chart-echarts │ │ └── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.css │ ├── App.test.tsx │ ├── App.tsx │ ├── assets │ │ └── images │ │ │ └── logo.svg │ ├── chart │ │ ├── BigNumber │ │ │ └── BigNumber.tsx │ │ ├── Echart.tsx │ │ ├── Radar │ │ │ ├── Radar.tsx │ │ │ └── transform-props.ts │ │ ├── VizTypeGallery.tsx │ │ └── chart-data.ts │ ├── components │ │ ├── README.md │ │ ├── business │ │ │ └── README.md │ │ ├── general │ │ │ ├── README.md │ │ │ └── fitness │ │ │ │ └── FitnessFunction.tsx │ │ └── threejs │ │ │ ├── Box.tsx │ │ │ └── Canvas.tsx │ ├── hooks │ │ └── README.md │ ├── i18n │ │ ├── i18n-config.ts │ │ └── locales │ │ │ ├── en.json │ │ │ └── zh-cn.json │ ├── index.css │ ├── index.tsx │ ├── layout │ │ └── DefaultLayout.tsx │ ├── pages │ │ ├── NoMatch.tsx │ │ ├── README.md │ │ ├── alerts │ │ │ └── Alerts.tsx │ │ ├── create │ │ │ └── CreateAlert.tsx │ │ ├── dashboard │ │ │ └── Dashboard.tsx │ │ ├── fitness │ │ │ └── CreateFitness.tsx │ │ └── queries │ │ │ └── Queries.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ ├── setupTests.ts │ ├── stories │ │ ├── Button.stories.tsx │ │ ├── Button.tsx │ │ ├── Header.stories.tsx │ │ ├── Header.tsx │ │ ├── Introduction.stories.mdx │ │ ├── Page.stories.tsx │ │ ├── Page.tsx │ │ ├── assets │ │ │ ├── code-brackets.svg │ │ │ ├── colors.svg │ │ │ ├── comments.svg │ │ │ ├── direction.svg │ │ │ ├── flow.svg │ │ │ ├── plugin.svg │ │ │ ├── repo.svg │ │ │ └── stackalt.svg │ │ ├── button.css │ │ ├── header.css │ │ └── page.css │ ├── style │ │ └── antd │ │ │ └── customTheme.less │ └── theme │ │ └── color.ts └── tsconfig.json ├── core ├── build.gradle.kts ├── gradle.properties └── src │ └── main │ └── kotlin │ └── org │ └── archguard │ └── core │ ├── DefaultProject.kt │ ├── Project.kt │ ├── ProjectContext.kt │ ├── client │ └── CodedbConfig.kt │ ├── internal │ ├── Action.kt │ ├── Element.kt │ └── Factory.kt │ ├── io │ ├── DirectoryWalker.kt │ └── WalkerCollector.kt │ ├── log │ └── StreamConsumer.kt │ ├── task │ └── TaskConfigure.kt │ └── uuid.kt ├── docs ├── adr │ ├── 0001-keep-spring-2.md │ ├── 0002-use-h2-memorydb-for-metric-when-scan.md │ ├── 0003-use-json-schema-for-share-context.md │ ├── 0004-use-yaml-as-task-dsl-configure.md │ ├── 0005-add-config-file-for-cli.md │ ├── 0006-keep-register-metadata-only.md │ └── README.md ├── specs │ ├── .archguard-cli.schema.json │ └── .archguard-task.schema.json └── spike │ ├── README.md │ ├── ai │ ├── README.md │ ├── code-ai.md │ ├── model-architecture.png │ └── swagger-api.md │ ├── api-design │ ├── builtin-function.md │ ├── ops-driven-fitness.md │ └── samples.md │ ├── atom │ ├── license.md │ └── similarity-analyser.md │ ├── dsl │ ├── Kotlin∇.md │ └── task.md │ ├── expression │ ├── README.md │ ├── kotlin-jupyter-library.md │ └── sigmod14.pdf │ ├── gradle │ └── README.md │ ├── images │ └── Extracted-Project-Metrics.png │ ├── math │ ├── Graphic.md │ └── README.md │ ├── metrics │ ├── README.md │ ├── arch-metrics.md │ ├── category.md │ ├── code-metrics.md │ ├── code-overview.md │ ├── coding-rules.md │ ├── common-factor.md │ ├── images │ │ ├── deployment.png │ │ ├── microservices-pattern.png │ │ ├── monitor.png │ │ ├── reaction.png │ │ ├── runtime-verify.png │ │ ├── specification.png │ │ ├── taxonomy-static-code-anlaysis-tools.png │ │ └── trace.png │ └── tools.md │ ├── query │ ├── AstQuery.md │ └── README.md │ ├── related │ └── searchcode.md │ ├── streaming │ └── README.md │ ├── twin │ ├── README.md │ ├── general-digital-framework.png │ ├── lifecycle.png │ └── self-management.png │ ├── visualization │ └── README.md │ └── workflow │ ├── README.md │ ├── Workflow.md │ ├── metamodel-dsl.png │ ├── openwdl.md │ └── patterns.md ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pipeline ├── README.md ├── action-toolkit │ ├── LICENSE │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── org │ │ │ └── archguard │ │ │ └── action │ │ │ ├── core │ │ │ └── Tracing.kt │ │ │ ├── exec │ │ │ ├── Command.kt │ │ │ ├── CommandArgs.kt │ │ │ ├── CommandSetting.kt │ │ │ └── ExecListeners.kt │ │ │ ├── http │ │ │ └── HttpClientWrapper.kt │ │ │ └── io │ │ │ ├── FileExt.kt │ │ │ └── Shell.kt │ │ └── test │ │ └── kotlin │ │ └── org │ │ └── archguard │ │ └── action │ │ └── exec │ │ └── CommandTest.kt ├── checkout │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── org │ │ │ └── archguard │ │ │ └── action │ │ │ └── checkout │ │ │ ├── ExecuteGitCheckout.kt │ │ │ ├── GitCommandManager.kt │ │ │ ├── GitSourceSettings.kt │ │ │ ├── Main.kt │ │ │ └── helper │ │ │ ├── GitAuthHelper.kt │ │ │ ├── RefHelper.kt │ │ │ └── RetryHelper.kt │ │ └── test │ │ └── kotlin │ │ └── org │ │ └── archguard │ │ └── action │ │ └── checkout │ │ ├── GitCommandManagerTest.kt │ │ └── GitSourceSettingsTest.kt ├── coverage │ ├── README.md │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── org │ │ │ └── archguard │ │ │ └── codedb │ │ │ └── coverage │ │ │ ├── CoverageFileCollector.kt │ │ │ ├── CoverageSettings.kt │ │ │ ├── FileSearcher.kt │ │ │ ├── Main.kt │ │ │ └── jacoco │ │ │ ├── BeanToSql.kt │ │ │ ├── JacocoModel.kt │ │ │ └── JacocoService.kt │ │ └── test │ │ ├── kotlin │ │ └── org │ │ │ └── archguard │ │ │ └── codedb │ │ │ └── coverage │ │ │ └── CoverageFileFilterTest.kt │ │ └── resources │ │ └── lcov.info ├── oo-metric │ ├── README.md │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── org │ │ │ └── archguard │ │ │ └── codedb │ │ │ └── metric │ │ │ └── oo │ │ │ ├── Main.kt │ │ │ ├── Metric.kt │ │ │ └── OoMetricSetting.kt │ │ └── test │ │ └── kotlin │ │ └── org │ │ └── archguard │ │ └── codedb │ │ └── metric │ │ └── oo │ │ └── MetricTest.kt └── runner │ ├── .gitignore │ ├── LICENSE │ ├── archguard.yml │ ├── build.gradle.kts │ └── src │ ├── kts │ └── kotlin │ │ └── org │ │ └── archguard │ │ └── runner │ │ └── handler │ │ ├── HandlerFactory.kt │ │ └── KotlinScriptActionHandler.kt │ ├── main │ └── kotlin │ │ └── org │ │ └── archguard │ │ └── runner │ │ ├── Runner.kt │ │ ├── Worker.kt │ │ ├── context │ │ ├── ActionContext.kt │ │ ├── EnvironmentContext.kt │ │ ├── HostContext.kt │ │ └── RunnerContext.kt │ │ ├── handler │ │ ├── CommandActionHandler.kt │ │ ├── CompositeActionHandler.kt │ │ ├── Handler.kt │ │ ├── HandlerFactory.kt │ │ └── ShellScriptActionHandler.kt │ │ ├── pipeline │ │ ├── ActionDefinitionData.kt │ │ ├── ActionEnv.kt │ │ ├── ActionExecutionData.kt │ │ ├── ActionStep.kt │ │ ├── ScalarVariableExt.kt │ │ └── UsesAction.kt │ │ ├── registry │ │ └── ActionRegistry.kt │ │ ├── runner │ │ ├── ActionManager.kt │ │ ├── ActionManifestManager.kt │ │ ├── ActionRunner.kt │ │ ├── JobRunner.kt │ │ ├── RunnerService.kt │ │ └── StepRunner.kt │ │ └── serial │ │ ├── Scalar.kt │ │ └── YamlExt.kt │ └── test │ ├── kotlin │ └── org │ │ └── archguard │ │ └── runner │ │ ├── ActionManagerTest.kt │ │ ├── ActionManifestManagerTest.kt │ │ ├── DownloadInfoTest.kt │ │ ├── handler │ │ └── HandlerFactorTest.kt │ │ ├── pipeline │ │ └── ActionStepTest.kt │ │ └── serial │ │ ├── ScalarSerialTest.kt │ │ └── ScalarTest.kt │ └── resources │ └── pipeline │ ├── basic-script.yml │ ├── basic.yml │ └── serial │ ├── basic-input.yml │ └── basic-output.yml ├── server ├── build.gradle.kts └── src │ ├── main │ ├── kotlin │ │ └── org │ │ │ └── archguard │ │ │ └── codedb │ │ │ ├── automate │ │ │ ├── builtin │ │ │ │ ├── LocTask.kt │ │ │ │ └── StaticTracing.kt │ │ │ └── task │ │ │ │ ├── DefaultTask.kt │ │ │ │ ├── TaskContainer.kt │ │ │ │ ├── TaskRunner.kt │ │ │ │ ├── api │ │ │ │ ├── AbstractTask.kt │ │ │ │ ├── QueryTask.kt │ │ │ │ ├── Task.kt │ │ │ │ └── TaskProvider.kt │ │ │ │ ├── core │ │ │ │ ├── CacheableTask.kt │ │ │ │ ├── Incremental.kt │ │ │ │ ├── Input.kt │ │ │ │ ├── Intermediate.kt │ │ │ │ ├── Output.kt │ │ │ │ ├── TaskAction.kt │ │ │ │ └── factory │ │ │ │ │ ├── DefaultTaskFactory.kt │ │ │ │ │ ├── TaskFactory.kt │ │ │ │ │ └── TaskIdentity.kt │ │ │ │ ├── execution │ │ │ │ ├── DefaultTaskState.kt │ │ │ │ ├── TaskExecuteResult.kt │ │ │ │ ├── TaskExecutionContext.kt │ │ │ │ ├── TaskExecutor.kt │ │ │ │ └── TaskState.kt │ │ │ │ └── reflect │ │ │ │ └── DirectInstantiator.kt │ │ │ ├── computing │ │ │ └── MathExt.kt │ │ │ ├── fitness │ │ │ └── Fitness.kt │ │ │ ├── orchestration │ │ │ ├── Workflow.kt │ │ │ ├── dag │ │ │ │ └── Dag.kt │ │ │ ├── io │ │ │ │ ├── GitHandler.kt │ │ │ │ ├── HandlerType.kt │ │ │ │ ├── HttpMethod.kt │ │ │ │ └── IOHandler.kt │ │ │ └── schedule │ │ │ │ └── CronTime.kt │ │ │ ├── pipeline │ │ │ └── PipelineTask.kt │ │ │ ├── querydsl │ │ │ ├── AstQuery.kt │ │ │ └── DatabaseQuery.kt │ │ │ ├── report │ │ │ └── ConceptReport.kt │ │ │ └── server │ │ │ ├── CodedbApplication.kt │ │ │ ├── MongoConfig.kt │ │ │ ├── code │ │ │ ├── CodeController.kt │ │ │ ├── CodeRepository.kt │ │ │ ├── ContainerRepository.kt │ │ │ ├── domain │ │ │ │ ├── CodeDocument.kt │ │ │ │ └── ContainerService.kt │ │ │ └── dto │ │ │ │ └── ContainerServiceDto.kt │ │ │ └── hello │ │ │ └── HelloController.kt │ └── resources │ │ ├── application-local.properties │ │ └── application.properties │ └── test │ └── kotlin │ └── org │ └── archguard │ └── codedb │ ├── automate │ └── task │ │ ├── TaskContainerTest.kt │ │ └── TaskRunnerTest.kt │ ├── orchestration │ └── WorkflowTest.kt │ ├── querydsl │ └── DatabaseQueryTest.kt │ └── server │ └── CodedbApplicationTests.kt ├── settings.gradle.kts ├── submodules ├── README.md ├── gitignore │ ├── .gitignore │ ├── README.md │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── org │ │ │ └── archguard │ │ │ └── codedb │ │ │ └── gitignore │ │ │ └── FileUtils.kt │ │ └── test │ │ ├── kotlin │ │ └── org │ │ │ └── archguard │ │ │ └── codedb │ │ │ └── gitignore │ │ │ └── FileUtilsTest.kt │ │ └── resources │ │ └── ignore │ │ ├── .ignoretest │ │ └── should_include ├── repl │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── org │ │ │ └── archguard │ │ │ └── codedb │ │ │ └── repl │ │ │ ├── CustomLibraryResolver.kt │ │ │ └── KotlinReplWrapper.kt │ │ └── test │ │ └── kotlin │ │ └── org │ │ └── archguard │ │ └── codedb │ │ └── repl │ │ └── KotlinReplWrapperTest.kt └── walkdir │ ├── .gitignore │ ├── build.gradle.kts │ └── src │ ├── main │ ├── kotlin │ │ └── org │ │ │ └── archguard │ │ │ └── codedb │ │ │ ├── Workdir.kt │ │ │ ├── git │ │ │ └── GitCommand.kt │ │ │ └── walkdir │ │ │ └── GitDirectoryWalker.kt │ └── resources │ │ └── logback.xml │ └── test │ ├── kotlin │ └── org │ │ └── archguard │ │ └── codedb │ │ └── walkdir │ │ └── GitDirectoryWalkerTest.kt │ └── resources │ └── logback.xml └── workflow-lib ├── README.md ├── factor ├── README.md ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── org │ └── archguard │ └── codedb │ └── factor │ ├── Factor.kt │ ├── JpaHelper.kt │ ├── Period.kt │ ├── code │ ├── cloc │ │ └── LanguageSummary.kt │ ├── dependency │ │ └── PackageDependency.kt │ ├── rest │ │ └── ContainerResource.kt │ └── scm │ │ ├── ScmChangeEntry.kt │ │ ├── ScmCommit.kt │ │ ├── ScmPathChangeCount.kt │ │ └── SourceCodeManagement.kt │ ├── devops │ ├── ChangeFailureRate.kt │ ├── DeploymentFrequency.kt │ ├── LeadTimeForChange.kt │ ├── MeanTimeToRestore.kt │ └── Metric.kt │ ├── experience │ ├── developer │ │ └── TimeToFirstCommit.kt │ └── user │ │ ├── Functionality.kt │ │ └── Usability.kt │ ├── governance │ ├── document │ │ ├── ArchitectureDocument.kt │ │ └── Document.kt │ ├── gate │ │ └── QualityGate.kt │ ├── linting │ │ ├── IssuePosition.kt │ │ ├── Linting.kt │ │ └── Rule.kt │ ├── metric │ │ └── MetricDef.kt │ └── smell │ │ └── Smell.kt │ ├── meta │ ├── Level.kt │ ├── Todo.kt │ └── model │ │ └── DeadlineItem.kt │ ├── progress │ ├── CodeReview.kt │ ├── PathToProduction.kt │ └── TechnicalDebt.kt │ ├── quality │ └── Coverage.kt │ └── tracing │ ├── DynamicTracing.kt │ ├── ManualTracing.kt │ ├── StaticTracing.kt │ └── Tracing.kt └── fitness-engine ├── README.md ├── build.gradle.kts └── src ├── main └── kotlin │ └── org │ └── archguard │ └── codedb │ └── fitness │ ├── core │ ├── CalculateEngine.kt │ └── Level.kt │ └── slice │ ├── compliance │ └── Compliance.kt │ ├── deployment │ └── Deployment.kt │ ├── document │ ├── Document.kt │ └── DocumentCode.kt │ ├── operability │ └── Operability.kt │ ├── quality │ └── QualityCode.kt │ ├── security │ ├── Security.kt │ ├── SecurityCode.kt │ ├── SecurityContainer.kt │ └── SecurityLibrary.kt │ └── service │ └── WebService.kt └── test └── kotlin └── org └── archguard └── codedb └── fitness └── FitnessDemoTest.kt /.adr.json: -------------------------------------------------------------------------------- 1 | {"language":"en","path":"docs/adr/","prefix":"","digits":4} -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Env (please complete the following information):** 14 | - OS: [e.g. iOS] 15 | - Env: Docker compose? Local dev? 16 | - Browser [e.g. chrome, safari] 17 | - Version [e.g. 22] 18 | 19 | 20 | **To Reproduce** 21 | Steps to reproduce the behavior: 22 | 1. Go to '...' 23 | 2. Click on '....' 24 | 3. Scroll down to '....' 25 | 4. See error 26 | 27 | **Expected behavior** 28 | A clear and concise description of what you expected to happen. 29 | 30 | **Screenshots** 31 | If applicable, add screenshots to help explain your problem. 32 | 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/new-framework-support.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New framework support 3 | about: new framework support 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Which language would you to support** 11 | xxx 12 | 13 | **Example of this language HTTP API syntax** 14 | xxx 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [ push ] 4 | 5 | jobs: 6 | build: 7 | strategy: 8 | matrix: 9 | os: [ macos-latest, ubuntu-latest ] 10 | runs-on: ${{ matrix.os }} 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: actions/setup-java@v3 15 | with: 16 | distribution: 'zulu' 17 | java-version: '11' 18 | 19 | - name: Setup Gradle 20 | uses: gradle/gradle-build-action@v2 21 | 22 | - name: Execute Gradle build 23 | run: ./gradlew build 24 | 25 | - name: Execute Gradle Coverage 26 | run: ./gradlew check 27 | 28 | # - name: Execute Gradle Coverage 29 | # if: runner.os == 'macOS' 30 | # run: bash <(curl -s https://codecov.io/bash) 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | bin/ 17 | !**/src/main/**/bin/ 18 | !**/src/test/**/bin/ 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | !.idea/icon.png 23 | *.iws 24 | *.iml 25 | *.ipr 26 | out/ 27 | !**/src/main/**/out/ 28 | !**/src/test/**/out/ 29 | 30 | ### NetBeans ### 31 | /nbproject/private/ 32 | /nbbuild/ 33 | /dist/ 34 | /nbdist/ 35 | /.nb-gradle/ 36 | 37 | ### VS Code ### 38 | .vscode/ 39 | docs/spike/papers 40 | dependencies 41 | */.DS_Store 42 | kotlin-js-store/yarn.lock 43 | -------------------------------------------------------------------------------- /.idea/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/.idea/icon.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022~ Archguard.org. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /client/client-api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | alias(libs.plugins.jvm) 4 | alias(libs.plugins.serialization) 5 | } 6 | 7 | dependencies { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /client/client-api/src/main/kotlin/org/archguard/codedb/client/CodeDBHttpClient.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.client 2 | 3 | class CodeDBHttpClient { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /client/codedb-cli/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | application 4 | alias(libs.plugins.jvm) 5 | alias(libs.plugins.serialization) 6 | alias(libs.plugins.shadow) 7 | } 8 | 9 | dependencies { 10 | implementation(libs.clikt) 11 | 12 | // Logging 13 | implementation(libs.logging.slf4j.api) 14 | implementation(libs.logging.logback.classic) 15 | 16 | testImplementation(libs.bundles.test) 17 | } 18 | 19 | application { 20 | mainClass.set("org.archguard.codedb.cli.RunnerKt") 21 | } 22 | 23 | tasks { 24 | shadowJar { 25 | manifest { 26 | attributes(Pair("Main-Class", "org.archguard.scanner.ctl.RunnerKt")) 27 | } 28 | // minimize() 29 | dependencies { 30 | exclude(dependency("org.junit.jupiter:.*:.*")) 31 | exclude(dependency("org.junit:.*:.*")) 32 | exclude(dependency("junit:.*:.*")) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /client/codedb-cli/src/main/kotlin/org/archguard/codedb/cli/Runner.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.cli 2 | 3 | import com.github.ajalt.clikt.core.CliktCommand 4 | 5 | fun main(args: Array) = Runner().main(args) 6 | class Runner : CliktCommand(help = "codedb clui") { 7 | override fun run() { 8 | echo("Hello, World!") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /client/codedb-clui/README.md: -------------------------------------------------------------------------------- 1 | # CLUI 2 | 3 | tech stack: JetBrains Compose, Mosaic 4 | 5 | - [ ] REPL with CodeDB API 6 | - [ ] DSL integration 7 | - [ ] History API 8 | 9 | example: `codedb run --repl System101.kt` 10 | 11 | refs: https://blog.replit.com/clui 12 | 13 | 1. Approachability 14 | 2. Discoverability 15 | 3. Interactivity 16 | 17 | ## Frameworks 18 | 19 | - [Compose](https://github.com/JetBrains/compose-jb) - Compose Kotlin UI framework port for desktop platforms (macOS, Linux, Windows) and Web, components outside the core Compose repository. 20 | 21 | - Compose for Web 22 | 23 | ## Refs: 24 | 25 | - [Mosaic](https://github.com/JakeWharton/mosaic), An experimental tool for building console UI in Kotlin using the Jetpack Compose compiler/runtime. 26 | - [Ink](https://github.com/vadimdemedes/ink), provides the same component-based UI building experience that React offers in the browser, but for command-line apps. -------------------------------------------------------------------------------- /client/codedb-clui/src/main/kotlin/org/archguard/codedb/clui/CodeDB.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.clui 2 | 3 | import androidx.compose.runtime.CompositionLocalProvider 4 | import androidx.compose.ui.window.application 5 | import org.archguard.codedb.clui.common.LocalAppResources 6 | import org.archguard.codedb.clui.common.rememberAppResources 7 | 8 | fun main() = application { 9 | CompositionLocalProvider(LocalAppResources provides rememberAppResources()) { 10 | CodeDBApplication(rememberApplicationState()) 11 | } 12 | } -------------------------------------------------------------------------------- /client/codedb-clui/src/main/kotlin/org/archguard/codedb/clui/CodeDBApplication.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.clui 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.compose.runtime.key 5 | import androidx.compose.runtime.rememberCoroutineScope 6 | import androidx.compose.ui.window.ApplicationScope 7 | import androidx.compose.ui.window.MenuScope 8 | import androidx.compose.ui.window.Tray 9 | import org.archguard.codedb.clui.common.LocalAppResources 10 | import kotlinx.coroutines.launch 11 | import org.archguard.codedb.clui.common.Constants 12 | import org.archguard.codedb.clui.window.CodeDBWindow 13 | 14 | @Composable 15 | fun ApplicationScope.CodeDBApplication(state: CodeDBApplicationState) { 16 | if (state.settings.isTrayEnabled && state.windows.isNotEmpty()) { 17 | ApplicationTray(state) 18 | } 19 | 20 | for (window in state.windows) { 21 | key(window) { 22 | CodeDBWindow(window) 23 | } 24 | } 25 | } 26 | 27 | @Composable 28 | private fun ApplicationScope.ApplicationTray(state: CodeDBApplicationState) { 29 | Tray( 30 | LocalAppResources.current.icon, 31 | state = state.tray, 32 | tooltip = Constants.APP_NAME, 33 | menu = { ApplicationMenu(state) } 34 | ) 35 | } 36 | 37 | @Composable 38 | private fun MenuScope.ApplicationMenu(state: CodeDBApplicationState) { 39 | val scope = rememberCoroutineScope() 40 | fun exit() = scope.launch { state.exit() } 41 | 42 | Item("New", onClick = state::newWindow) 43 | Separator() 44 | Item("Exit", onClick = { exit() }) 45 | } -------------------------------------------------------------------------------- /client/codedb-clui/src/main/kotlin/org/archguard/codedb/clui/CodeDBApplicationState.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.clui 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.compose.runtime.mutableStateListOf 5 | import androidx.compose.runtime.remember 6 | import androidx.compose.ui.window.Notification 7 | import androidx.compose.ui.window.TrayState 8 | import org.archguard.codedb.clui.common.Settings 9 | import org.archguard.codedb.clui.window.CodeDBWindowState 10 | 11 | @Composable 12 | fun rememberApplicationState() = remember { 13 | CodeDBApplicationState().apply { 14 | newWindow() 15 | } 16 | } 17 | 18 | class CodeDBApplicationState { 19 | val settings = Settings() 20 | val tray = TrayState() 21 | 22 | private val _windows = mutableStateListOf() 23 | val windows: List get() = _windows 24 | 25 | fun newWindow() { 26 | _windows.add( 27 | CodeDBWindowState( 28 | application = this, 29 | path = null, 30 | exit = _windows::remove 31 | ) 32 | ) 33 | } 34 | 35 | fun sendNotification(notification: Notification) { 36 | tray.sendNotification(notification) 37 | } 38 | 39 | suspend fun exit() { 40 | val windowsCopy = windows.reversed() 41 | for (window in windowsCopy) { 42 | if (!window.exit()) { 43 | break 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /client/codedb-clui/src/main/kotlin/org/archguard/codedb/clui/common/Constants.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.clui.common 2 | 3 | class Constants { 4 | companion object { 5 | const val APP_NAME = "CodeDB" 6 | } 7 | } -------------------------------------------------------------------------------- /client/codedb-clui/src/main/kotlin/org/archguard/codedb/clui/common/Settings.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.clui.common 2 | 3 | import androidx.compose.runtime.getValue 4 | import androidx.compose.runtime.mutableStateOf 5 | import androidx.compose.runtime.setValue 6 | 7 | class Settings { 8 | var isTrayEnabled by mutableStateOf(true) 9 | private set 10 | 11 | fun toggleTray() { 12 | isTrayEnabled = !isTrayEnabled 13 | } 14 | } -------------------------------------------------------------------------------- /client/codedb-clui/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | UTF-8 5 | 6 | [SCANNER] %logger{36} %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /client/codedb-gradle-plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | repositories { 2 | gradlePluginPortal() 3 | mavenCentral() 4 | } 5 | 6 | @Suppress("DSL_SCOPE_VIOLATION") 7 | plugins { 8 | alias(libs.plugins.jvm) 9 | alias(libs.plugins.serialization) 10 | `java-gradle-plugin` 11 | } 12 | 13 | dependencies { 14 | implementation(gradleApi()) 15 | } 16 | 17 | java { 18 | sourceCompatibility = JavaVersion.VERSION_1_8 19 | targetCompatibility = JavaVersion.VERSION_1_8 20 | } 21 | -------------------------------------------------------------------------------- /client/codedb-gradle-plugin/src/main/kotlin/org/archguard/codedb/gradle/CodeDBPlugin.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.gradle 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | 6 | const val EXTENSION_NAME = "codedb" 7 | 8 | abstract class CodeDBPlugin : Plugin { 9 | override fun apply(project: Project) { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /codedb-ui/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # Matches multiple files with brace expansion notation 12 | # Set default charset 13 | [*.{js, py, ts, tsx, html, css, scss, json}] 14 | charset = utf-8 15 | indent_style = space 16 | indent_size = 2 17 | 18 | # 4 space indentation 19 | [*.py] 20 | indent_style = space 21 | indent_size = 4 22 | 23 | # Tab indentation (no size specified) 24 | [Makefile] 25 | indent_style = tab 26 | 27 | # Matches the exact files either package.json or .travis.yml 28 | [{package.json,.travis.yml}] 29 | indent_style = space 30 | indent_size = 2 31 | 32 | -------------------------------------------------------------------------------- /codedb-ui/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["react-app", "react-app/jest"], 3 | "plugins": ["prettier"], 4 | "rules": { 5 | "prettier/prettier": [ 6 | "error", 7 | { 8 | "endOfLine": "lf" 9 | } 10 | ], 11 | "@typescript-eslint/no-unused-vars": ["error"], 12 | "jsx-quotes": [1, "prefer-single"], 13 | "no-class-assign": "error", 14 | "no-dupe-keys": "error", 15 | "no-dupe-args": "error", 16 | "no-duplicate-case": "error", 17 | "no-fallthrough": "error", 18 | "no-func-assign": "error", 19 | "no-multi-spaces": "warn", 20 | "no-var": "error", 21 | "eqeqeq": [2, "allow-null"], 22 | "quotes": [1, "single"], 23 | "no-unreachable": "error", 24 | "no-multiple-empty-lines": [ 25 | 2, 26 | { 27 | "max": 2 28 | } 29 | ], 30 | "camelcase": "warn", 31 | "react/jsx-key": 2, 32 | "react/jsx-max-props-per-line": 0, 33 | "space-infix-ops": "error" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /codedb-ui/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /codedb-ui/.npmrc: -------------------------------------------------------------------------------- 1 | legacy-peer-deps=true 2 | -------------------------------------------------------------------------------- /codedb-ui/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "tabWidth": 2, 4 | "semi": false, 5 | "singleQuote": true, 6 | "jsxSingleQuote": true, 7 | "endOfLine": "lf", 8 | "printWidth": 120, 9 | "bracketSpacing": true, 10 | "arrowParens": "always", 11 | "useTabs": false 12 | } 13 | -------------------------------------------------------------------------------- /codedb-ui/.storybook/main.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], 3 | addons: [ 4 | '@storybook/addon-links', 5 | '@storybook/addon-essentials', 6 | '@storybook/addon-interactions', 7 | '@storybook/preset-create-react-app' 8 | ], 9 | framework: '@storybook/react', 10 | core: { 11 | builder: '@storybook/builder-webpack5' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /codedb-ui/.storybook/preview.js: -------------------------------------------------------------------------------- 1 | export const parameters = { 2 | actions: { argTypesRegex: '^on[A-Z].*' }, 3 | controls: { 4 | matchers: { 5 | color: /(background|color)$/i, 6 | date: /Date$/ 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /codedb-ui/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 ~ ArchGuard Org. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /codedb-ui/craco.config.js: -------------------------------------------------------------------------------- 1 | const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') 2 | const WebpackBar = require('webpackbar') 3 | 4 | const CracoAntDesignPlugin = require('craco-antd') 5 | const path = require('path') 6 | 7 | // Don't open the browser during development 8 | process.env.BROWSER = 'none' 9 | 10 | module.exports = { 11 | webpack: { 12 | alias: { 13 | 'antd/lib/theme': false 14 | }, 15 | plugins: [ 16 | new WebpackBar({ profile: true }), 17 | ...(process.env.NODE_ENV === 'development' ? [new BundleAnalyzerPlugin({ openAnalyzer: false })] : []) 18 | ] 19 | }, 20 | plugins: [ 21 | { 22 | plugin: CracoAntDesignPlugin, 23 | options: { 24 | customizeThemeLessPath: path.join(__dirname, 'src/style/antd/customTheme.less'), 25 | babelPluginImportOptions: { 26 | libraryName: 'antd', 27 | libraryDirectory: 'es', 28 | style: true 29 | } 30 | } 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /codedb-ui/lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "node_modules/lerna/schemas/lerna-schema.json", 3 | "useNx": true, 4 | "useWorkspaces": true, 5 | "version": "0.1.1", 6 | "packages": ["packages/*", "plugins/*"], 7 | "command": { 8 | "publish": { 9 | "message": "chore(superset-ui): publish %s", 10 | "graphType": "all" 11 | }, 12 | "version": { 13 | "message": "chore(superset-ui): publish %s", 14 | "exact": true 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codedb-ui/packages/README.md: -------------------------------------------------------------------------------- 1 | # Packages 2 | 3 | This directory contains the packages that are used by the project. 4 | -------------------------------------------------------------------------------- /codedb-ui/plugins/README.md: -------------------------------------------------------------------------------- 1 | # Graph Plugins 2 | 3 | - Tables: https://github.com/TanStack/table 4 | - Markdown: react-markdown 5 | - rehype-raw: https://github.com/rehypejs/rehype-raw 6 | - Math Expression 7 | - math-expression-evaluator 8 | -------------------------------------------------------------------------------- /codedb-ui/plugins/plugin-chart-echarts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codedb/plugin-chart-echarts", 3 | "version": "0.1.1", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "MIT" 11 | } 12 | -------------------------------------------------------------------------------- /codedb-ui/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/codedb-ui/public/favicon.ico -------------------------------------------------------------------------------- /codedb-ui/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/codedb-ui/public/logo192.png -------------------------------------------------------------------------------- /codedb-ui/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/codedb-ui/public/logo512.png -------------------------------------------------------------------------------- /codedb-ui/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /codedb-ui/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /codedb-ui/src/App.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/codedb-ui/src/App.css -------------------------------------------------------------------------------- /codedb-ui/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactThreeTestRenderer from '@react-three/test-renderer' 3 | import { Box } from './components/threejs/Box' 4 | 5 | test('mesh to have two children', async () => { 6 | const renderer = await ReactThreeTestRenderer.create() 7 | 8 | const mesh = renderer.scene.children[0].allChildren 9 | expect(mesh.length).toBe(2) 10 | }) 11 | -------------------------------------------------------------------------------- /codedb-ui/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { Route, Routes } from 'react-router-dom' 3 | import { ConfigProvider } from 'antd' 4 | import { Helmet } from 'react-helmet' 5 | 6 | import './App.css' 7 | import DefaultLayout from './layout/DefaultLayout' 8 | import { NoMatch } from './pages/NoMatch' 9 | import { Dashboard } from './pages/dashboard/Dashboard' 10 | import { color } from './theme/color' 11 | import 'antd/dist/reset.css' 12 | import Alerts from './pages/alerts/Alerts' 13 | import Queries from './pages/queries/Queries' 14 | import { useTranslation } from 'react-i18next' 15 | import './i18n/i18n-config' 16 | 17 | function App() { 18 | const { t } = useTranslation() 19 | 20 | return ( 21 | 22 |
23 | 24 | 25 | {t('title')} 26 | 27 | 28 | }> 29 | } /> 30 | } /> 31 | } /> 32 | } /> 33 | 34 | 35 |
36 |
37 | ) 38 | } 39 | 40 | export default App 41 | -------------------------------------------------------------------------------- /codedb-ui/src/chart/BigNumber/BigNumber.tsx: -------------------------------------------------------------------------------- 1 | export default function BigNumber() {} 2 | -------------------------------------------------------------------------------- /codedb-ui/src/chart/Echart.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react' 2 | import { EChartOption, ECharts, init } from 'echarts' 3 | 4 | interface EchartProps { 5 | width: number 6 | 7 | height: number 8 | /** 9 | * the echart option 10 | */ 11 | option: EChartOption 12 | 13 | ref: React.Ref<{ instance: () => ECharts | undefined }> 14 | } 15 | 16 | function Echart(props: EchartProps) { 17 | const { width, height } = props 18 | 19 | const elemRef = useRef(null) 20 | const echartRef = useRef() 21 | 22 | useEffect(() => { 23 | if (!elemRef.current) { 24 | return 25 | } 26 | 27 | if (!echartRef.current) { 28 | echartRef.current = init(elemRef.current!) 29 | } 30 | 31 | echartRef.current.setOption(props.option, true) 32 | }) 33 | 34 | useImperativeHandle(props.ref, () => ({ 35 | instance() { 36 | return echartRef.current 37 | } 38 | })) 39 | 40 | const onResize = useCallback((width: number, height: number) => { 41 | if (echartRef.current) { 42 | echartRef.current.resize({ width, height }) 43 | } 44 | }, []) 45 | 46 | useLayoutEffect(() => { 47 | onResize(width, height) 48 | }, [width, height, onResize]) 49 | 50 | return
51 | } 52 | 53 | export default forwardRef(Echart) 54 | -------------------------------------------------------------------------------- /codedb-ui/src/chart/Radar/Radar.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Echart from '../Echart' 3 | import { RadarOptions, transformProps } from './transform-props' 4 | 5 | interface RadarProps { 6 | option: RadarOptions 7 | } 8 | 9 | export default function Radar(props: RadarProps) { 10 | return 11 | } 12 | -------------------------------------------------------------------------------- /codedb-ui/src/chart/Radar/transform-props.ts: -------------------------------------------------------------------------------- 1 | import { EChartOption } from 'echarts' 2 | 3 | /** 4 | * 5 | */ 6 | export interface RadarOptions {} 7 | 8 | export function transformProps(radarOptions: RadarOptions): EChartOption { 9 | let radarOption = { 10 | title: { 11 | text: 'Radar' 12 | }, 13 | legend: { 14 | data: ['Allocated Budget', 'Actual Spending'] 15 | }, 16 | radar: { 17 | // shape: 'circle', 18 | indicator: [ 19 | { name: 'Sales', max: 6500 }, 20 | { name: 'Administration', max: 16000 }, 21 | { name: 'Information Technology', max: 30000 }, 22 | { name: 'Customer Support', max: 38000 }, 23 | { name: 'Development', max: 52000 }, 24 | { name: 'Marketing', max: 25000 } 25 | ] 26 | }, 27 | series: [ 28 | { 29 | name: 'Budget vs spending', 30 | type: 'radar', 31 | data: [ 32 | { 33 | value: [4200, 3000, 20000, 35000, 50000, 18000], 34 | name: 'Allocated Budget' 35 | }, 36 | { 37 | value: [5000, 14000, 28000, 26000, 42000, 21000], 38 | name: 'Actual Spending' 39 | } 40 | ] 41 | } 42 | ] 43 | } 44 | 45 | return radarOption 46 | } 47 | -------------------------------------------------------------------------------- /codedb-ui/src/chart/VizTypeGallery.tsx: -------------------------------------------------------------------------------- 1 | export default function VizTypeGallery() { 2 | return
3 | } 4 | -------------------------------------------------------------------------------- /codedb-ui/src/chart/chart-data.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Chart data is a wrapper around the data that is passed to the chart. 3 | * Receive JSON data and convert to different formats, for example: Radar, Line, Bar, etc. 4 | */ 5 | export interface ChartData { 6 | // the Visualization type 7 | viz_type: string 8 | } 9 | -------------------------------------------------------------------------------- /codedb-ui/src/components/README.md: -------------------------------------------------------------------------------- 1 | # Components 2 | 3 | - business, for related to project 4 | - general, for general components 5 | - layout, for layout components 6 | - pages, for pages components 7 | -------------------------------------------------------------------------------- /codedb-ui/src/components/business/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/codedb-ui/src/components/business/README.md -------------------------------------------------------------------------------- /codedb-ui/src/components/general/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/codedb-ui/src/components/general/README.md -------------------------------------------------------------------------------- /codedb-ui/src/components/general/fitness/FitnessFunction.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | function FitnessFunction(props: any) { 4 | return
5 | } 6 | 7 | export default FitnessFunction 8 | -------------------------------------------------------------------------------- /codedb-ui/src/components/threejs/Box.tsx: -------------------------------------------------------------------------------- 1 | import React, { useRef, useState } from 'react' 2 | import { useFrame } from '@react-three/fiber' 3 | 4 | export function Box(props: any) { 5 | // This reference gives us direct access to the THREE.Mesh object 6 | const ref = useRef() 7 | // Hold state for hovered and clicked events 8 | const [hovered, hover] = useState(false) 9 | const [clicked, click] = useState(false) 10 | // @ts-ignore 11 | useFrame((state, delta) => (ref.current.rotation.x += delta)) 12 | // Return the view, these are regular Threejs elements expressed in JSX 13 | return ( 14 | click(!clicked)} 19 | onPointerOver={(event) => hover(true)} 20 | onPointerOut={(event) => hover(false)} 21 | > 22 | 23 | 24 | 25 | ) 26 | } 27 | -------------------------------------------------------------------------------- /codedb-ui/src/components/threejs/Canvas.tsx: -------------------------------------------------------------------------------- 1 | import { Canvas } from '@react-three/fiber' 2 | import { Flex } from '@react-three/flex' 3 | import { Box } from './Box' 4 | import React from 'react' 5 | 6 | function CanvasDemo() { 7 | return ( 8 | // follow https://github.com/pmndrs/react-three-fiber/issues/248 setup pollyfill 9 | // 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ) 21 | } 22 | 23 | export default CanvasDemo 24 | -------------------------------------------------------------------------------- /codedb-ui/src/hooks/README.md: -------------------------------------------------------------------------------- 1 | # Components 2 | -------------------------------------------------------------------------------- /codedb-ui/src/i18n/i18n-config.ts: -------------------------------------------------------------------------------- 1 | import i18next from 'i18next' 2 | import { initReactI18next } from 'react-i18next' 3 | import LanguageDetector from 'i18next-browser-languagedetector' 4 | 5 | import en from './locales/en.json' 6 | import zhCn from './locales/zh-cn.json' 7 | 8 | export const resources = { 9 | en: { 10 | translation: en 11 | }, 12 | zh: { 13 | translation: zhCn 14 | } 15 | } 16 | 17 | i18next 18 | .use(LanguageDetector) 19 | .use(initReactI18next) 20 | .init({ 21 | lng: 'zh', 22 | debug: true, 23 | resources, 24 | // fallbackLng: 'en', 25 | react: { 26 | useSuspense: false 27 | }, 28 | detection: { 29 | order: ['querystring', 'navigator', 'localStorage'], 30 | lookupQuerystring: 'lang' 31 | }, 32 | interpolation: { 33 | escapeValue: false 34 | } 35 | }) 36 | -------------------------------------------------------------------------------- /codedb-ui/src/i18n/locales/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "FitFlow - Fit your software in flow", 3 | "fitness": "Fitness", 4 | "dashboard": "Dashboard", 5 | "alerts": "Alerts", 6 | "queries": "Queries", 7 | "analysis": "Analysis", 8 | "create": "Create" 9 | } 10 | -------------------------------------------------------------------------------- /codedb-ui/src/i18n/locales/zh-cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "FitFlow - 让软件合身于设计", 3 | "fitness": "适应度(联合计算)", 4 | "dashboard": "Dashboard", 5 | "alerts": "预警", 6 | "queries": "查询", 7 | "analysis": "扫描分析", 8 | "create": "创建" 9 | } 10 | -------------------------------------------------------------------------------- /codedb-ui/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 4 | 'Droid Sans', 'Helvetica Neue', sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; 11 | } 12 | -------------------------------------------------------------------------------- /codedb-ui/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import './index.css' 4 | import App from './App' 5 | import reportWebVitals from './reportWebVitals' 6 | import { BrowserRouter } from 'react-router-dom' 7 | 8 | const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement) 9 | root.render( 10 | 11 | 12 | 13 | 14 | 15 | ) 16 | 17 | // If you want to start measuring performance in your app, pass a function 18 | // to log results (for example: reportWebVitals(console.log)) 19 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 20 | reportWebVitals() 21 | -------------------------------------------------------------------------------- /codedb-ui/src/pages/NoMatch.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from 'react-router-dom' 2 | import React from 'react' 3 | 4 | export function NoMatch() { 5 | return ( 6 |
7 |

Nothing to see here!

8 |

9 | Go to the home page 10 |

11 |
12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /codedb-ui/src/pages/README.md: -------------------------------------------------------------------------------- 1 | # Pages/Scenes 2 | -------------------------------------------------------------------------------- /codedb-ui/src/pages/alerts/Alerts.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export interface AlertProps {} 4 | 5 | function Alerts(props: AlertProps) { 6 | return ( 7 |
8 |

Alerts

9 |
10 | ) 11 | } 12 | 13 | export default Alerts 14 | -------------------------------------------------------------------------------- /codedb-ui/src/pages/create/CreateAlert.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export interface CreateAlertProps {} 4 | 5 | function CreateAlert(props: CreateAlertProps) { 6 | return ( 7 |
8 |

Create Alert

9 |
10 | ) 11 | } 12 | 13 | export default CreateAlert 14 | -------------------------------------------------------------------------------- /codedb-ui/src/pages/dashboard/Dashboard.tsx: -------------------------------------------------------------------------------- 1 | import { Card, Col, Row } from 'antd' 2 | import React from 'react' 3 | import Radar from '../../chart/Radar/Radar' 4 | 5 | export function Dashboard() { 6 | return ( 7 | <> 8 |
9 | 10 | {/*for loop in here */} 11 | 12 | Title 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | LineChart 23 | 24 | 25 |
26 | 27 | ) 28 | } 29 | -------------------------------------------------------------------------------- /codedb-ui/src/pages/fitness/CreateFitness.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | function CreateFitness(props: any) { 4 | return
5 | } 6 | 7 | export default CreateFitness 8 | -------------------------------------------------------------------------------- /codedb-ui/src/pages/queries/Queries.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { tableFromArrays } from 'apache-arrow/table' 3 | 4 | export interface QueriesProps {} 5 | 6 | function Queries(props: QueriesProps) { 7 | const LENGTH = 2000 8 | 9 | const rainAmounts = Float32Array.from({ length: LENGTH }, () => Number((Math.random() * 20).toFixed(1))) 10 | 11 | const rainDates = Array.from({ length: LENGTH }, (_, i) => new Date(Date.now() - 1000 * 60 * 60 * 24 * i)) 12 | 13 | const rainfall = tableFromArrays({ 14 | precipitation: rainAmounts, 15 | date: rainDates 16 | }) 17 | 18 | console.table(rainfall) 19 | 20 | return ( 21 |
22 |

Queries

23 |
24 | ) 25 | } 26 | 27 | export default Queries 28 | -------------------------------------------------------------------------------- /codedb-ui/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /codedb-ui/src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals' 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry) 7 | getFID(onPerfEntry) 8 | getFCP(onPerfEntry) 9 | getLCP(onPerfEntry) 10 | getTTFB(onPerfEntry) 11 | }) 12 | } 13 | } 14 | 15 | export default reportWebVitals 16 | -------------------------------------------------------------------------------- /codedb-ui/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom' 6 | 7 | ;(global as any).IS_REACT_ACT_ENVIRONMENT = true 8 | -------------------------------------------------------------------------------- /codedb-ui/src/stories/Button.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { ComponentStory, ComponentMeta } from '@storybook/react' 3 | 4 | import { Button } from './Button' 5 | 6 | // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export 7 | export default { 8 | title: 'Example/Button', 9 | component: Button, 10 | // More on argTypes: https://storybook.js.org/docs/react/api/argtypes 11 | argTypes: { 12 | backgroundColor: { control: 'color' } 13 | } 14 | } as ComponentMeta 15 | 16 | // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args 17 | const Template: ComponentStory = (args) => 41 | ) 42 | } 43 | -------------------------------------------------------------------------------- /codedb-ui/src/stories/Header.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { ComponentStory, ComponentMeta } from '@storybook/react' 3 | 4 | import { Header } from './Header' 5 | 6 | export default { 7 | title: 'Example/Header', 8 | component: Header, 9 | parameters: { 10 | // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout 11 | layout: 'fullscreen' 12 | } 13 | } as ComponentMeta 14 | 15 | const Template: ComponentStory = (args) =>
16 | 17 | export const LoggedIn = Template.bind({}) 18 | LoggedIn.args = { 19 | user: { 20 | name: 'Jane Doe' 21 | } 22 | } 23 | 24 | export const LoggedOut = Template.bind({}) 25 | LoggedOut.args = {} 26 | -------------------------------------------------------------------------------- /codedb-ui/src/stories/Header.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | import { Button } from './Button' 4 | import './header.css' 5 | 6 | type User = { 7 | name: string 8 | } 9 | 10 | interface HeaderProps { 11 | user?: User 12 | onLogin: () => void 13 | onLogout: () => void 14 | onCreateAccount: () => void 15 | } 16 | 17 | export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => ( 18 |
19 |
20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |

Acme

29 |
30 |
31 | {user ? ( 32 | <> 33 | 34 | Welcome, {user.name}! 35 | 36 |
45 |
46 |
47 | ) 48 | -------------------------------------------------------------------------------- /codedb-ui/src/stories/Page.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { ComponentStory, ComponentMeta } from '@storybook/react' 3 | import { within, userEvent } from '@storybook/testing-library' 4 | import { Page } from './Page' 5 | 6 | export default { 7 | title: 'Example/Page', 8 | component: Page, 9 | parameters: { 10 | // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout 11 | layout: 'fullscreen' 12 | } 13 | } as ComponentMeta 14 | 15 | const Template: ComponentStory = (args) => 16 | 17 | export const LoggedOut = Template.bind({}) 18 | 19 | export const LoggedIn = Template.bind({}) 20 | 21 | // More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing 22 | LoggedIn.play = async ({ canvasElement }) => { 23 | const canvas = within(canvasElement) 24 | const loginButton = await canvas.getByRole('button', { name: /Log in/i }) 25 | await userEvent.click(loginButton) 26 | } 27 | -------------------------------------------------------------------------------- /codedb-ui/src/stories/assets/code-brackets.svg: -------------------------------------------------------------------------------- 1 | illustration/code-brackets -------------------------------------------------------------------------------- /codedb-ui/src/stories/assets/comments.svg: -------------------------------------------------------------------------------- 1 | illustration/comments -------------------------------------------------------------------------------- /codedb-ui/src/stories/assets/direction.svg: -------------------------------------------------------------------------------- 1 | illustration/direction -------------------------------------------------------------------------------- /codedb-ui/src/stories/assets/flow.svg: -------------------------------------------------------------------------------- 1 | illustration/flow -------------------------------------------------------------------------------- /codedb-ui/src/stories/button.css: -------------------------------------------------------------------------------- 1 | .storybook-button { 2 | font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; 3 | font-weight: 700; 4 | border: 0; 5 | border-radius: 3em; 6 | cursor: pointer; 7 | display: inline-block; 8 | line-height: 1; 9 | } 10 | .storybook-button--primary { 11 | color: white; 12 | background-color: #1ea7fd; 13 | } 14 | .storybook-button--secondary { 15 | color: #333; 16 | background-color: transparent; 17 | box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset; 18 | } 19 | .storybook-button--small { 20 | font-size: 12px; 21 | padding: 10px 16px; 22 | } 23 | .storybook-button--medium { 24 | font-size: 14px; 25 | padding: 11px 20px; 26 | } 27 | .storybook-button--large { 28 | font-size: 16px; 29 | padding: 12px 24px; 30 | } 31 | -------------------------------------------------------------------------------- /codedb-ui/src/stories/header.css: -------------------------------------------------------------------------------- 1 | .wrapper { 2 | font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; 3 | border-bottom: 1px solid rgba(0, 0, 0, 0.1); 4 | padding: 15px 20px; 5 | display: flex; 6 | align-items: center; 7 | justify-content: space-between; 8 | } 9 | 10 | svg { 11 | display: inline-block; 12 | vertical-align: top; 13 | } 14 | 15 | h1 { 16 | font-weight: 900; 17 | font-size: 20px; 18 | line-height: 1; 19 | margin: 6px 0 6px 10px; 20 | display: inline-block; 21 | vertical-align: top; 22 | } 23 | 24 | button + button { 25 | margin-left: 10px; 26 | } 27 | 28 | .welcome { 29 | color: #333; 30 | font-size: 14px; 31 | margin-right: 10px; 32 | } 33 | -------------------------------------------------------------------------------- /codedb-ui/src/stories/page.css: -------------------------------------------------------------------------------- 1 | section { 2 | font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; 3 | font-size: 14px; 4 | line-height: 24px; 5 | padding: 48px 20px; 6 | margin: 0 auto; 7 | max-width: 600px; 8 | color: #333; 9 | } 10 | 11 | section h2 { 12 | font-weight: 900; 13 | font-size: 32px; 14 | line-height: 1; 15 | margin: 0 0 4px; 16 | display: inline-block; 17 | vertical-align: top; 18 | } 19 | 20 | section p { 21 | margin: 1em 0; 22 | } 23 | 24 | section a { 25 | text-decoration: none; 26 | color: #1ea7fd; 27 | } 28 | 29 | section ul { 30 | padding-left: 30px; 31 | margin: 1em 0; 32 | } 33 | 34 | section li { 35 | margin-bottom: 8px; 36 | } 37 | 38 | section .tip { 39 | display: inline-block; 40 | border-radius: 1em; 41 | font-size: 11px; 42 | line-height: 12px; 43 | font-weight: 700; 44 | background: #e7fdd8; 45 | color: #66bf3c; 46 | padding: 4px 12px; 47 | margin-right: 10px; 48 | vertical-align: top; 49 | } 50 | 51 | section .tip-wrapper { 52 | font-size: 13px; 53 | line-height: 20px; 54 | margin-top: 40px; 55 | margin-bottom: 40px; 56 | } 57 | 58 | section .tip-wrapper svg { 59 | display: inline-block; 60 | height: 12px; 61 | width: 12px; 62 | margin-right: 4px; 63 | vertical-align: top; 64 | margin-top: 3px; 65 | } 66 | 67 | section .tip-wrapper svg path { 68 | fill: #1ea7fd; 69 | } 70 | -------------------------------------------------------------------------------- /codedb-ui/src/style/antd/customTheme.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/codedb-ui/src/style/antd/customTheme.less -------------------------------------------------------------------------------- /codedb-ui/src/theme/color.ts: -------------------------------------------------------------------------------- 1 | export const color = { 2 | colorPrimary: '#5a3cc1', 3 | colorSuccess: '#09be92', 4 | colorWarning: '#f59153', 5 | colorInfo: '#067056' 6 | } 7 | -------------------------------------------------------------------------------- /codedb-ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "esModuleInterop": true, 8 | "allowSyntheticDefaultImports": true, 9 | "strict": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "noFallthroughCasesInSwitch": true, 12 | "module": "esnext", 13 | "moduleResolution": "node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react-jsx" 18 | }, 19 | "include": ["src"] 20 | } 21 | -------------------------------------------------------------------------------- /core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | alias(libs.plugins.jvm) 4 | alias(libs.plugins.serialization) 5 | } 6 | 7 | dependencies { 8 | api(libs.coroutines.core) 9 | } 10 | -------------------------------------------------------------------------------- /core/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | kotlin.js.compiler=ir 3 | -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/DefaultProject.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core 2 | 3 | /** 4 | * align IDEA project model with Gradle project model 5 | * keep same to: https://www.phodal.com/blog/gradle-idea-project-model/ 6 | **/ 7 | class DefaultProject( 8 | override var name: String = "", 9 | override var displayName: String = "", 10 | override var description: String = "", 11 | override var workdir: String = "", 12 | override var basedir: String = "", 13 | override var modules: List = emptyList() 14 | ) : Project { 15 | /** 16 | * project source root / content 17 | */ 18 | val contentRoot: String get() = "" 19 | 20 | /** 21 | * project dependencies 22 | */ 23 | val dependencies: List get() = emptyList() 24 | 25 | /** 26 | * multiple languages in one project 27 | */ 28 | val languages: List get() = emptyList() 29 | 30 | companion object { 31 | fun create(): Project { 32 | return DefaultProject() 33 | } 34 | } 35 | } 36 | 37 | // to tree 38 | class Dependency( 39 | val name: String, 40 | val version: String, 41 | val scope: String, 42 | // 43 | val dependencies: List = emptyList() 44 | ) 45 | 46 | 47 | class LanguageInfo( 48 | val name: String, 49 | val displayName: String, 50 | val version: String 51 | ) 52 | -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/Project.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core 2 | 3 | interface Project { 4 | var name: String 5 | 6 | var displayName: String 7 | 8 | var description: String 9 | 10 | var workdir: String 11 | 12 | var basedir: String 13 | 14 | var modules: List 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/ProjectContext.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core 2 | 3 | class ProjectContext { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/client/CodedbConfig.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core.client 2 | 3 | // todo: align to ArchGuard CLI config 4 | class CodedbConfig { 5 | /** 6 | * The URL of the server. 7 | */ 8 | val serverUrl: String = "http://localhost:8080" 9 | 10 | /** 11 | * The path to the project root. 12 | */ 13 | val projectRoot: String = "." 14 | 15 | companion object { 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/internal/Action.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core.internal 2 | 3 | interface Action { 4 | fun execute(t: T) 5 | } -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/internal/Element.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core.internal 2 | 3 | import org.jetbrains.annotations.Nullable 4 | 5 | interface Element { 6 | fun getName(): String? 7 | 8 | @Nullable 9 | fun getDescription(): String? 10 | } 11 | 12 | interface HierarchicalElement : Element { 13 | val parent: HierarchicalElement? 14 | val children: List? 15 | } -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/internal/Factory.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core.internal 2 | 3 | /** 4 | * Factory for creating instances of [org.archguard.codedb.automate.api.Task]. 5 | */ 6 | interface Factory { 7 | fun create(): T 8 | } -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/io/DirectoryWalker.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core.io 2 | 3 | import java.io.File 4 | import kotlinx.coroutines.channels.Channel 5 | 6 | abstract class DirectoryWalker(workdir: String) { 7 | protected val root = File(workdir) 8 | 9 | abstract fun start(): List 10 | abstract suspend fun start(output: Channel) 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/io/WalkerCollector.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core.io 2 | 3 | import java.nio.file.FileSystem 4 | import java.nio.file.FileSystems 5 | 6 | 7 | /** 8 | * a collector for TreeWalker 9 | */ 10 | abstract class WalkerCollector { 11 | protected var collectFiles: List = listOf() 12 | protected val fileSystem: FileSystem = FileSystems.getDefault() 13 | 14 | open fun isMatch(rules: List, filename: String) = rules.any { isMatch(it, filename) } 15 | 16 | /** 17 | * default to blob match 18 | */ 19 | open fun isMatch(filename: String, pattern: String): Boolean { 20 | return fileSystem.getPathMatcher("glob:$pattern").matches(fileSystem.getPath(filename)) 21 | } 22 | 23 | abstract fun finalize() 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/log/StreamConsumer.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core.log 2 | 3 | /** 4 | * A consumer of a stream of lines. 5 | */ 6 | interface StreamConsumer { 7 | fun consumeLine(line: String) 8 | 9 | fun stop() {} 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/task/TaskConfigure.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core.task 2 | 3 | class TaskConfigure { 4 | } -------------------------------------------------------------------------------- /core/src/main/kotlin/org/archguard/core/uuid.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.core 2 | 3 | import java.util.* 4 | 5 | fun uuid(): String = UUID.randomUUID().toString() 6 | -------------------------------------------------------------------------------- /docs/adr/0001-keep-spring-2.md: -------------------------------------------------------------------------------- 1 | # 1. keep spring 2.* 2 | 3 | Date: 2023-01-28 4 | 5 | ## Status 6 | 7 | 2023-01-28 proposed 8 | 9 | ## Context 10 | 11 | Spring 3.0 requirements JAVA 17, 12 | refs: [Spring Boot 3.0 require Java 17](https://spring.io/blog/2022/05/24/preparing-for-spring-boot-3-0) 13 | 14 | For now, in most organization, JAVA 17 is not ready for production. 15 | 16 | Table - "Percent in use for each Java LTS version" from [2022 State of the Java Ecosystem Report](https://newrelic.com/resources/report/2022-state-of-java-ecosystem) 17 | 18 | | Java LTS Version | Percent in use | 19 | |------------------|----------------| 20 | | Java 11 | 48.44% | 21 | | Java 8 | 46.45% | 22 | | Java 7 | 1.71% | 23 | | Java 17 | 0.37% | 24 | | Java 6 | 0.27% | 25 | 26 | ## Decision 27 | 28 | Decision here... 29 | 30 | ## Consequences 31 | 32 | Consequences here... 33 | -------------------------------------------------------------------------------- /docs/adr/0002-use-h2-memorydb-for-metric-when-scan.md: -------------------------------------------------------------------------------- 1 | # 2. use h2 memorydb for metric when scan 2 | 3 | Date: 2023-02-02 4 | 5 | ## Status 6 | 7 | 2023-02-02 proposed 8 | 9 | ## Context 10 | 11 | In ArchGuard 1.x and 2.x, we use MySQL to build the metric database. 12 | 13 | - It is not easy to use MySQL in the scan process. 14 | - The old scanner2 module will be removed in the future, but we want to keep the compatibility for old code. 15 | 16 | So we decide to use h2 memorydb to build the metric database. 17 | 18 | Here is the modules: `MetricPersistApplService` 19 | 20 | - DitService 21 | - LCOM4Service 22 | - NocService 23 | - ScannerDataClassService 24 | - JClassRepository 25 | - JMethodRepository 26 | - FanInFanOutService 27 | - ScannerCircularDependencyService 28 | - ClassMetricRepository 29 | - MethodMetricRepository 30 | - PackageMetricRepository 31 | - ModuleMetricRepository 32 | - DataClassRepository 33 | - ScannerCircularDependencyMetricRepository 34 | 35 | ## Decision 36 | 37 | Decision here... 38 | 39 | ## Consequences 40 | 41 | Consequences here... 42 | -------------------------------------------------------------------------------- /docs/adr/0003-use-json-schema-for-share-context.md: -------------------------------------------------------------------------------- 1 | # 3. use Json Schema for share context 2 | 3 | Date: 2023-02-03 4 | 5 | ## Status 6 | 7 | 2023-02-03 proposed 8 | 9 | ## Context 10 | 11 | Context here... 12 | 13 | ## Decision 14 | 15 | Decision here... 16 | 17 | ## Consequences 18 | 19 | Consequences here... 20 | -------------------------------------------------------------------------------- /docs/adr/0004-use-yaml-as-task-dsl-configure.md: -------------------------------------------------------------------------------- 1 | # 4. use yaml as task DSL configure 2 | 3 | Date: 2023-02-07 4 | 5 | ## Status 6 | 7 | 2023-02-07 proposed 8 | 9 | 2023-02-07 accepted 10 | 11 | ## Context 12 | 13 | In our task engine, we need an orchestration DSL to define the task flow. We need to define the task flow in a DSL, 14 | and then we can use the DSL to orchestrate the task flow. 15 | 16 | Design a DSL is not easy, we need to consider the following things (Generate by GitHub Copilot): 17 | 18 | - How to define the task flow? 19 | - How to define the task? 20 | - How to define the task dependency? 21 | - How to define the task parameter? 22 | - How to define the task output? 23 | - How to define the task input? 24 | - How to define the task error? 25 | - How to define the task retry? 26 | - How to define the task timeout? 27 | - ... 28 | 29 | We also need to implement the DSL and the IDE plugin. It's a lot of work. For the coding, it's easy to implement, but for the user, 30 | they need to learn the DSL. It's not easy to learn a DSL. 31 | 32 | So we need to find a way to reduce the learning cost, like Jenkinsfile, we can use the Groovy as the DSL. But Groovy is not a human-readable data-serialization language. 33 | 34 | ## Decision 35 | 36 | So, we can use the YAML as the DSL, and it has used by GitHub Actions, so it's easy to learn and use. 37 | 38 | ## Consequences 39 | 40 | 1. We can use the YAML as the task DSL. 41 | 2. use Kotlin Multiplatform to implement the DSL. 42 | 3. use Json Schema to validate the DSL. 43 | 44 | -------------------------------------------------------------------------------- /docs/adr/0005-add-config-file-for-cli.md: -------------------------------------------------------------------------------- 1 | # 5. add config file for cli 2 | 3 | Date: 2023-02-07 4 | 5 | ## Status 6 | 7 | 2023-02-07 proposed 8 | 9 | ## Context 10 | 11 | In our current CLI, we need to pass the parameters to the CLI. It's not easy to use. We need to add a config file to the 12 | CLI. 13 | 14 | We need to config a lot of things, like (Generate by GitHub Copilot): 15 | 16 | - the server url 17 | - the language 18 | - the features 19 | - the output 20 | - the path 21 | - ... 22 | 23 | But, for the user, it will be hard to remember all the parameters. So we need to add a config file to the CLI. 24 | 25 | ## Decision 26 | 27 | Sample: 28 | 29 | ```yaml 30 | path: . 31 | server: 32 | url: http://localhost:8084 33 | language: Kotlin 34 | features: apicalls 35 | output: http 36 | ``` 37 | 38 | ## Consequences 39 | 40 | Consequences here... 41 | -------------------------------------------------------------------------------- /docs/adr/0006-keep-register-metadata-only.md: -------------------------------------------------------------------------------- 1 | # 6. keep register metadata only 2 | 3 | Date: 2023-02-11 4 | 5 | ## Status 6 | 7 | 2023-02-11 proposed 8 | 9 | ## Context 10 | 11 | In PoC of registry we had saved `.jar` files, but it was not a good idea, because it was not possible to use it in CI/CD pipeline. 12 | 13 | ## Decision 14 | 15 | So, we decided to save only metadata, like `action.json`, then we can choose different ways for our action 16 | 17 | - download `.jar` file from maven repository 18 | - download `.jar` file from GitHub release 19 | - download `.jar` file from GitHub package registry 20 | - download `.jar` file from any other place 21 | 22 | ## Consequences 23 | 24 | Consequences here... 25 | -------------------------------------------------------------------------------- /docs/adr/README.md: -------------------------------------------------------------------------------- 1 | # Architecture Decision Records 2 | 3 | * [1. keep-spring-2](0001-keep-spring-2.md) 4 | * [2. use-h2-memorydb-for-metric-when-scan](0002-use-h2-memorydb-for-metric-when-scan.md) 5 | * [3. use-json-schema-for-share-context](0003-use-json-schema-for-share-context.md) 6 | * [4. use-yaml-as-task-dsl-configure](0004-use-yaml-as-task-dsl-configure.md) 7 | * [5. add-config-file-for-cli](0005-add-config-file-for-cli.md) 8 | * [6. keep-register-metadata-only](0006-keep-register-metadata-only.md) 9 | -------------------------------------------------------------------------------- /docs/specs/.archguard-cli.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "Archguard command line interface schema", 4 | "description": "Archguard command line interface schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "properties": { 8 | "serverUrl": { 9 | "type": "string", 10 | "description": "The URL of the Archguard server" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docs/specs/.archguard-task.schema.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/specs/.archguard-task.schema.json -------------------------------------------------------------------------------- /docs/spike/README.md: -------------------------------------------------------------------------------- 1 | # Docs 2 | 3 | ## 基础数据 4 | 5 | 代码: 6 | 7 | - 包:嵌套深度 8 | - 文件:复杂度 9 | - 类:类名、长度、行数、复杂度 10 | - 函数:函数名、长度、行号、文件名、调用链 11 | 12 | Git: 13 | 14 | - 变更的文件 15 | - 变更的函数 16 | - 变更复杂度 17 | 18 | 设计度量? 19 | 20 | 21 | 架构特征: 22 | 23 | - Spring: Controller-Repository-Service-Entity-Component 24 | 25 | ## 复杂度 26 | 27 | "Correlations of Software Code Metrics: An Empirical Study" 28 | 29 | ![Extracted Project Metrics](images/Extracted-Project-Metrics.png) 30 | 31 | ## 重复度 32 | 33 | 物理重复度: 34 | 35 | - Number of lines involved in duplications 36 | - Duplicated lines on new code 37 | - Number of duplicated blocks of lines. At least 10 successive and duplicated statements to count a block. Indentation and string literals are ignored while detecting 38 | - Duplicated blocks on new code 39 | - Number of files involved in duplications. 40 | - Density of duplication = Duplicated lines / Lines * 100 Duplicated lines on new code balanced by statements 41 | 42 | 逻辑重复度: 43 | 44 | AST 判定。 45 | 46 | ## 基础函数/算子 47 | 48 | ### Aggregate 49 | 50 | 数据缓存层:基于基础数据计算 51 | 52 | ## 机器学习算法 53 | 54 | -------------------------------------------------------------------------------- /docs/spike/ai/code-ai.md: -------------------------------------------------------------------------------- 1 | # Smart Code 2 | 3 | ## CodeSearchNet 4 | 5 | 6 | https://github.com/github/CodeSearchNet 7 | 8 | > Datasets, tools, and benchmarks for representation learning of code. 9 | 10 | ![Model Architecture](model-architecture.png) 11 | 12 | ## Semantic Code Search 13 | 14 | https://github.com/overwindows/SemanticCodeSearch 15 | 16 | Semantic code search implementation using Tensorflow framework and the source code data from the CodeSearchNet project. 17 | The model training pipeline was based on the implementation in CodeSearchNet repository. 18 | Python, Java, Go, Php, Javascript, and Ruby programming language are supported. 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/spike/ai/model-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/ai/model-architecture.png -------------------------------------------------------------------------------- /docs/spike/ai/swagger-api.md: -------------------------------------------------------------------------------- 1 | # API 中文语义 2 | 3 | 4 | 使用 Swagger 理解中文语义,诸如于: 5 | 6 | 获取 xx 信息 - 对应于 GET /xx 7 | 8 | -------------------------------------------------------------------------------- /docs/spike/api-design/builtin-function.md: -------------------------------------------------------------------------------- 1 | # Builtin Function 2 | 3 | 4 | ## Trigger Function / Data 5 | 6 | - 持续构建构建? 7 | - Git 变更 8 | - 扫描变更的文件 9 | - 代码变更 10 | 11 | -------------------------------------------------------------------------------- /docs/spike/api-design/ops-driven-fitness.md: -------------------------------------------------------------------------------- 1 | # Operation Driven Fitness 2 | 3 | 线上资源利用率,分析架构有用性,微服务必要性。 4 | 5 | 微服务 merge 思路 6 | 7 | -------------------------------------------------------------------------------- /docs/spike/api-design/samples.md: -------------------------------------------------------------------------------- 1 | # Syntax Design 2 | 3 | ## Fitness DSL 4 | 5 | ```kotlin 6 | val fitness = Fitness { x: Double -> x * x } 7 | ``` 8 | 9 | ## Tasking 10 | 11 | ```kotlin 12 | @Input 13 | @Parallel // for inputs ? 14 | fun loc(context: Context): Int { 15 | 16 | } 17 | ``` 18 | 19 | or 20 | 21 | ```kotlin 22 | @CodeTask 23 | class Loc : DefaultTask { 24 | /// 25 | @Input 26 | @Incremental 27 | fun query(datasource: Datasource) { 28 | 29 | } 30 | 31 | @Internal 32 | fun loc(context: Context): Int { 33 | 34 | } 35 | 36 | @Output 37 | //@OutputData => to database ? 38 | fun save(context: Context): String { 39 | 40 | } 41 | ` 42 | @TaskAction 43 | fun taskAction() { 44 | 45 | } 46 | } 47 | ``` 48 | 49 | ## Query DSL 50 | 51 | like: [https://prestodb.io/](https://prestodb.io/) ? 52 | 53 | ```kotlin 54 | val query = Query { 55 | select { 56 | from("table") 57 | where("id" eq 1) 58 | } 59 | } 60 | ``` 61 | -------------------------------------------------------------------------------- /docs/spike/atom/license.md: -------------------------------------------------------------------------------- 1 | # LICENSE Checker 2 | 3 | > licensechecker (lc) a command line application which scans directories and identifies what software license things are under producing reports as either SPDX, CSV, JSON, XLSX or CLI Tabular output. Dual-licensed under MIT or the UNLICENSE. 4 | 5 | [https://github.com/boyter/lc](https://github.com/boyter/lc) 6 | 7 | -------------------------------------------------------------------------------- /docs/spike/atom/similarity-analyser.md: -------------------------------------------------------------------------------- 1 | # Similarity Analyser 2 | 3 | 4 | ## Simian 5 | 6 | [https://simian.quandarypeak.com/](https://simian.quandarypeak.com/) 7 | 8 | Simian (Similarity Analyser) identifies duplication in Java, C#, C, C++, COBOL, Ruby, JSP, ASP, HTML, XML, Visual Basic, Groovy source code and even plain text files. In fact, simian can be used on any human readable files such as ini files, deployment descriptors, you name it. 9 | 10 | Especially on large enterprise projects, it can be difficult for any one developer to keep track of all the features (classes, methods, etc.) of the system. 11 | 12 | Simian runs natively in any .NET 1.1 or higher supported environment and on any Java 5 or higher virtual machine, meaning Simian can be run on just about any hardware and any operating system you can hope for. Both the Java and .NET runtimes are included as part of the distribution. 13 | 14 | Simian can be used as part of the build process during development or as a guide when re-factoring. Think of Simian as an independent pair of eyes that will assist in raising the quality of your software. 15 | 16 | Within minutes, Simian can save you literally thousands of dollars in time spent performing maintenence, debugging and re-factoring. 17 | 18 | With licensing available to suite personal, project and enterprise use, simian is ideally suited for use on your project. 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/spike/dsl/Kotlin∇.md: -------------------------------------------------------------------------------- 1 | # Kotlin∇: Type-safe Symbolic Differentiation for the JVM 2 | 3 | https://github.com/breandan/kotlingrad 4 | 5 | "Programming tools for intelligent systems" - 6 | 7 | 8 | ```kotlin 9 | "d(sin x)/dx should be equal to (sin(x + dx) - sin(x)) / dx" { 10 | NumericalGenerator.assertAll { ẋ -> 11 | val f = sin(x) 12 | 13 | val `df∕dx` = d(f) / d(x) 14 | val adEval = `df∕dx`(ẋ) 15 | 16 | val dx = 1E-8 17 | // Since ẋ is a raw numeric type, sin => kotlin.core.sin 18 | val fdEval = (sin(ẋ + dx) - sin(ẋ)) / dx 19 | adEval shouldBeApproximately fdEval 20 | } 21 | } 22 | ``` 23 | 24 | ## Kaliningraph 25 | 26 | 这个库实现了一个新的计算模型,我们称之为图形计算。 与之前的工作(例如图灵机和 Church 的 λ 演算)相比,该模型的优势在于它可以直接转换为 27 | GPU 上的迭代矩阵乘法,并且具有许多理想的代数性质。 此外,它提供了一种自然的方式来表达代数电路、神经网络、因子图、证明网络,并且与编程语言理论、 28 | 自动机理论和范畴论有许多联系。 29 | 30 | ```kotlin 31 | val de = LabeledGraph { d - e } 32 | val dacbe = LabeledGraph { d - a - c - b - e } 33 | val dce = LabeledGraph { d - c - e } 34 | 35 | val abcd = LabeledGraph { a - b - c - d } 36 | val cfde = LabeledGraph { c - "a" - f - d - e } 37 | 38 | val dg = LabeledGraph(dacbe, dce, de) + Graph(abcd, cfde) 39 | dg.show() 40 | ``` 41 | 42 | ![](https://github.com/breandan/galoisenne/raw/master/latex/figures/visualization.svg) 43 | 44 | Computation graph 45 | 46 | ```kotlin 47 | Notebook { 48 | a = b + c 49 | f = b - h 50 | }.show() 51 | ``` 52 | 53 | ![](https://github.com/breandan/galoisenne/raw/master/pdg_demo.svg) 54 | 55 | -------------------------------------------------------------------------------- /docs/spike/expression/README.md: -------------------------------------------------------------------------------- 1 | # Functions 2 | 3 | 4 | ## NLyze: Interactive Programming by Natural Language for SpreadSheet Data Analysis and Manipulation 5 | 6 | ```antlrv4 7 | Program := MakeActive(Q) | Format(fe,Q) | v | V 8 | QueryExprQ := SelectRows(rs,f) | SelectCells(C ̃,rs,f) 9 | Row Source Expr rs := GetTable(Tbl) | MTable() | GetActive() | GetFormat(Tbl,fe) 10 | Format Expr fe := {fmt1, . . . , fmtn} 11 | Filter Expr f := relop(C, v) | relop(v, C) | relop(C, C) | And(f,f) | Or(f,f) | Not(f) | True 12 | Scalar Expr v := rop(C,rs,f) | Count(rs,f) | bop(v,v) | Lookup(v,rs,C,C) | c 13 | Vector Expr V := bop(V,V ) | bop(V,v) | bop(v,V ) | C | Lookup(C, rs, C, C) 14 | Format Fn fmt := Color(c) | FontSize (c) | Bold(b) | Italics (b) | Unserline(b) ... 15 | 16 | Binary Fn bop := Add|Sub|Mult|Div 17 | Reduce Fn rop := Sum|Avg|Min|Max 18 | Relational Fn relop := Lt|Gt|Eq 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/spike/expression/sigmod14.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/expression/sigmod14.pdf -------------------------------------------------------------------------------- /docs/spike/gradle/README.md: -------------------------------------------------------------------------------- 1 | # Gradle Notes 2 | 3 | 4 | ```groovy 5 | def action = Mock(Action) 6 | def provider = container.register("task", action) 7 | provider.configure(action) 8 | container.configureEach(action) 9 | ``` -------------------------------------------------------------------------------- /docs/spike/images/Extracted-Project-Metrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/images/Extracted-Project-Metrics.png -------------------------------------------------------------------------------- /docs/spike/math/Graphic.md: -------------------------------------------------------------------------------- 1 | # Graphics 2 | 3 | 4 | ## Graphviz 5 | 6 | ```kotlin 7 | implementation("guru.nidi:graphviz-kotlin:0.18.1") 8 | ``` 9 | 10 | ## Kaliningraph: A Type Family of Algebraic Graphs 11 | 12 | [https://github.com/breandan/galoisenne](https://github.com/breandan/galoisenne) 13 | 14 | ## Lets-Plot for Kotlin 15 | 16 | https://github.com/JetBrains/lets-plot-kotlin 17 | 18 | Lets-Plot for Kotlin is a Kotlin API for the Lets-Plot library - an open-source plotting library for statistical data. 19 | 20 | Lets-Plot Kotlin API is built on the principles of layered graphics first described in the 21 | Leland Wilkinson work The Grammar of Graphics and later implemented in the ggplot2 package for R. 22 | 23 | 24 | ```kotlin 25 | val rand = java.util.Random() 26 | val data = mapOf ( 27 | "rating" to List(200) { rand.nextGaussian() } + List(200) { rand.nextGaussian() * 1.5 + 1.5 }, 28 | "cond" to List(200) { "A" } + List(200) { "B" } 29 | ) 30 | 31 | var p = letsPlot(data) 32 | p += geomDensity(color="dark_green", alpha=.3) {x="rating"; fill="cond"} 33 | p + ggsize(700, 350) 34 | ``` 35 | 36 | -------------------------------------------------------------------------------- /docs/spike/metrics/code-overview.md: -------------------------------------------------------------------------------- 1 | # 代码指标 2 | 3 | - 代码行数 4 | - 文件数 5 | - 复杂度 6 | - 代码年限 7 | - 作者数 8 | - 需要按邮箱合并? 9 | - 版本管理 10 | - 总提交次数 11 | - 代码变化 12 | - 平均变化复杂度 13 | - 代码行数变化率 14 | - 代码行数变化量 15 | - 代码行数变化量占比 16 | 17 | 其它 18 | 19 | - 代码重复率? 20 | - 代码覆盖率? 21 | -------------------------------------------------------------------------------- /docs/spike/metrics/images/deployment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/metrics/images/deployment.png -------------------------------------------------------------------------------- /docs/spike/metrics/images/microservices-pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/metrics/images/microservices-pattern.png -------------------------------------------------------------------------------- /docs/spike/metrics/images/monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/metrics/images/monitor.png -------------------------------------------------------------------------------- /docs/spike/metrics/images/reaction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/metrics/images/reaction.png -------------------------------------------------------------------------------- /docs/spike/metrics/images/runtime-verify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/metrics/images/runtime-verify.png -------------------------------------------------------------------------------- /docs/spike/metrics/images/specification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/metrics/images/specification.png -------------------------------------------------------------------------------- /docs/spike/metrics/images/taxonomy-static-code-anlaysis-tools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/metrics/images/taxonomy-static-code-anlaysis-tools.png -------------------------------------------------------------------------------- /docs/spike/metrics/images/trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/metrics/images/trace.png -------------------------------------------------------------------------------- /docs/spike/query/README.md: -------------------------------------------------------------------------------- 1 | # Query 2 | 3 | ## Presto 4 | 5 | https://github.com/prestodb/presto 6 | 7 | > Presto is a distributed SQL query engine for big data. 8 | 9 | 10 | ## Velox 11 | 12 | https://github.com/facebookincubator/velox 13 | 14 | > Velox is a C++ database acceleration library which provides reusable, extensible, and high-performance data processing 15 | > components. These components can be reused to build compute engines focused on different analytical workloads, 16 | > including batch, interactive, stream processing, and AI/ML. Velox was created by Facebook and it is currently 17 | > developed in partnership with Intel, ByteDance, and Ahana. 18 | 19 | 20 | - Expression Eval: a fully vectorized expression evaluation engine that allows expressions to be efficiently executed on top of Vector/Arrow encoded data. 21 | 22 | ## QueryDSL Mongodb 23 | 24 | http://querydsl.com/static/querydsl/latest/reference/html/ch02s07.html 25 | 26 | ```java 27 | Morphia morphia; 28 | Datastore datastore; 29 | // ... 30 | QUser user = new QUser("user"); 31 | MorphiaQuery query = new MorphiaQuery(morphia, datastore, user); 32 | List list = query 33 | .where(user.firstName.eq("Bob")) 34 | .fetch(); 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/spike/related/searchcode.md: -------------------------------------------------------------------------------- 1 | # SearchCode 2 | 3 | ## Searchcode 4 | 5 | [https://github.com/boyter/searchcode-server](https://github.com/boyter/searchcode-server) 6 | 7 | > searchcode server is a powerful code search engine with a sleek web user interface. 8 | 9 | searchcode server works in tandem with your source control system, indexing thousands of repositories and files allowing you and your developers to quickly find and reuse code across teams. 10 | 11 | See https://searchcodeserver.com/ for more details or http://demo.searchcodeserver.com/ for a live demo which is indexing multiple projects using GIT and SVN. 12 | 13 | ## codespelunker 14 | 15 | [codespelunker](https://github.com/boyter/cs) 16 | 17 | > command line codespelunker or code search 18 | 19 | -------------------------------------------------------------------------------- /docs/spike/streaming/README.md: -------------------------------------------------------------------------------- 1 | # 2 | 3 | 4 | ## encodeToStream && decodeFromStream 5 | 6 | https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/decode-from-stream.html 7 | 8 | https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/encode-to-stream.html 9 | 10 | decodeToSequence ? 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/spike/twin/README.md: -------------------------------------------------------------------------------- 1 | # Architecture Twin 2 | 3 | 4 | ## Digital Twin in the IoT context: a survey on technical features, scenarios and architectural models 5 | 6 | Digital Twin 7 | 8 | ![](lifecycle.png) 9 | 10 | 在每个阶段,都需要工具和功能才能正确执行流程。一些工具在不同的阶段列出。这是因为它们用于不同的目的。例如, 11 | 创建阶段的模拟可能用于选择一些产品选项 12 | ;在生产阶段,它可用于模拟产品的某些预期行为 13 | ,而在运营阶段,如果产品处于“压力”或在危急情况下使用,它可用于检查和预测某些故障。 14 | 15 | 在设计阶段,数字孪生将由一个逻辑对象表示,实际上是唯一存在的对象,它是所有未来物理对象的软件原型。一旦产品及其数字对应物离开设计阶段, 16 | 生产阶段就会将原型及其软件表示相关联,以便测试和试验未来的产品。在此阶段,DT 的软件方面有助于优化物理对象并进行测试, 17 | 否则将需要实施模型。在操作阶段,逻辑对象和产品(即物理对象)之间的关系可以用不同的方式实例化:1:1 定义意味着一个物理对象由一个逻辑对象表示, 18 | 而1: N指的是产品的n个物理实现指的是一个逻辑对象。换句话说,数字孪生将 n 个产品与单个软件表示相关联。在后一种情况下, 19 | 多个物理副本可以引用一个原型对象并进行协作以表示实例化对象类的实际功能。在某种意义上,数字孪生可以是一个元系统,代表产品的任何物理实例的典型行为。 20 | 物联网技术和功能的一个明显作用是在生产和运营阶段。在这些阶段,传感器和物联网平台可用于实际构建产品,然后用于感测和测量产品的行为和性能。 21 | 22 | ![](self-management.png) 23 | 24 | 自我管理函数与 Orchestrator 同步,以确定需要哪些存储、计算和通信功能以及可以将其分配到何处。 然后创建一个新实例, 25 | 即 LO,根据 PO 和其他 LO 分配状态值,并将应用程序绑定到它。 应执行同步阶段以限制对应用程序的影响。 理想情况下, 26 | 应用程序不应该知道(并且在任何情况下都不会受到影响)正在使用的逻辑对象实例的更改。 在此特定情况下, 27 | 自我管理函数显示为功能块。 选择集中式或更分布式的解决方案取决于数字孪生平台的不同实现方式。 28 | 29 | ![](general-digital-framework.png) 30 | 31 | 分层符合大型中间件开发的总体趋势,并且符合数字孪生平台范围的广泛性及其在关注点分离方面的需求。底层是与设备、边缘和云资源交互的层, 32 | 并考虑如何使用它们、如何虚拟化以及如何利用它们的特性。需要一些功能来分配正确的资源并虚拟化基础设施中的功能/对象。 33 | 此外,由于一些 LO 的严格需求,必须优化通信,特别是为了有效地支持纠缠。分层本质上源自网络资源虚拟化的当前发展,例如 ETSI [295] 所定义的。 34 | 上层处理数字孪生的主要属性,对象层致力于逻辑对象的生命周期及其存在。这包括对象建模、实例化、自我管理、编排、纠缠等功能。 35 | 数据层处理数据的收集和上下文化,以及执行数据分析和信息推断。此外,还有爬取功能,以收集非由实物直接提供的外部信息。 36 | 可以在此处为特定问题域添加语义和本体论。仿真层支持 DT 的可视化、它们的仿真以及用于设计和定义它们的工具。 -------------------------------------------------------------------------------- /docs/spike/twin/general-digital-framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/twin/general-digital-framework.png -------------------------------------------------------------------------------- /docs/spike/twin/lifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/twin/lifecycle.png -------------------------------------------------------------------------------- /docs/spike/twin/self-management.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/twin/self-management.png -------------------------------------------------------------------------------- /docs/spike/visualization/README.md: -------------------------------------------------------------------------------- 1 | # Visualization Metaphor 2 | 3 | 4 | ## The City Metaphor in Software Visualization 5 | 6 | A city metaphor has become a popular method of visualizing properties of program code. This paper provides an overview 7 | of research projects that employ this metaphor for a wide range of software engineering tasks. Until now, projects 8 | employing the city metaphor have primarily focused on visualizing static and semi-static properties of software 9 | repositories, such as understanding how a program’s source code structure is changing over time, 10 | and who is changing what. This paper compares these research. 11 | 12 | 13 | ## Microservice Architecture Reconstruction and Visualization Techniques: A Review 14 | 15 | 过去提出了不同的方法:基于微服务源代码静态分析的方法和基于运行时收集的日志跟踪分析的方法。基于静态和动态分析的方法各有利弊。 16 | 在这项工作中,我们回顾了现有的静态和动态架构重建技术以及用于可视化重建架构的相关工具。这项工作的结果对从业者和研究人员都有用, 17 | 他们可以进一步开发这些方法,为架构退化提供更好的支持。 18 | 19 | 索引词——微服务、软件架构重构、可视化、以系统为中心的视图、去中心化 20 | 21 | -------------------------------------------------------------------------------- /docs/spike/workflow/Workflow.md: -------------------------------------------------------------------------------- 1 | # Workflow 2 | 3 | ## Scalable Execution of Big Data Workflows using Software Containers 4 | 5 | Samples: https://github.com/SINTEF-9012/ebw-prototype 6 | 7 | ![](metamodel-dsl.png) 8 | 9 | 工作流是需要按某种顺序执行以处理一组数据的一系列步骤。它表示执行不同数据摄取、转换和分析任务的一系列概念化步骤。 10 | 可以通过重用另一个工作流来定义给定的工作流。除了步骤之外,工作流还由通信媒介和一组参数组成。步骤是工作流的构建块。 11 | 一个步骤对应于工作流中的单个数据处理工作单元。工作流中的步骤是独立执行的,并且彼此隔离。此外,一个步骤可以有多种选择来实现它并触发执行机制。 12 | 13 | 参数是执行工作流所需的配置的常量值。参数用于运行具有不同配置的工作流。 14 | 除了工作流之外,参数还可以用于定义工作流步骤的配置。触发器表示步骤实例的执行是如何被实例化的。 15 | 步骤执行可以从以固定时间间隔运行的计划触发,也可以配置为仅运行一次(例如,在工作流初始化期间)。 16 | 执行也可以由外部事件触发(例如,从 REST API 调用或消息队列中输入数据的可用性)。 17 | 步骤实施是一个概念,表示如何执行工作流步骤的实际实施。基于容器的实现可以被视为步骤实现的示例。通信介质表示工作流步骤交换数据的机制。 18 | 工作流步骤可以使用消息队列将数据传递到另一个步骤。数据交换也可以使用分布式文件系统或网络服务来执行。 19 | 20 | -------------------------------------------------------------------------------- /docs/spike/workflow/metamodel-dsl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/docs/spike/workflow/metamodel-dsl.png -------------------------------------------------------------------------------- /docs/spike/workflow/openwdl.md: -------------------------------------------------------------------------------- 1 | # OpenWDL 2 | 3 | ## Spec 4 | 5 | https://github.com/openwdl/wdl/blob/main/versions/1.1/SPEC.md 6 | 7 | ```wdl 8 | task hello { 9 | input { 10 | File infile 11 | String pattern 12 | } 13 | 14 | command <<< 15 | egrep '~{pattern}' '~{infile}' 16 | >>> 17 | 18 | runtime { 19 | container: "my_image:latest" 20 | } 21 | 22 | output { 23 | Array[String] matches = read_lines(stdout()) 24 | } 25 | } 26 | 27 | workflow wf { 28 | input { 29 | File infile 30 | String pattern 31 | } 32 | 33 | call hello { 34 | input: infile, pattern 35 | } 36 | 37 | output { 38 | Array[String] matches = hello.matches 39 | } 40 | } 41 | ``` 42 | 43 | Multiple output 44 | 45 | ``` 46 | task mytask { 47 | input { 48 | String s # required input declaration 49 | Int? i # optional input declaration 50 | Float f # input delcaration with an initialization 51 | } 52 | 53 | Boolean b = true # declaration in the task body 54 | 55 | # This is an error! f is not an input parameter and thus 56 | # must be initialized. 57 | File f 58 | 59 | ... 60 | 61 | output { 62 | Array[String] strarr = ["a", "b"] # output declaration 63 | File? optfile = "/path/to/file" # optional output declaration 64 | } 65 | } 66 | ``` -------------------------------------------------------------------------------- /docs/spike/workflow/patterns.md: -------------------------------------------------------------------------------- 1 | # Workflow Patterns 2 | 3 | link: [http://www.workflowpatterns.com/patterns/](http://www.workflowpatterns.com/patterns/) 4 | 5 | In process-aware information systems various perspectives can be distinguished. The [control-flow perspective](http://www.workflowpatterns.com/patterns/control/index.php) 6 | captures aspects related to control-flow dependencies between various tasks (e.g. parallelism, choice, synchronization etc). 7 | Originally twenty patterns were proposed for this perspective, but in the latest iteration this has grown to over forty patterns. 8 | The [data perspective](http://www.workflowpatterns.com/patterns/data/index.php) deals with the passing of information , 9 | scoping of variables, etc, while the [resource perspective](http://www.workflowpatterns.com/patterns/resource/index.php) deals with resource 10 | to task allocation, delegation, etc. Finally the patterns for the [exception handling perspective](http://www.workflowpatterns.com/patterns/exception/index.php) 11 | deal with the various causes of exceptions and the various actions that need to be taken as a result of exceptions occurring. 12 | 13 | Process data extracted from information systems for the purpose of process analysis needs to be of high data-quality for 14 | analysis results to be accurate and trustworthy. [Event Log Imperfection](http://www.workflowpatterns.com/patterns/logimperfection/index.php) 15 | patterns capture some frequently occurring data quality issues that commonly found in event log data used for process analysis. 16 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /pipeline/README.md: -------------------------------------------------------------------------------- 1 | # Action 2 | 3 | inspired by GitHub Action & Action Runner, try to keep align to GitHub Action API. 4 | 5 | 6 | ``` 7 | -> Worker 8 | -> JobRunner 9 | -> StepRunner 10 | -> ActionRunner 11 | ``` -------------------------------------------------------------------------------- /pipeline/action-toolkit/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2018 GitHub, Inc. and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /pipeline/action-toolkit/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | alias(libs.plugins.jvm) 4 | alias(libs.plugins.serialization) 5 | } 6 | 7 | dependencies { 8 | // Logging 9 | api(libs.logging.slf4j.api) 10 | 11 | // http 12 | api(libs.ktor.client.core) 13 | api(libs.ktor.client.cio) 14 | api(libs.ktor.serialization.json) 15 | api(libs.ktor.client.content.negotiation) 16 | 17 | testImplementation(libs.bundles.test) 18 | } 19 | -------------------------------------------------------------------------------- /pipeline/action-toolkit/src/main/kotlin/org/archguard/action/core/Tracing.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.action.core 2 | 3 | import org.slf4j.Logger 4 | import org.slf4j.LoggerFactory 5 | 6 | /** 7 | * Todo: tracing for api 8 | */ 9 | class Tracing { 10 | fun info(str: String) { 11 | logger.info(str) 12 | } 13 | 14 | companion object { 15 | val logger: Logger = LoggerFactory.getLogger(Tracing::class.java) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pipeline/action-toolkit/src/main/kotlin/org/archguard/action/exec/CommandArgs.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.action.exec 2 | 3 | object CommandArgs { 4 | fun argsToMap(args: Array): Map { 5 | return args.toList().chunked(2).associate { it[0] to it[1] } 6 | } 7 | } -------------------------------------------------------------------------------- /pipeline/action-toolkit/src/main/kotlin/org/archguard/action/exec/CommandSetting.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.action.exec 2 | 3 | interface CommandSetting { 4 | companion object fromArgs { 5 | fun fromArgs(args: Array): CommandSetting { 6 | return object : CommandSetting {} 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /pipeline/action-toolkit/src/main/kotlin/org/archguard/action/exec/ExecListeners.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.action.exec 2 | 3 | import org.slf4j.Logger 4 | 5 | interface ExecListeners { 6 | fun stdout(data: String) {} 7 | fun stderr(data: String) {} 8 | } 9 | 10 | class LoggerExecListeners(private val logger: Logger) : ExecListeners { 11 | override fun stdout(data: String) { 12 | logger.info(data) 13 | } 14 | 15 | override fun stderr(data: String) { 16 | logger.error(data) 17 | } 18 | } 19 | 20 | class StringListExecListeners(private var stdout: MutableList, private var stderr: MutableList) : ExecListeners { 21 | override fun stdout(data: String) { 22 | stdout += data 23 | } 24 | 25 | override fun stderr(data: String) { 26 | stderr += data 27 | } 28 | } -------------------------------------------------------------------------------- /pipeline/action-toolkit/src/main/kotlin/org/archguard/action/io/FileExt.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.action.io 2 | 3 | import java.io.File 4 | 5 | object FileExt { 6 | fun rmdir(dir: String) { 7 | val file = File(dir) 8 | if (file.isDirectory && file.exists()) { 9 | file.deleteRecursively() 10 | } 11 | } 12 | 13 | fun mkdir(dir: String) { 14 | val file = File(dir) 15 | if (!file.exists()) { 16 | file.mkdirs() 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /pipeline/action-toolkit/src/test/kotlin/org/archguard/action/exec/CommandTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.action.exec 2 | 3 | import io.kotest.matchers.shouldNotBe 4 | import org.junit.jupiter.api.Test 5 | 6 | class CommandTest { 7 | @Test 8 | fun `test command manager git`() { 9 | var stdout = "" 10 | val options = ExecOptions( 11 | cwd = ".", 12 | listeners = object : ExecListeners { 13 | override fun stdout(data: String) { 14 | stdout += data 15 | } 16 | } 17 | ) 18 | 19 | Command().exec("git", listOf("status"), options) 20 | stdout shouldNotBe "" 21 | } 22 | } -------------------------------------------------------------------------------- /pipeline/checkout/.gitignore: -------------------------------------------------------------------------------- 1 | .tmp 2 | codedb 3 | ddd-monolithic-code-sample -------------------------------------------------------------------------------- /pipeline/checkout/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2018 GitHub, Inc. and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /pipeline/checkout/README.md: -------------------------------------------------------------------------------- 1 | # Checkout Action 2 | 3 | !!!Please carefully test this action in your local environment before using it in production. 4 | -------------------------------------------------------------------------------- /pipeline/checkout/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | application 4 | alias(libs.plugins.jvm) 5 | alias(libs.plugins.shadow) 6 | } 7 | 8 | dependencies { 9 | implementation(projects.pipeline.actionToolkit) 10 | 11 | // Logging 12 | implementation(libs.logging.slf4j.api) 13 | implementation(libs.logging.logback.classic) 14 | 15 | testImplementation(libs.bundles.test) 16 | } 17 | 18 | application { 19 | mainClass.set("org.archguard.action.checkout.MainKt") 20 | } 21 | 22 | tasks { 23 | shadowJar { 24 | 25 | manifest { 26 | attributes(Pair("Main-Class", "org.archguard.action.checkout.MainKt")) 27 | } 28 | // minimize() 29 | dependencies { 30 | exclude(dependency("org.junit.jupiter:.*:.*")) 31 | exclude(dependency("org.junit:.*:.*")) 32 | exclude(dependency("junit:.*:.*")) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /pipeline/checkout/src/main/kotlin/org/archguard/action/checkout/Main.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.action.checkout 2 | 3 | 4 | val logger = org.slf4j.LoggerFactory.getLogger("CheckoutAction") 5 | 6 | fun main(args: Array) { 7 | logger.info("args: ${args.joinToString(" ")}") 8 | // args to GitSourceSettings 9 | val settings = GitSourceSettings.fromArgs(args) 10 | 11 | executeGitCheckout(settings) 12 | } 13 | 14 | -------------------------------------------------------------------------------- /pipeline/checkout/src/main/kotlin/org/archguard/action/checkout/helper/RetryHelper.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.action.checkout.helper 2 | 3 | import kotlin.math.floor 4 | 5 | const val defaultMaxAttempts = 3 6 | const val defaultMinSeconds = 10 7 | const val defaultMaxSeconds = 20 8 | 9 | class RetryHelper( 10 | val maxAttempts: Int = defaultMaxAttempts, 11 | val minSeconds: Int = defaultMinSeconds, 12 | val maxSeconds: Int = defaultMaxSeconds 13 | ) { 14 | private fun getSleepAmount(): Int { 15 | return (floor(Math.random() * (maxSeconds - minSeconds + 1)) + minSeconds).toInt() 16 | } 17 | 18 | private fun sleep(seconds: Int): Unit { 19 | Thread.sleep((seconds * 1000).toLong()) 20 | } 21 | 22 | fun execute(action: () -> T): T { 23 | var attempt = 1 24 | while (attempt < maxAttempts) { 25 | // Try 26 | try { 27 | return action() 28 | } catch (err: Exception) { 29 | println(err.message) 30 | } 31 | 32 | // Sleep 33 | val seconds = getSleepAmount() 34 | println("Waiting $seconds seconds before trying again") 35 | sleep(seconds) 36 | attempt++ 37 | } 38 | 39 | // Last attempt 40 | return action() 41 | } 42 | } -------------------------------------------------------------------------------- /pipeline/checkout/src/test/kotlin/org/archguard/action/checkout/GitSourceSettingsTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.action.checkout 2 | 3 | import io.kotest.matchers.shouldBe 4 | import org.junit.jupiter.api.Test 5 | 6 | class GitSourceSettingsTest { 7 | @Test 8 | fun `test from args for branch`() { 9 | val repository = "https://github.com/archguard/ddd-monolithic-code-sample" 10 | val branch = "master" 11 | 12 | val settings = GitSourceSettings( 13 | repository = repository, 14 | branch = branch, 15 | ) 16 | 17 | executeGitCheckout(settings) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /pipeline/coverage/README.md: -------------------------------------------------------------------------------- 1 | # Coverage 2 | 3 | for more information: http://openclover.org/doc/manual/latest/general--about-code-coverage.html 4 | 5 | ``` 6 | TPC = (BT + BF + SC + MC)/(2*B + S + M) * 100% 7 | 8 | where 9 | 10 | BT - branches that evaluated to "true" at least once 11 | BF - branches that evaluated to "false" at least once 12 | SC - statements covered 13 | MC - methods entered 14 | 15 | B - total number of branches 16 | S - total number of statements 17 | M - total number of methods 18 | ``` 19 | 20 | others: 21 | 22 | 23 | based: 24 | 25 | - https://github.com/bazelbuild/bazel/blob/master/tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator/LcovParser.java 26 | 27 | Can be 28 | 29 | - Bazel 30 | -------------------------------------------------------------------------------- /pipeline/coverage/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | java 4 | application 5 | alias(libs.plugins.jvm) 6 | alias(libs.plugins.serialization) 7 | alias(libs.plugins.shadow) 8 | 9 | kotlin("kapt") 10 | } 11 | 12 | dependencies { 13 | implementation(projects.pipeline.actionToolkit) 14 | implementation(projects.core) 15 | 16 | implementation(libs.kotlin.reflect) 17 | implementation(libs.kotlin.stdlib) 18 | 19 | // Logging 20 | implementation(libs.logging.slf4j.api) 21 | implementation(libs.logging.logback.classic) 22 | 23 | // java 24 | implementation(libs.jacoco.core) 25 | implementation(libs.guava) 26 | implementation(libs.gson) 27 | 28 | compileOnly(libs.auto.value.annotations) 29 | kapt(libs.auto.value) 30 | 31 | implementation(libs.jcommander) 32 | 33 | testImplementation(libs.bundles.test) 34 | testRuntimeOnly(libs.test.junit.engine) 35 | } 36 | 37 | application { 38 | mainClass.set("org.archguard.codedb.coverage.MainKt") 39 | } 40 | 41 | tasks { 42 | shadowJar { 43 | 44 | manifest { 45 | attributes(Pair("Main-Class", "org.archguard.codedb.coverage.MainKt")) 46 | } 47 | // minimize() 48 | dependencies { 49 | exclude(dependency("org.junit.jupiter:.*:.*")) 50 | exclude(dependency("org.junit:.*:.*")) 51 | exclude(dependency("junit:.*:.*")) 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /pipeline/coverage/src/main/kotlin/org/archguard/codedb/coverage/CoverageSettings.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.coverage 2 | 3 | import org.archguard.action.exec.CommandSetting 4 | 5 | class CoverageSettings(val workdir: String, val outputDir: String) : CommandSetting { 6 | companion object { 7 | fun from(argsToMap: Map): CoverageSettings { 8 | return CoverageSettings( 9 | workdir = argsToMap["workdir"] ?: "", 10 | outputDir = argsToMap["outputDir"] ?: "" 11 | ) 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /pipeline/coverage/src/main/kotlin/org/archguard/codedb/coverage/FileSearcher.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.coverage 2 | 3 | interface FileSearcher { 4 | /** 5 | * @param filename 6 | * @return true if the file is a coverage file 7 | */ 8 | fun isMatch(filename: String): Boolean 9 | 10 | fun analyze(filename: String): FileSearchResult 11 | } 12 | 13 | // todo: binding to model 14 | class FileSearchResult { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /pipeline/coverage/src/main/kotlin/org/archguard/codedb/coverage/Main.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.coverage 2 | 3 | import org.archguard.action.exec.CommandArgs 4 | 5 | val logger = org.slf4j.LoggerFactory.getLogger("CoverageAction") 6 | 7 | fun main(args: Array) { 8 | // println args 9 | logger.info("args: ${args.joinToString(" ")}") 10 | val settings = CoverageSettings.from(CommandArgs.argsToMap(args)) 11 | } 12 | -------------------------------------------------------------------------------- /pipeline/coverage/src/main/kotlin/org/archguard/codedb/coverage/jacoco/BeanToSql.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.coverage.jacoco 2 | 3 | import kotlin.reflect.full.findAnnotation 4 | import kotlin.reflect.full.memberProperties 5 | 6 | 7 | class BeanToSql { 8 | fun bean2Sql(bean: Any): String { 9 | val clazz = bean::class 10 | val table = clazz.findAnnotation()?.value ?: clazz.simpleName 11 | val columns = arrayListOf() 12 | val values = arrayListOf() 13 | clazz.memberProperties.forEach { property -> 14 | val column = property.findAnnotation()?.value ?: property.name 15 | columns.add(column) 16 | values.add(property.call(bean)) 17 | } 18 | val valueString = values.joinToString { 19 | if (it is String) { 20 | "'${it.replace("'", "''")}'"// do with like it's -- there is a ' within string 21 | } else if (it is Enum<*>) { 22 | "'$it'" 23 | } else it.toString() 24 | } 25 | 26 | return "insert into test_coverage_$table(${columns.joinToString()}) values($valueString);" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pipeline/coverage/src/test/kotlin/org/archguard/codedb/coverage/CoverageFileFilterTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.coverage 2 | 3 | import io.kotest.matchers.shouldBe 4 | import org.junit.jupiter.api.Disabled 5 | import org.junit.jupiter.api.Test 6 | 7 | class CoverageFileFilterTest { 8 | 9 | @Test 10 | @Disabled 11 | fun byRegex() { 12 | CoverageFileCollector().isMatch("clover.xml") shouldBe true 13 | } 14 | 15 | @Test 16 | @Disabled 17 | fun testFinalize() { 18 | val filter = CoverageFileCollector() 19 | filter.isMatch("coverage.xml") shouldBe false 20 | filter.isMatch("jacoco2.xml") shouldBe false 21 | filter.isMatch("hello.txt") shouldBe false 22 | 23 | filter.finalize() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pipeline/oo-metric/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | java 4 | application 5 | alias(libs.plugins.jvm) 6 | alias(libs.plugins.serialization) 7 | alias(libs.plugins.shadow) 8 | 9 | kotlin("kapt") 10 | } 11 | 12 | dependencies { 13 | implementation(projects.pipeline.actionToolkit) 14 | implementation(projects.core) 15 | 16 | implementation(libs.serialization.json) 17 | 18 | implementation(libs.dataframe.arrow) 19 | implementation(libs.arrow.vector) 20 | implementation(libs.chapi.domain) 21 | 22 | testImplementation(libs.bundles.test) 23 | testRuntimeOnly(libs.test.junit.engine) 24 | } 25 | 26 | application { 27 | mainClass.set("org.archguard.codedb.metric.oo.MainKt") 28 | } 29 | 30 | tasks { 31 | shadowJar { 32 | 33 | manifest { 34 | attributes(Pair("Main-Class", "org.archguard.codedb.metric.oo.MainKt")) 35 | } 36 | // minimize() 37 | dependencies { 38 | exclude(dependency("org.junit.jupiter:.*:.*")) 39 | exclude(dependency("org.junit:.*:.*")) 40 | exclude(dependency("junit:.*:.*")) 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pipeline/oo-metric/src/main/kotlin/org/archguard/codedb/metric/oo/Main.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.metric.oo 2 | 3 | import chapi.domain.core.CodeDataStruct 4 | import org.jetbrains.kotlinx.dataframe.DataFrame 5 | import org.jetbrains.kotlinx.dataframe.api.cast 6 | import org.jetbrains.kotlinx.dataframe.io.read 7 | 8 | val logger = org.slf4j.LoggerFactory.getLogger("OoMetric") 9 | /** 10 | * OO metric for Java/Kotlin, etc. 11 | * 12 | * input args: CodeDataStructure 13 | */ 14 | fun main(args: Array) { 15 | logger.info("args: ${args.joinToString(" ")}") 16 | val settings = OoMetricSetting.fromArgs(args) 17 | 18 | val structDataFrame = DataFrame.read(settings.input).cast() 19 | metric(structDataFrame) 20 | } 21 | -------------------------------------------------------------------------------- /pipeline/oo-metric/src/main/kotlin/org/archguard/codedb/metric/oo/Metric.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.metric.oo 2 | 3 | import chapi.domain.core.CodeDataStruct 4 | import org.jetbrains.kotlinx.dataframe.DataFrame 5 | 6 | fun metric(structDataFrame: DataFrame) { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /pipeline/oo-metric/src/main/kotlin/org/archguard/codedb/metric/oo/OoMetricSetting.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.metric.oo 2 | 3 | import kotlinx.serialization.Serializable 4 | import org.archguard.action.exec.CommandArgs 5 | import org.archguard.action.exec.CommandSetting 6 | 7 | @Serializable 8 | data class OoMetricSetting( 9 | val input: String, 10 | val output: String, 11 | ) : CommandSetting { 12 | companion object { 13 | fun fromArgs(args: Array): OoMetricSetting { 14 | val argsMap = CommandArgs.argsToMap(args) 15 | 16 | return OoMetricSetting( 17 | input = argsMap["--input"] ?: "", 18 | output = argsMap["--output"] ?: "", 19 | ) 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /pipeline/oo-metric/src/test/kotlin/org/archguard/codedb/metric/oo/MetricTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.metric.oo 2 | 3 | class MetricTest { 4 | 5 | } -------------------------------------------------------------------------------- /pipeline/runner/.gitignore: -------------------------------------------------------------------------------- 1 | plugins/** 2 | *.json 3 | *.arrow -------------------------------------------------------------------------------- /pipeline/runner/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2018 GitHub, Inc. and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /pipeline/runner/archguard.yml: -------------------------------------------------------------------------------- 1 | name: ArchGuard 3.0 - CodeDB 2 | on: [ push ] 3 | 4 | env: 5 | registry: 6 | url: https://registry.archguard.org/ 7 | local: true 8 | server: 9 | url: http://localhost:8084 10 | 11 | jobs: 12 | backend: 13 | config: 14 | displayName: Backend 15 | 16 | steps: 17 | # - uses: actions/checkout@0.1.0-SNAPSHOT 18 | # with: 19 | # repository: https://github.com/archguard/code-poc.git 20 | # branch: master 21 | # 22 | # - name: "Complexity" 23 | # uses: archguard/scanner@v2 24 | # with: 25 | # type: "estimate" 26 | # path: "." 27 | # output: [ "json", "arrow" ] 28 | 29 | - name: "Source Code with Linter" 30 | uses: archguard/scanner@v2 31 | with: 32 | type: "source_code" 33 | language: kotlin 34 | features: [ "datamap" ] 35 | output: [ "json", "arrow" ] 36 | rules: [ "webapi", "test", "sql" ] 37 | path: "." 38 | 39 | - name: Software Composition Analysis 40 | uses: archguard/scanner@v2 41 | with: 42 | type: "sca" 43 | path: "." 44 | language: kotlin 45 | output: [ "json" ] 46 | 47 | # - uses: analyser/architecture@0.0.1 48 | # with: 49 | 50 | # - uses: linter/database@v1 51 | # - used: metric/oo@v1 52 | # - used: metric/complexity@v1 53 | 54 | # for translation custom rules 55 | # - used: factor/sonarqube@v1 56 | -------------------------------------------------------------------------------- /pipeline/runner/src/kts/kotlin/org/archguard/runner/handler/HandlerFactory.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.handler 2 | 3 | import org.archguard.runner.context.RunnerContext 4 | import org.archguard.runner.pipeline.ActionStep 5 | 6 | class HandlerFactory { 7 | companion object { 8 | fun create(data: ActionStep, context: RunnerContext): Handler { 9 | if (data.run.isEmpty()) { 10 | return CompositeActionHandler(data, context, data.uses) 11 | } 12 | 13 | return when (data.run.scriptType()) { 14 | ScriptType.KotlinScriptFile -> KotlinScriptActionHandler(data, context, data.name) 15 | ScriptType.Shell -> CommandActionHandler(data, context, data.name) 16 | ScriptType.ShellScriptFile -> ShellScriptActionHandler(data, context, data.name) 17 | } 18 | } 19 | } 20 | } 21 | 22 | private fun String.scriptType(): ScriptType { 23 | if (this.endsWith(".kts")) { 24 | return ScriptType.KotlinScriptFile 25 | } 26 | if (this.endsWith(".sh")) { 27 | return ScriptType.ShellScriptFile 28 | } 29 | 30 | return ScriptType.Shell 31 | } 32 | 33 | sealed class ScriptType { 34 | object KotlinScriptFile : ScriptType() 35 | 36 | object ShellScriptFile : ScriptType() 37 | 38 | object Shell : ScriptType() 39 | } -------------------------------------------------------------------------------- /pipeline/runner/src/kts/kotlin/org/archguard/runner/handler/KotlinScriptActionHandler.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.handler 2 | 3 | import org.archguard.codedb.repl.KotlinReplWrapper 4 | import org.archguard.runner.context.RunnerContext 5 | import org.archguard.runner.pipeline.ActionStep 6 | import java.io.File 7 | 8 | class KotlinScriptActionHandler( 9 | private val step: ActionStep, val context: RunnerContext, val name: String 10 | ) : Handler { 11 | override fun getDisplayName(): String = name 12 | override fun runSync() { 13 | val file = File(step.run) 14 | if (!file.exists()) { 15 | throw Exception("File not found: ${file.absolutePath}") 16 | } 17 | 18 | val readText = file.readText() 19 | KotlinReplWrapper().eval(readText) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/Runner.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner 2 | 3 | import com.github.ajalt.clikt.core.CliktCommand 4 | import com.github.ajalt.clikt.parameters.options.default 5 | import com.github.ajalt.clikt.parameters.options.option 6 | import org.archguard.runner.context.DEFAULT_MANIFEST_PATH 7 | import org.slf4j.Logger 8 | import java.io.File 9 | import kotlin.system.exitProcess 10 | import kotlin.system.measureTimeMillis 11 | 12 | fun main(args: Array) = Runner().main(args) 13 | class Runner : CliktCommand(help = "ArchGuard Action Runner") { 14 | // todo: add auto lookup for config file 15 | private val runnerConfig: String by option(help = "Number of greetings").default(DEFAULT_MANIFEST_PATH) 16 | 17 | private val worker = Worker() 18 | 19 | override fun run() { 20 | logger.info("Runner started") 21 | logger.info("Current directory: ${System.getProperty("user.dir")}") 22 | logger.info("configFile: $runnerConfig") 23 | 24 | if(!File(runnerConfig).exists()) { 25 | logger.error("Config file not found: $runnerConfig") 26 | exitProcess(1) 27 | } 28 | 29 | measureTimeMillis { 30 | worker.run(runnerConfig) 31 | }.let { 32 | logger.info("Runner finished in ${it}ms = ${it / 1000.0}s") 33 | } 34 | } 35 | 36 | companion object { 37 | val logger: Logger = org.slf4j.LoggerFactory.getLogger(Runner::class.java) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/Worker.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner 2 | 3 | import org.archguard.runner.context.RunnerContext 4 | import org.archguard.runner.runner.JobRunner 5 | import org.archguard.runner.runner.RunnerService 6 | 7 | class Worker: RunnerService() { 8 | private val jobRunner: JobRunner = JobRunner() 9 | fun run(configFile: String) { 10 | val runnerContext = RunnerContext() 11 | runnerContext.manifestYmlPath = configFile 12 | jobRunner.run(runnerContext) 13 | } 14 | } -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/context/ActionContext.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.context 2 | 3 | /** 4 | * Base class for all template tokens 5 | */ 6 | abstract class ActionContext { 7 | } 8 | 9 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/context/EnvironmentContext.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.context 2 | 3 | /** 4 | * A key value pair of environment variables 5 | */ 6 | interface EnvironmentContext { 7 | fun getRuntimeEnvironmentVariables(): Map 8 | } 9 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/context/HostContext.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.context 2 | 3 | import java.io.File 4 | 5 | /** 6 | * todo: to support action and worker run in different host 7 | */ 8 | open class HostContext(val hostType: String) { 9 | protected val logFile: File by lazy { File(directory, "log.txt") } 10 | protected val directory: String by lazy { 11 | System.getProperty("user.dir") 12 | // todo: create temp dir 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/context/RunnerContext.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.context 2 | 3 | import org.archguard.runner.pipeline.ActionEnv 4 | import java.io.File 5 | 6 | const val DEFAULT_MANIFEST_PATH: String = "archguard.yml" 7 | 8 | /** 9 | * Runner context 10 | */ 11 | open class RunnerContext: EnvironmentContext, ActionContext() { 12 | var registry: String = "https://registry.archguard.org/" 13 | 14 | val pluginDirectory: String = "plugins" 15 | 16 | var manifestYmlPath: String = DEFAULT_MANIFEST_PATH 17 | 18 | var workingDirectory: String = "." 19 | 20 | // share in context 21 | val actionEnv: ActionEnv = ActionEnv() 22 | 23 | override fun getRuntimeEnvironmentVariables(): Map { 24 | return mapOf() 25 | } 26 | } -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/handler/CommandActionHandler.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.handler 2 | 3 | import org.archguard.runner.context.RunnerContext 4 | import org.archguard.runner.pipeline.ActionStep 5 | 6 | class CommandActionHandler( 7 | private val step: ActionStep, 8 | val context: RunnerContext, 9 | val name: String 10 | ) : Handler { 11 | override fun getDisplayName(): String = name 12 | 13 | override fun runSync() { 14 | 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/handler/Handler.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.handler 2 | 3 | interface Handler { 4 | fun getDisplayName(): String 5 | 6 | fun runSync() 7 | 8 | fun prepareExecution() {} 9 | } 10 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/handler/HandlerFactory.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.handler 2 | 3 | import org.archguard.runner.context.RunnerContext 4 | import org.archguard.runner.pipeline.ActionStep 5 | 6 | class HandlerFactory { 7 | companion object { 8 | fun create(data: ActionStep, context: RunnerContext): Handler { 9 | if (data.run.isEmpty()) { 10 | return CompositeActionHandler(data, context, data.uses) 11 | } 12 | 13 | return when (data.run.scriptType()) { 14 | ScriptType.Shell -> CommandActionHandler(data, context, data.name) 15 | ScriptType.ShellScriptFile -> ShellScriptActionHandler(data, context, data.name) 16 | else -> { 17 | throw Exception("Unsupported script type: ${data.run}") 18 | } 19 | } 20 | } 21 | } 22 | } 23 | 24 | private fun String.scriptType(): ScriptType { 25 | if (this.endsWith(".kts")) { 26 | return ScriptType.KotlinScriptFile 27 | } 28 | if (this.endsWith(".sh")) { 29 | return ScriptType.ShellScriptFile 30 | } 31 | 32 | return ScriptType.Shell 33 | } 34 | 35 | sealed class ScriptType { 36 | object KotlinScriptFile : ScriptType() 37 | 38 | object ShellScriptFile : ScriptType() 39 | 40 | object Shell : ScriptType() 41 | } -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/handler/ShellScriptActionHandler.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.handler 2 | 3 | import org.archguard.action.exec.Command 4 | import org.archguard.runner.context.RunnerContext 5 | import org.archguard.runner.pipeline.ActionStep 6 | 7 | class ShellScriptActionHandler( 8 | private val step: ActionStep, 9 | val context: RunnerContext, 10 | val name: String 11 | ) : Handler { 12 | override fun getDisplayName(): String = name 13 | override fun runSync() { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/pipeline/ActionDefinitionData.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.pipeline 2 | 3 | import kotlinx.serialization.Serializable 4 | 5 | @Serializable 6 | data class ActionDefinitionData( 7 | var name: String = "", 8 | var description: String = "", 9 | var author: String? = "", 10 | var version: String? = "", 11 | var env: ActionEnv = ActionEnv(), 12 | val jobs: Map = mapOf() 13 | ) 14 | 15 | enum class ActionExecutionType { 16 | Composite, 17 | Script, 18 | Plugin 19 | } 20 | 21 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/pipeline/ActionEnv.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.pipeline 2 | 3 | import kotlinx.serialization.Serializable 4 | 5 | /** 6 | * examples: 7 | * ```yaml 8 | * config: 9 | * metric: true 10 | * server: 11 | * url: http://localhost:8084 12 | * ``` 13 | */ 14 | 15 | @Serializable 16 | data class ActionEnv( 17 | var metric: Boolean = false, 18 | val registry: RegistryConfig = RegistryConfig(), 19 | val server: ActionServerConfig = ActionServerConfig() 20 | ) 21 | 22 | @Serializable 23 | data class RegistryConfig( 24 | // string representation of the plugin registry 25 | val url: String = "", 26 | val local: Boolean = false, 27 | ) 28 | 29 | @Serializable 30 | data class JobConfig( 31 | val server: ActionServerConfig = ActionServerConfig(), 32 | val displayName: String = "", 33 | ) 34 | 35 | @Serializable 36 | data class ActionServerConfig( 37 | var url: String = "" 38 | ) 39 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/pipeline/ActionExecutionData.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.pipeline 2 | 3 | import kotlinx.serialization.Serializable 4 | 5 | @Serializable 6 | sealed class ActionExecutionData { 7 | abstract val name: String 8 | abstract val config: JobConfig 9 | abstract val steps: List 10 | abstract val actionType: ActionExecutionType 11 | } 12 | 13 | @Serializable 14 | data class ScriptActionExecutionData( 15 | override var name: String = "", 16 | override var config: JobConfig = JobConfig(), 17 | override var steps: List = listOf(), 18 | override val actionType: ActionExecutionType = ActionExecutionType.Script, 19 | val script: String = "" 20 | ) : ActionExecutionData() 21 | 22 | @Serializable 23 | data class CompositeActionExecutionData( 24 | override var name: String = "", 25 | override var config: JobConfig = JobConfig(), 26 | override var steps: List = listOf(), 27 | override val actionType: ActionExecutionType = ActionExecutionType.Composite, 28 | // todo: support pre-actions and post-actions in future 29 | val pre: List = listOf(), 30 | val post: List = listOf(), 31 | ) : ActionExecutionData() { 32 | 33 | } -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/registry/ActionRegistry.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.registry 2 | 3 | import kotlinx.serialization.Serializable 4 | 5 | @Serializable 6 | data class ActionRegistry( 7 | val name: String, 8 | val description: String, 9 | val version: String, 10 | val author: String, 11 | val time: Time, 12 | val versions: Map, 13 | val homepage: String, 14 | val repository: Repository, 15 | val license: String, 16 | val readme: String 17 | ) { 18 | 19 | } 20 | 21 | @Serializable 22 | data class Repository( 23 | val type: String, 24 | val url: String 25 | ) 26 | 27 | @Serializable 28 | data class Time( 29 | val modified: String, 30 | val created: String, 31 | val latestVersion: String 32 | ) 33 | 34 | @Serializable 35 | data class Version( 36 | val name: String, 37 | val description: String, 38 | val dist: Dist 39 | ) 40 | 41 | @Serializable 42 | data class Dist( 43 | val sha: String, 44 | val pkg: String 45 | ) 46 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/runner/ActionRunner.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.runner 2 | 3 | import org.archguard.runner.context.RunnerContext 4 | import org.archguard.runner.handler.Handler 5 | import org.archguard.runner.handler.HandlerFactory 6 | import org.slf4j.LoggerFactory 7 | 8 | class ActionRunner : RunnerService() { 9 | 10 | // todo: convert to handler and execute by type? 11 | fun run(context: RunnerContext) { 12 | val actionManager = ActionManager(context) 13 | 14 | // 1. load action definition 15 | val definitionData = actionManager.loadActions() 16 | // 2. build context 17 | context.registry = definitionData.env.registry.url 18 | 19 | // 3. create handler 20 | val handlers: List = definitionData.jobs.flatMap { job -> 21 | val actionData = job.value 22 | 23 | actionManager.prepareActionsAsync(actionData) 24 | actionData.steps.map { step -> 25 | HandlerFactory.create(step, context) 26 | } 27 | } 28 | 29 | // 4. prepare actions 30 | handlers.forEach { handler -> 31 | handler.prepareExecution() 32 | logger.info("Run action: ${handler.getDisplayName()}, type: ${handler.javaClass.simpleName}") 33 | handler.runSync() 34 | } 35 | } 36 | 37 | companion object { 38 | private val logger = LoggerFactory.getLogger(ActionRunner::class.java) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/runner/JobRunner.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.runner 2 | 3 | import org.archguard.runner.context.RunnerContext 4 | 5 | class JobRunner : RunnerService() { 6 | private val stepRunner = StepRunner() 7 | 8 | fun run(context: RunnerContext) { 9 | stepRunner.run(context) 10 | } 11 | } -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/runner/RunnerService.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.runner 2 | 3 | import org.archguard.runner.context.HostContext 4 | 5 | open class RunnerService { 6 | protected val hostContext: HostContext = HostContext(hostType = "Runner") 7 | } 8 | -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/runner/StepRunner.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.runner 2 | 3 | import org.archguard.runner.context.RunnerContext 4 | 5 | class StepRunner: RunnerService() { 6 | private val actionRunner = ActionRunner() 7 | 8 | fun run(content: RunnerContext) { 9 | actionRunner.run(content) 10 | } 11 | } -------------------------------------------------------------------------------- /pipeline/runner/src/main/kotlin/org/archguard/runner/serial/YamlExt.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.serial 2 | 3 | import com.charleskorn.kaml.Yaml 4 | import com.charleskorn.kaml.YamlNode 5 | import com.charleskorn.kaml.yamlMap 6 | import com.charleskorn.kaml.yamlScalar 7 | import kotlinx.serialization.decodeFromString 8 | 9 | fun YamlNode.stringify(): String { 10 | return this.contentToString().withoutQuotes() 11 | } 12 | 13 | private fun String.withoutQuotes(): String { 14 | if (this.startsWith("\"") && this.endsWith("\"")) { 15 | return this.substring(1, this.length - 1) 16 | } 17 | 18 | if (this.startsWith("'") && this.endsWith("'")) { 19 | return this.substring(1, this.length - 1) 20 | } 21 | 22 | return this 23 | } 24 | 25 | inline fun YamlNode.objectValue(name: String): T { 26 | val node = this.yamlMap.get(name)?.contentToString() 27 | return Yaml.default.decodeFromString(node ?: "") 28 | } 29 | 30 | fun YamlNode.flatString(name: String): String { 31 | return this.yamlMap.get(name)?.yamlScalar?.content ?: "" 32 | } -------------------------------------------------------------------------------- /pipeline/runner/src/test/kotlin/org/archguard/runner/ActionManagerTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner 2 | 3 | import org.archguard.runner.context.RunnerContext 4 | import org.archguard.runner.runner.ActionManager 5 | import org.archguard.runner.runner.DownloadInfo 6 | import org.junit.jupiter.api.Disabled 7 | import org.junit.jupiter.api.Test 8 | import java.io.File 9 | 10 | class ActionManagerTest { 11 | @Test 12 | @Disabled 13 | fun `test action manager`() { 14 | val actionManager = ActionManager(RunnerContext()) 15 | 16 | val targetDir = "plugins" 17 | val pluginFile = File(targetDir) 18 | if (!pluginFile.exists()) { 19 | pluginFile.mkdirs() 20 | } 21 | 22 | val downloadInfo = DownloadInfo.from("https://registry.archguard.org/", "actions/checkout@0.1.0-SNAPSHOT")!! 23 | actionManager.executeDownload(downloadInfo, targetDir) 24 | } 25 | } -------------------------------------------------------------------------------- /pipeline/runner/src/test/kotlin/org/archguard/runner/DownloadInfoTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner 2 | 3 | import io.kotest.matchers.shouldBe 4 | import org.archguard.runner.runner.DownloadInfo 5 | import org.junit.jupiter.api.Test 6 | import java.net.URL 7 | 8 | class DownloadInfoTest { 9 | @Test 10 | fun `test download info`() { 11 | val downloadInfo = DownloadInfo.from("https://plugin.archguard.org/", "actions/setup@v1")!! 12 | 13 | downloadInfo.metaUrl shouldBe URL("https://plugin.archguard.org/actions/setup.json") 14 | } 15 | 16 | @Test 17 | fun `should log error when action name error`() { 18 | val downloadInfo = DownloadInfo.from("https://plugin.archguard.org/", "actions/setup@v1@v1") 19 | downloadInfo shouldBe null 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /pipeline/runner/src/test/kotlin/org/archguard/runner/handler/HandlerFactorTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.handler 2 | 3 | import io.kotest.matchers.types.shouldBeTypeOf 4 | import org.archguard.runner.context.RunnerContext 5 | import org.archguard.runner.pipeline.ActionStep 6 | import org.junit.jupiter.api.Test 7 | 8 | class HandlerFactorTest { 9 | @Test 10 | fun `handler type shell script`() { 11 | val handler = HandlerFactory.create( 12 | ActionStep( 13 | name = "test", 14 | run = "test.sh" 15 | ), RunnerContext() 16 | ) 17 | 18 | handler.shouldBeTypeOf() 19 | } 20 | 21 | @Test 22 | fun `handler type command`() { 23 | val handler = HandlerFactory.create( 24 | ActionStep( 25 | name = "test", 26 | run = "npm ci" 27 | ), RunnerContext() 28 | ) 29 | 30 | handler.shouldBeTypeOf() 31 | } 32 | } -------------------------------------------------------------------------------- /pipeline/runner/src/test/kotlin/org/archguard/runner/serial/ScalarTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.runner.serial 2 | 3 | import com.charleskorn.kaml.Yaml 4 | import com.charleskorn.kaml.YamlNode 5 | import com.charleskorn.kaml.yamlMap 6 | import io.kotest.matchers.shouldBe 7 | import org.junit.jupiter.api.Test 8 | 9 | class ScalarTest { 10 | @Test 11 | fun `should convert scalar value`() { 12 | Scalar.fromString("value") shouldBe Scalar.String("value") 13 | Scalar.fromString("true") shouldBe Scalar.Boolean(true) 14 | 15 | Scalar.fromString("1") shouldBe Scalar.Number(1.0) 16 | } 17 | 18 | @Test 19 | fun `should convert array`() { 20 | val result = Yaml.default.parseToYamlNode("value: [1, 2, 3]") 21 | val scalar = result.yamlMap.get("value")!! 22 | 23 | // Numbers 24 | Scalar.from(scalar) shouldBe Scalar.List( 25 | listOf( 26 | Scalar.Number(1.0), 27 | Scalar.Number(2.0), 28 | Scalar.Number(3.0) 29 | ) 30 | ) 31 | 32 | val result2 = Yaml.default.parseToYamlNode("value: [\"1\", \"2\", \"3\"]") 33 | val scalar2 = result2.yamlMap.get("value")!! 34 | 35 | Scalar.from(scalar2) shouldBe Scalar.List( 36 | listOf("1.0", "2.0", "3.0").map { Scalar.Number(it.toDouble()) } 37 | ) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pipeline/runner/src/test/resources/pipeline/basic-script.yml: -------------------------------------------------------------------------------- 1 | name: ArchGuard 3.0 - CodeDB 2 | 3 | on: [ push ] 4 | 5 | jobs: 6 | hello: 7 | config: 8 | displayName: "Sample" 9 | steps: 10 | - name: Sample Script 11 | type: Kotlin 12 | script: sample/sample.kts 13 | env: 14 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 15 | -------------------------------------------------------------------------------- /pipeline/runner/src/test/resources/pipeline/basic.yml: -------------------------------------------------------------------------------- 1 | name: ArchGuard 3.0 - CodeDB 2 | 3 | # This workflow is triggered on pushes to the repository. 4 | on: [ push ] 5 | 6 | # global shared context information 7 | env: 8 | registry: 9 | url: https://registry.archguard.org/ 10 | server: 11 | url: http://localhost:8084 12 | 13 | jobs: 14 | backend: 15 | config: 16 | displayName: "Backend" 17 | 18 | steps: 19 | - uses: actions/checkout@v3 20 | - uses: analyser/source-code@v1 21 | with: 22 | features: [ 'datamap' ] 23 | server-url: ${{ env.server.url }} 24 | - uses: linter/database@v1 25 | - uses: analyser/coverage@v1 26 | 27 | frontend: 28 | 29 | config: 30 | displayName: "Frontend" 31 | 32 | steps: 33 | - uses: actions/checkout@v3 34 | - uses: analyser/source-code@v1 35 | with: 36 | project: frontend 37 | path: frontend 38 | features: 39 | - name: datamap 40 | config: 41 | languages: [ "javascript" ] 42 | -------------------------------------------------------------------------------- /pipeline/runner/src/test/resources/pipeline/serial/basic-input.yml: -------------------------------------------------------------------------------- 1 | name: ArchGuard 3.0 - CodeDB 2 | 3 | # This workflow is triggered on pushes to the repository. 4 | on: [ push ] 5 | 6 | # global shared context information 7 | env: 8 | registry: 9 | url: https://registry.archguard.org/ 10 | server: 11 | url: http://localhost:8084 12 | 13 | jobs: 14 | backend: 15 | config: 16 | displayName: "Backend" 17 | 18 | steps: 19 | - uses: actions/checkout@v3 20 | - uses: analyser/source-code@v1 21 | with: 22 | features: [ 'datamap' ] 23 | - uses: linter/database@v1 24 | - uses: analyser/coverage@v1 25 | 26 | frontend: 27 | 28 | config: 29 | displayName: "Frontend" 30 | 31 | steps: 32 | - uses: actions/checkout@v3 33 | - uses: analyser/source-code@v1 34 | with: 35 | project: frontend 36 | path: frontend 37 | server: ${{ project.server.url }} 38 | features: 39 | - name: datamap 40 | config: 41 | languages: [ "javascript" ] 42 | -------------------------------------------------------------------------------- /pipeline/runner/src/test/resources/pipeline/serial/basic-output.yml: -------------------------------------------------------------------------------- 1 | name: "ArchGuard 3.0 - CodeDB" 2 | env: 3 | registry: 4 | url: "https://registry.archguard.org/" 5 | server: 6 | url: "http://localhost:8084" 7 | jobs: 8 | "backend": 9 | type: "org.archguard.runner.pipeline.CompositeActionExecutionJob" 10 | name: "backend" 11 | config: 12 | server: {} 13 | displayName: "Backend" 14 | steps: 15 | - uses: "actions/checkout@v3" 16 | - uses: "analyser/source-code@v1" 17 | with: 18 | "features": 19 | - "datamap" 20 | - uses: "linter/database@v1" 21 | - uses: "analyser/coverage@v1" 22 | "frontend": 23 | type: "org.archguard.runner.pipeline.CompositeActionExecutionJob" 24 | name: "frontend" 25 | config: 26 | server: {} 27 | displayName: "Frontend" 28 | steps: 29 | - uses: "actions/checkout@v3" 30 | - uses: "analyser/source-code@v1" 31 | with: 32 | "path": "frontend" 33 | "server": "${{ project.server.url }}" 34 | "features": 35 | - "name": "datamap" 36 | "config": 37 | "languages": 38 | - "javascript" 39 | "project": "frontend" 40 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/builtin/LocTask.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.builtin 2 | 3 | import org.archguard.codedb.automate.task.DefaultTask 4 | import org.archguard.codedb.automate.task.core.CacheableTask 5 | import org.archguard.codedb.automate.task.core.Input 6 | import org.archguard.codedb.automate.task.core.Output 7 | import org.archguard.codedb.automate.task.core.TaskAction 8 | 9 | @CacheableTask 10 | abstract class LocTask : DefaultTask() { 11 | @get:Input 12 | val source = "src/main/kotlin" 13 | 14 | @get:Output 15 | val output = "" 16 | 17 | @TaskAction 18 | fun run() { 19 | println("Running LocTask") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/builtin/StaticTracing.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.builtin 2 | 3 | import org.archguard.codedb.automate.task.DefaultTask 4 | import org.archguard.codedb.automate.task.core.CacheableTask 5 | 6 | @CacheableTask 7 | abstract class StaticTracing : DefaultTask() { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/DefaultTask.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task 2 | 3 | import org.archguard.core.DefaultProject 4 | import org.archguard.core.Project 5 | import org.archguard.codedb.automate.task.api.AbstractTask 6 | import org.archguard.codedb.automate.task.api.TaskInputs 7 | import org.archguard.codedb.automate.task.api.TaskOutputs 8 | 9 | open class DefaultTask : AbstractTask() { 10 | override var project: Project = DefaultProject.create() 11 | 12 | override var name: String 13 | get() = TODO("Not yet implemented") 14 | set(value) {} 15 | override var description: String 16 | get() = TODO("Not yet implemented") 17 | set(value) {} 18 | override var group: String 19 | get() = TODO("Not yet implemented") 20 | set(value) {} 21 | override var dependsOn: Set 22 | get() = TODO("Not yet implemented") 23 | set(value) {} 24 | 25 | override fun getInputs(): TaskInputs { 26 | TODO("Not yet implemented") 27 | } 28 | 29 | override fun getOutputs(): TaskOutputs { 30 | TODO("Not yet implemented") 31 | } 32 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/TaskRunner.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task 2 | 3 | import org.archguard.core.DefaultProject 4 | import org.archguard.codedb.automate.task.api.AbstractTask 5 | import org.archguard.codedb.automate.task.core.Input 6 | import kotlin.reflect.full.findAnnotation 7 | import kotlin.reflect.full.primaryConstructor 8 | 9 | class TaskRunner { 10 | fun run(): Input? { 11 | val instance = DefaultProject::class.primaryConstructor!!.call("demo", "", "") 12 | 13 | // todo: add task collections 14 | val runnerKClass = AbstractTask::class 15 | val tasks = runnerKClass.findAnnotation() 16 | return tasks 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/api/AbstractTask.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.api 2 | 3 | import org.archguard.core.Project 4 | 5 | abstract class AbstractTask() : Task { 6 | open lateinit var project: Project 7 | override fun setDependsOn(dependsOnTasks: Iterable<*>) { 8 | TODO("Not yet implemented") 9 | } 10 | 11 | override fun dependsOn(vararg tables: Any): Task { 12 | TODO("Not yet implemented") 13 | } 14 | 15 | override fun compareTo(other: Task): Int { 16 | TODO("Not yet implemented") 17 | } 18 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/api/QueryTask.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.api 2 | 3 | import org.archguard.core.Project 4 | 5 | abstract class AbstractQueryTask() : Task { 6 | open lateinit var project: Project 7 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/api/Task.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.api 2 | 3 | interface Task : Comparable { 4 | var name: String 5 | var description: String 6 | var group: String 7 | var dependsOn: Set 8 | 9 | 10 | fun getInputs(): TaskInputs 11 | 12 | fun getOutputs(): TaskOutputs 13 | 14 | fun setDependsOn(dependsOnTasks: Iterable<*>) {} 15 | 16 | fun dependsOn(vararg tables: Any): Task { 17 | return this 18 | } 19 | 20 | // TODO: add some DAG, like before and after 21 | } 22 | 23 | interface TaskInputs { 24 | 25 | } 26 | 27 | interface TaskOutputs { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/api/TaskProvider.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.api 2 | 3 | import org.archguard.core.internal.Action 4 | 5 | interface TaskProvider { 6 | fun configure(action: Action) 7 | fun getName(): String 8 | } 9 | 10 | 11 | class TaskCreatingProvider : TaskProvider { 12 | private val name: String? = null 13 | 14 | override fun configure(action: Action) { 15 | } 16 | 17 | override fun getName(): String { 18 | return name ?: "" 19 | } 20 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/core/CacheableTask.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.core 2 | 3 | @MustBeDocumented 4 | @Retention(AnnotationRetention.RUNTIME) 5 | @Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS) 6 | annotation class CacheableTask -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/core/Incremental.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.core 2 | 3 | @MustBeDocumented 4 | @Retention(AnnotationRetention.RUNTIME) 5 | @Target( 6 | AnnotationTarget.FUNCTION, 7 | AnnotationTarget.PROPERTY_GETTER, 8 | AnnotationTarget.PROPERTY_SETTER, 9 | AnnotationTarget.FIELD 10 | ) 11 | annotation class Incremental -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/core/Input.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.core 2 | 3 | @MustBeDocumented 4 | @Retention(AnnotationRetention.RUNTIME) 5 | @Target( 6 | AnnotationTarget.FUNCTION, 7 | AnnotationTarget.PROPERTY_GETTER, 8 | AnnotationTarget.PROPERTY_SETTER, 9 | AnnotationTarget.FIELD 10 | ) 11 | annotation class Input -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/core/Intermediate.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.core 2 | 3 | /** 4 | * intermediate will create a new document/table/schema in the database 5 | */ 6 | @MustBeDocumented 7 | @Retention(AnnotationRetention.RUNTIME) 8 | @Target( 9 | AnnotationTarget.FUNCTION, 10 | AnnotationTarget.PROPERTY_GETTER, 11 | AnnotationTarget.PROPERTY_SETTER, 12 | AnnotationTarget.FIELD 13 | ) 14 | annotation class Intermediate(val name: String = "") 15 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/core/Output.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.core 2 | 3 | @MustBeDocumented 4 | @Retention(AnnotationRetention.RUNTIME) 5 | @Target( 6 | AnnotationTarget.FUNCTION, 7 | AnnotationTarget.PROPERTY_GETTER, 8 | AnnotationTarget.PROPERTY_SETTER, 9 | AnnotationTarget.FIELD 10 | ) 11 | annotation class Output -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/core/TaskAction.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.core 2 | 3 | @MustBeDocumented 4 | @Retention(AnnotationRetention.RUNTIME) 5 | @Target( 6 | AnnotationTarget.FUNCTION, 7 | AnnotationTarget.PROPERTY_GETTER, 8 | AnnotationTarget.PROPERTY_SETTER, 9 | AnnotationTarget.FIELD 10 | ) 11 | annotation class TaskAction -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/core/factory/DefaultTaskFactory.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.core.factory 2 | 3 | import org.archguard.codedb.automate.task.api.Task 4 | import org.archguard.codedb.automate.task.reflect.DirectInstantiator 5 | import kotlin.reflect.cast 6 | 7 | class DefaultTaskFactory : TaskFactory { 8 | private val instantiator = DirectInstantiator() 9 | 10 | override fun create(identity: TaskIdentity, constructorArgs: Array): S { 11 | val instance = instantiator.newInstanceByTypename(identity.type, *constructorArgs) 12 | return identity.type.cast(instance) 13 | } 14 | 15 | // todo: add process to get classInfo 16 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/core/factory/TaskFactory.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.core.factory 2 | 3 | import org.archguard.codedb.automate.task.api.Task 4 | 5 | interface TaskFactory { 6 | fun create(identity: TaskIdentity, constructorArgs: Array): S? 7 | } 8 | 9 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/core/factory/TaskIdentity.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.core.factory 2 | 3 | import org.archguard.core.Project 4 | import org.archguard.codedb.automate.task.api.Task 5 | import kotlin.reflect.KClass 6 | 7 | class TaskIdentity(val type: KClass, val name: String? = null, val project: Project? = null) { 8 | 9 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/execution/DefaultTaskState.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.execution 2 | 3 | class DefaultTaskState : TaskState { 4 | override fun getExecuted(): Boolean { 5 | TODO("Not yet implemented") 6 | } 7 | 8 | override fun getFailure(): Throwable? { 9 | TODO("Not yet implemented") 10 | } 11 | 12 | override fun rethrowFailure() { 13 | TODO("Not yet implemented") 14 | } 15 | 16 | override fun getDidWork(): Boolean { 17 | TODO("Not yet implemented") 18 | } 19 | 20 | override fun getSkipped(): Boolean { 21 | TODO("Not yet implemented") 22 | } 23 | 24 | override fun getSkipMessage(): String? { 25 | TODO("Not yet implemented") 26 | } 27 | 28 | override fun getUpToDate(): Boolean { 29 | TODO("Not yet implemented") 30 | } 31 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/execution/TaskExecuteResult.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.execution 2 | 3 | class TaskExecuteResult { 4 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/execution/TaskExecutionContext.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.execution 2 | 3 | class TaskExecutionContext { 4 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/execution/TaskExecutor.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.execution 2 | 3 | import org.archguard.codedb.automate.task.api.Task 4 | 5 | abstract class TaskExecutor { 6 | fun execute(task: Task, context: TaskExecutionContext): TaskExecuteResult { 7 | return TaskExecuteResult() 8 | } 9 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/execution/TaskState.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.execution 2 | 3 | interface TaskState { 4 | fun getExecuted(): Boolean 5 | 6 | fun getFailure(): Throwable? 7 | 8 | fun rethrowFailure() 9 | 10 | fun getDidWork(): Boolean 11 | 12 | fun getSkipped(): Boolean 13 | 14 | fun getSkipMessage(): String? 15 | 16 | fun getUpToDate(): Boolean 17 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/automate/task/reflect/DirectInstantiator.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task.reflect 2 | 3 | import org.archguard.codedb.automate.task.api.Task 4 | import kotlin.reflect.KClass 5 | import kotlin.reflect.full.primaryConstructor 6 | 7 | class DirectInstantiator { 8 | fun newInstanceByTypename(type: KClass, vararg parameters: Any?): T? { 9 | return doCreate(type, null, parameters) 10 | } 11 | 12 | 13 | // or maybe create a new class for it. 14 | private fun doCreate(type: KClass, nothing: Nothing?, parameters: Array): T? { 15 | 16 | 17 | if (parameters.isNotEmpty() && type.typeParameters.isNotEmpty()) { 18 | return type.primaryConstructor?.call(*parameters) 19 | } else { 20 | return type.primaryConstructor?.call() 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/computing/MathExt.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.computing 2 | 3 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/fitness/Fitness.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness 2 | 3 | class FitnessDeclaration(val name: String) { 4 | /** 5 | * a detail will should show the detail of report 6 | */ 7 | val detail: HashMap> = hashMapOf() 8 | } 9 | 10 | class Fitness(val value: Double) { 11 | 12 | } 13 | 14 | fun fitness(name: String, function: FitnessDeclaration.() -> Unit) { 15 | FitnessDeclaration(name).function() 16 | } 17 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/orchestration/dag/Dag.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.orchestration.dag 2 | 3 | class Dag { 4 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/orchestration/io/GitHandler.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.orchestration.io 2 | 3 | class GitHandler(val commandName: String, var source: String = "", var destination: String = "") { 4 | fun source(input: String): GitHandler { 5 | source = input 6 | return this 7 | } 8 | 9 | // todo: auto generate this 10 | fun target(output: String = ""): GitHandler { 11 | destination = output 12 | return this 13 | } 14 | 15 | fun execute() { 16 | println("git $commandName $source $destination") 17 | } 18 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/orchestration/io/HandlerType.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.orchestration.io 2 | 3 | import kotlin.reflect.KClass 4 | 5 | sealed class HandlerType { 6 | class Auto() : HandlerType() 7 | class Repo(val url: String) : HandlerType() { 8 | 9 | } 10 | 11 | class Http(val url: String, val method: HttpMethod, val data: Any) : HandlerType() { 12 | 13 | } 14 | 15 | class Database(val tableName: String) : HandlerType() { 16 | 17 | } 18 | 19 | class File(val fileName: String) : HandlerType() { 20 | 21 | } 22 | 23 | class Dir(val dirName: String) : HandlerType() { 24 | 25 | } 26 | 27 | class Custom(val handler: KClass<*>) : HandlerType() { 28 | 29 | } 30 | 31 | class Multiple(val handlerTypes: Array) : HandlerType() { 32 | 33 | } 34 | 35 | class Stdout: HandlerType() { 36 | 37 | } 38 | 39 | override fun toString(): String { 40 | return when (this) { 41 | is Auto -> "auto" 42 | is Repo -> "repo $url" 43 | is Http -> "http $method $url" 44 | is Database -> "database $tableName" 45 | is File -> "file $fileName" 46 | is Dir -> "dir $dirName" 47 | is Custom -> "custom" 48 | is Multiple -> "multiple $handlerTypes" 49 | is Stdout -> "stdout" 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/orchestration/io/HttpMethod.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.orchestration.io 2 | 3 | sealed class HttpMethod { 4 | object GET : HttpMethod() 5 | object POST : HttpMethod() 6 | object PUT : HttpMethod() 7 | object DELETE : HttpMethod() 8 | object PATCH : HttpMethod() 9 | object HEAD : HttpMethod() 10 | object OPTIONS : HttpMethod() 11 | object TRACE : HttpMethod() 12 | object CONNECT : HttpMethod() 13 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/orchestration/io/IOHandler.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.orchestration.io 2 | 3 | class IOHandler { 4 | constructor() 5 | 6 | fun database(tableName: String): Boolean { 7 | return true 8 | } 9 | 10 | fun file(fileName: String): Boolean { 11 | return true 12 | } 13 | 14 | // output type: dr 15 | fun dir(dirName: String): Boolean { 16 | return true 17 | } 18 | 19 | // todo: add streaming for http 20 | fun http(url: String, method: HttpMethod, data: Any): Boolean { 21 | return true 22 | } 23 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/pipeline/PipelineTask.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.pipeline 2 | 3 | import kotlinx.coroutines.channels.Channel 4 | import kotlinx.coroutines.coroutineScope 5 | import kotlinx.coroutines.launch 6 | import org.archguard.codedb.automate.task.core.Input 7 | 8 | // todo: add pipeline task 9 | class PipelineTask(val output: Channel,) { 10 | fun run() { 11 | println("Running PipelineTask") 12 | } 13 | 14 | @Input 15 | suspend fun input(src: Channel) = coroutineScope { 16 | launch { 17 | for (s in src) { 18 | // do something, then output it 19 | output.send(s) 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/querydsl/AstQuery.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.querydsl 2 | 3 | class AstQuery { 4 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/querydsl/DatabaseQuery.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.querydsl 2 | 3 | class DatabaseQuery { 4 | fun query() { 5 | println("Hello, world!") 6 | } 7 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/report/ConceptReport.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.report 2 | 3 | class ConceptReport { 4 | fun getByName() { 5 | println("ConceptReport.getByName") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/server/CodedbApplication.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.server 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration 5 | import org.springframework.boot.runApplication 6 | 7 | @SpringBootApplication(exclude = [MongoReactiveDataAutoConfiguration::class]) 8 | open class CodedbApplication 9 | 10 | fun main(args: Array) { 11 | runApplication(*args) 12 | } 13 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/server/MongoConfig.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.server 2 | 3 | import com.mongodb.reactivestreams.client.MongoClient 4 | import com.mongodb.reactivestreams.client.MongoClients 5 | import org.archguard.codedb.server.code.CodeRepository 6 | import org.springframework.context.annotation.Bean 7 | import org.springframework.context.annotation.Configuration 8 | import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory 9 | import org.springframework.data.mongodb.config.AbstractReactiveMongoConfiguration 10 | import org.springframework.data.mongodb.core.ReactiveMongoTemplate 11 | import org.springframework.data.mongodb.core.convert.MappingMongoConverter 12 | import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories 13 | 14 | 15 | @Configuration 16 | @EnableReactiveMongoRepositories( 17 | basePackageClasses = [CodeRepository::class] 18 | ) 19 | open class MongoConfig : AbstractReactiveMongoConfiguration() { 20 | 21 | override fun getDatabaseName() = "codedb" 22 | 23 | override fun reactiveMongoClient(): MongoClient = mongoClient() 24 | 25 | @Bean 26 | open fun mongoClient(): MongoClient = MongoClients.create() 27 | 28 | @Bean 29 | override fun reactiveMongoTemplate( 30 | databaseFactory: ReactiveMongoDatabaseFactory, 31 | mongoConverter: MappingMongoConverter 32 | ): ReactiveMongoTemplate = ReactiveMongoTemplate(mongoClient(), databaseName) 33 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/server/code/CodeRepository.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.server.code 2 | 3 | import org.archguard.codedb.server.code.domain.CodeDocument 4 | import org.springframework.data.mongodb.repository.ReactiveMongoRepository 5 | import reactor.core.publisher.Mono 6 | 7 | 8 | interface CodeRepository : ReactiveMongoRepository { 9 | fun deleteAllBySystemId(systemId: String): Mono 10 | } 11 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/server/code/ContainerRepository.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.server.code 2 | 3 | import org.archguard.codedb.server.code.domain.ContainerService 4 | import org.springframework.data.mongodb.repository.ReactiveMongoRepository 5 | import reactor.core.publisher.Mono 6 | 7 | 8 | interface ContainerRepository : ReactiveMongoRepository { 9 | fun deleteAllBySystemId(systemId: String): Mono 10 | } -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/server/code/domain/CodeDocument.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.server.code.domain; 2 | 3 | import chapi.domain.core.CodeDataStruct 4 | import org.springframework.data.annotation.Id 5 | import org.springframework.data.mongodb.core.mapping.Document 6 | 7 | @Document 8 | class CodeDocument( 9 | @Id 10 | val id: String, 11 | val systemId: String, 12 | val language: String, 13 | val path: String, 14 | // data_struct 15 | val ds: CodeDataStruct, 16 | val ds_package: String, 17 | val ds_node_name: String, 18 | val ds_file_path: String, 19 | ) 20 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/server/code/domain/ContainerService.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.server.code.domain 2 | 3 | import kotlinx.serialization.Serializable 4 | import org.springframework.data.annotation.Id 5 | import org.springframework.data.mongodb.core.mapping.Document 6 | 7 | @Serializable 8 | @Document 9 | data class ContainerService( 10 | @Id val id: String, 11 | val systemId: String, 12 | val language: String, 13 | val path: String, 14 | // component name, only if is a component 15 | var name: String = "", 16 | var demands: List = listOf(), 17 | var resources: List = listOf() 18 | ) 19 | 20 | @Serializable 21 | data class ContainerDemand( 22 | var source_caller: String = "", 23 | var call_routes: List = listOf(), 24 | var base: String = "", 25 | var target_url: String = "", 26 | var target_http_method: String = "", 27 | var call_data: String = "" 28 | ) 29 | 30 | @Serializable 31 | data class ContainerSupply( 32 | var sourceUrl: String = "", 33 | var sourceHttpMethod: String = "", 34 | var packageName: String = "", 35 | var className: String = "", 36 | var methodName: String = "" 37 | ) 38 | -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/server/code/dto/ContainerServiceDto.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.server.code.dto 2 | 3 | import kotlinx.serialization.Serializable 4 | import org.archguard.codedb.server.code.domain.ContainerDemand 5 | import org.archguard.codedb.server.code.domain.ContainerSupply 6 | 7 | @Serializable 8 | data class ContainerServiceDto( 9 | var name: String = "", 10 | var demands: List = listOf(), 11 | var resources: List = listOf() 12 | ) -------------------------------------------------------------------------------- /server/src/main/kotlin/org/archguard/codedb/server/hello/HelloController.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.server.hello 2 | 3 | import org.springframework.web.bind.annotation.GetMapping 4 | import org.springframework.web.bind.annotation.RestController 5 | 6 | @RestController 7 | class HelloController { 8 | @GetMapping("/hello") 9 | fun hello() = "Hello, world!" 10 | } -------------------------------------------------------------------------------- /server/src/main/resources/application-local.properties: -------------------------------------------------------------------------------- 1 | server.port=8084 2 | spring.application.name=Archguard CodeDB 3 | # Mongodb data source 4 | spring.data.mongodb.host=localhost 5 | spring.data.mongodb.port=27017 6 | spring.data.mongodb.database=codedb 7 | spring.data.mongodb.username= 8 | spring.data.mongodb.password= 9 | -------------------------------------------------------------------------------- /server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.profiles.active=local 2 | spring.codec.max-in-memory-size=20MB -------------------------------------------------------------------------------- /server/src/test/kotlin/org/archguard/codedb/automate/task/TaskContainerTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task 2 | 3 | import org.archguard.codedb.automate.builtin.LocTask 4 | import org.junit.jupiter.api.Disabled 5 | import org.junit.jupiter.api.Test 6 | 7 | internal class TaskContainerTest { 8 | 9 | @Test 10 | @Disabled 11 | fun `should register task`() { 12 | val taskContainer = TaskContainer() 13 | val task = taskContainer.create("Hello", LocTask::class) 14 | task.run() 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /server/src/test/kotlin/org/archguard/codedb/automate/task/TaskRunnerTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.automate.task 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | 6 | class TaskRunnerTest { 7 | @Test 8 | @Disabled 9 | fun `run LocTask`() { 10 | val runner = TaskRunner() 11 | val output = runner.run() 12 | println(output) 13 | } 14 | } -------------------------------------------------------------------------------- /server/src/test/kotlin/org/archguard/codedb/querydsl/DatabaseQueryTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.querydsl 2 | 3 | import org.junit.jupiter.api.Test 4 | 5 | class DatabaseQueryTest { 6 | @Test 7 | fun testQuery() { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /server/src/test/kotlin/org/archguard/codedb/server/CodedbApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.server 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.springframework.boot.test.context.SpringBootTest 5 | 6 | @SpringBootTest 7 | class CodedbApplicationTests { 8 | 9 | // @Test 10 | // fun contextLoads() { 11 | // } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | rootProject.name = "CodeDB" 4 | 5 | pluginManagement { 6 | repositories { 7 | gradlePluginPortal() 8 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") 9 | } 10 | } 11 | 12 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 13 | 14 | include(":server") 15 | 16 | // TODO: spike for core usage 17 | include(":core") 18 | 19 | include(":submodules:gitignore") 20 | include(":submodules:walkdir") 21 | 22 | include(":client:client-api") 23 | include(":client:codedb-cli") 24 | include(":client:codedb-clui") 25 | include(":client:codedb-gradle-plugin") 26 | 27 | // for server/cli/other usage 28 | include(":workflow-lib:factor") 29 | include(":workflow-lib:fitness-engine") 30 | include(":submodules:repl") 31 | 32 | include(":pipeline:runner") 33 | include(":pipeline:action-toolkit") 34 | 35 | include(":pipeline:checkout") 36 | include(":pipeline:coverage") 37 | include(":pipeline:oo-metric") 38 | 39 | -------------------------------------------------------------------------------- /submodules/README.md: -------------------------------------------------------------------------------- 1 | # Feeder Utils 2 | 3 | -------------------------------------------------------------------------------- /submodules/gitignore/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !../gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | **/bin 8 | -------------------------------------------------------------------------------- /submodules/gitignore/README.md: -------------------------------------------------------------------------------- 1 | # Gitignore 2 | 3 | default by PathMatcher -------------------------------------------------------------------------------- /submodules/gitignore/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | alias(libs.plugins.jvm) 4 | alias(libs.plugins.serialization) 5 | } 6 | 7 | dependencies { 8 | implementation(libs.coroutines.core) 9 | 10 | // Logging 11 | implementation(libs.logging.kotlin) 12 | 13 | testImplementation(libs.jimfs) 14 | testImplementation(libs.bundles.test) 15 | } 16 | -------------------------------------------------------------------------------- /submodules/gitignore/src/test/resources/ignore/.ignoretest: -------------------------------------------------------------------------------- 1 | # https://git-scm.com/docs/gitignore 2 | 3 | # A blank line matches no files, so it can serve as a separator for readability. 4 | 5 | # A line starting with # serves as a comment. 6 | # Put a backslash ("\") in front of the first hash for patterns that begin with a hash. 7 | # * 8 | 9 | # empty error where it resolves to nothing crash https://github.com/boyter/scc/issues/149 10 | / 11 | 12 | # Trailing spaces are ignored unless they are quoted with backslash ("\"). 13 | / 14 | 15 | # An optional prefix "!" which negates the pattern 16 | !* -------------------------------------------------------------------------------- /submodules/gitignore/src/test/resources/ignore/should_include: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archguard/codedb/4c1f6a57568affeaab7771e83eb0665e934110a5/submodules/gitignore/src/test/resources/ignore/should_include -------------------------------------------------------------------------------- /submodules/repl/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | alias(libs.plugins.jvm) 4 | alias(libs.plugins.serialization) 5 | } 6 | 7 | dependencies { 8 | implementation(libs.serialization.json) 9 | 10 | // Logging 11 | implementation(libs.logging.slf4j.api) 12 | implementation(libs.logging.logback.classic) 13 | 14 | // DSL 15 | implementation(libs.jupyter.api) 16 | implementation(libs.jupyter.kernel) 17 | implementation(libs.jupyter.shared.compiler) 18 | compileOnly(libs.kotlin.scriptingJvm) 19 | 20 | implementation(libs.archguard.dsl) { 21 | exclude(group = "org.jetbrains.kotlin", module = "kotlin-test-junit") 22 | } 23 | 24 | testImplementation(libs.bundles.test) 25 | } 26 | -------------------------------------------------------------------------------- /submodules/repl/src/test/kotlin/org/archguard/codedb/repl/KotlinReplWrapperTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.repl 2 | 3 | import io.kotest.matchers.shouldBe 4 | import org.junit.jupiter.api.Assertions.* 5 | import org.junit.jupiter.api.BeforeEach 6 | import org.junit.jupiter.api.Test 7 | 8 | class KotlinReplWrapperTest { 9 | private lateinit var compiler: KotlinReplWrapper 10 | 11 | @BeforeEach 12 | internal fun setUp() { 13 | this.compiler = KotlinReplWrapper() 14 | } 15 | 16 | @Test 17 | internal fun simple_eval() { 18 | compiler.eval("val x = 3") 19 | } 20 | 21 | @Test 22 | internal fun local_file() { 23 | compiler.eval( 24 | """%use archguard 25 | 26 | var layer = layered { 27 | prefixId("org.archguard") 28 | component("controller") dependentOn component("service") 29 | 组件("service") 依赖于 组件("repository") 30 | } 31 | """ 32 | ) 33 | 34 | val res = compiler.eval("layer.components().size") 35 | res.resultValue shouldBe 3 36 | 37 | val name = compiler.eval("layer.components()[0].name") 38 | name.resultValue shouldBe "controller" 39 | } 40 | } -------------------------------------------------------------------------------- /submodules/walkdir/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !../gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | **/bin 8 | -------------------------------------------------------------------------------- /submodules/walkdir/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | alias(libs.plugins.jvm) 4 | alias(libs.plugins.serialization) 5 | } 6 | 7 | dependencies { 8 | implementation(projects.core) 9 | 10 | implementation(libs.coroutines.core) 11 | implementation(libs.jgit) 12 | 13 | // Logging 14 | implementation(libs.logging.slf4j.api) 15 | implementation(libs.logging.logback.classic) 16 | 17 | testImplementation(libs.bundles.test) 18 | } 19 | -------------------------------------------------------------------------------- /submodules/walkdir/src/main/kotlin/org/archguard/codedb/Workdir.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb 2 | 3 | import java.nio.file.Path 4 | import kotlin.io.path.createTempDirectory 5 | 6 | class Workdir { 7 | fun dir(workdir: String): Path { 8 | val tempDir = createTempDirectory("archguard") 9 | return tempDir.resolve(workdir) 10 | } 11 | } -------------------------------------------------------------------------------- /submodules/walkdir/src/main/kotlin/org/archguard/codedb/git/GitCommand.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.git 2 | 3 | private const val DEFAULT_BRANCH = "master" 4 | 5 | -------------------------------------------------------------------------------- /submodules/walkdir/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | UTF-8 5 | 6 | %logger{36} %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /submodules/walkdir/src/test/kotlin/org/archguard/codedb/walkdir/GitDirectoryWalkerTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.walkdir 2 | 3 | import io.kotest.matchers.ints.shouldBeGreaterThan 4 | import io.kotest.matchers.ints.shouldBeLessThan 5 | import kotlinx.coroutines.channels.Channel 6 | import kotlinx.coroutines.launch 7 | import kotlinx.coroutines.runBlocking 8 | import org.junit.jupiter.api.BeforeEach 9 | import org.junit.jupiter.api.Test 10 | import java.io.File 11 | import java.nio.file.Paths 12 | 13 | class GitDirectoryWalkerTest { 14 | private lateinit var walker: GitDirectoryWalker 15 | 16 | @BeforeEach 17 | fun setUp() { 18 | val rootDir = Paths.get("").toAbsolutePath().parent.parent.toString() 19 | walker = GitDirectoryWalker(rootDir) 20 | } 21 | 22 | @Test 23 | fun testWalkWithChannel() { 24 | // TODO: replace with absolute path 25 | var count = 0 26 | val channel = Channel() 27 | runBlocking { 28 | launch { 29 | for (fileJob in channel) { 30 | count++ 31 | } 32 | } 33 | 34 | walker.start(channel) 35 | channel.close() 36 | } 37 | 38 | count shouldBeGreaterThan 100 39 | 40 | // if with `build/` directory, the count should be greater than 5000 41 | count shouldBeLessThan 5000 42 | } 43 | 44 | @Test 45 | fun testWalkWithList() { 46 | val files = walker.start() 47 | files.size shouldBeGreaterThan 100 48 | files.size shouldBeLessThan 5000 49 | } 50 | } -------------------------------------------------------------------------------- /submodules/walkdir/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | UTF-8 5 | 6 | %logger{36} %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /workflow-lib/README.md: -------------------------------------------------------------------------------- 1 | # Workflow -------------------------------------------------------------------------------- /workflow-lib/factor/README.md: -------------------------------------------------------------------------------- 1 | # Factor 2 | 3 | > Metric Factor is a metric for measuring the impact of a change on the codebase. 4 | 5 | Issues: 6 | 7 | - [ ] QueryDSL 需要使用 KAPT + JPA 进行转换以生成查询 DSL 8 | - [ ] Chapi 需要结合到 JPA 9 | 10 | ## Factor in Design 11 | 12 | | Evolution | Progress | Governance | Experience | DevOps | Quality | Productivity | 13 | |---------------|--------------------|------------|------------|----------------------|---------------|--------------| 14 | | Coupling | Tech Debt | Document | Developer | Change Failure Rate | Test Coverage | Tracing | 15 | | Hierarchy | Path to Production | Gate | User | Deployment Frequency | Code Smell | Performance | 16 | | Changeability | Linting | | | Lead Time For Change | | Cost | 17 | | Modifiability | Metric | | | Mean Time To Restore | | | 18 | 19 | ## Metric Matrix for Architecture Twin 20 | 21 | | Metric | Description | Formula | Example | 22 | |--------|---------------------------------------------------|--------------------------------------------|---------------------------| 23 | | Factor | The number of files that are affected by a change | `factor = (files changed) / (total files)` | `factor = 2 / 100 = 0.02` | 24 | 25 | ## Expression by Explain ? 26 | 27 | ```kotlin 28 | val coverage = "Changed Files" / "Total Files" 29 | ``` 30 | -------------------------------------------------------------------------------- /workflow-lib/factor/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | idea 4 | alias(libs.plugins.jvm) 5 | alias(libs.plugins.serialization) 6 | 7 | kotlin("kapt") 8 | } 9 | 10 | idea { 11 | module { 12 | val kaptMain = file("build/generated/source/kapt/main") 13 | sourceDirs.plusAssign(kaptMain) 14 | generatedSourceDirs.plusAssign(kaptMain) 15 | } 16 | } 17 | 18 | dependencies { 19 | implementation(libs.javax.persistence.api) 20 | // ksp for annotation processing 21 | kapt(libs.querydsl.apt.get().toString() + ":jpa") 22 | 23 | implementation(libs.querydsl.core) 24 | 25 | implementation(libs.datetime) 26 | 27 | implementation(libs.kotlin.reflect) 28 | implementation(libs.serialization.json) 29 | implementation(libs.coroutines.core) 30 | 31 | testImplementation(libs.bundles.test) 32 | } 33 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/Factor.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor 2 | 3 | interface Factor { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/JpaHelper.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor 2 | 3 | import java.util.* 4 | 5 | fun uuid() = UUID.randomUUID().toString() -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/Period.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor 2 | 3 | /** 4 | * A period is a time interval. 5 | */ 6 | enum class Period { 7 | HOUR, 8 | DAY, 9 | WEEK, 10 | MONTH, 11 | YEAR 12 | } 13 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/code/cloc/LanguageSummary.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.code.cloc 2 | 3 | import kotlinx.serialization.Serializable 4 | import javax.persistence.Entity 5 | import javax.persistence.Id 6 | 7 | @Serializable 8 | @Entity 9 | class LanguageSummary( 10 | @Id 11 | val id: String, 12 | var name: String = "", 13 | var bytes: Long = 0, 14 | var lines: Long = 0, 15 | var code: Long = 0, 16 | var comment: Long = 0, 17 | var blank: Long = 0, 18 | var complexity: Long = 0, 19 | var count: Long = 0 20 | ) { 21 | constructor() : this("") 22 | } 23 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/code/dependency/PackageDependency.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.code.dependency 2 | 3 | import kotlinx.serialization.Serializable 4 | import javax.persistence.Entity 5 | import javax.persistence.Id 6 | 7 | @Serializable 8 | @Entity 9 | data class PackageDependency( 10 | @Id 11 | val id: String, 12 | val name: String, 13 | val path: String, 14 | val version: String, 15 | val parentId: String, 16 | val packageManager: String, 17 | val depName: String, 18 | val depGroup: String, 19 | val depArtifact: String, 20 | val depMetadata: String = "", 21 | val depSource: String = "", 22 | val depScope: String, 23 | val depVersion: String 24 | ) { 25 | constructor() : this("", "", "", "", "", "", "", "", "", "", "", "", "") 26 | } 27 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/code/rest/ContainerResource.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.code.rest 2 | 3 | import kotlinx.serialization.Serializable 4 | import javax.persistence.Entity 5 | import javax.persistence.Id 6 | 7 | @Entity 8 | @Serializable 9 | class ContainerResource( 10 | @Id 11 | val id: String, 12 | val systemId: String, 13 | var sourceUrl: String, 14 | var originUrl: String = "", 15 | val sourceHttpMethod: String, 16 | val packageName: String, 17 | val className: String, 18 | val methodName: String 19 | ) { 20 | constructor() : this("", "", "", "", "", "", "", "") 21 | } 22 | 23 | @Entity 24 | @Serializable 25 | class ContainerDemand( 26 | @Id 27 | val id: String, 28 | val systemId: String, 29 | val sourcePackage: String, 30 | val sourceClass: String, 31 | val sourceMethod: String, 32 | var targetUrl: String, 33 | var originUrl: String = "", 34 | val targetHttpMethod: String, 35 | ) { 36 | constructor() : this("", "", "", "", "", "", "", "") 37 | } -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/code/scm/ScmChangeEntry.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.code.scm 2 | 3 | import kotlinx.serialization.Serializable 4 | import javax.persistence.Entity 5 | import javax.persistence.Id 6 | 7 | @Serializable 8 | @Entity 9 | class ScmChangeEntry( 10 | @Id 11 | val id: String, 12 | val oldPath: String, 13 | val newPath: String, 14 | val commitTime: Long, 15 | val cognitiveComplexity: Int, 16 | val changeMode: String, 17 | val commitId: String, 18 | val committer: String, 19 | val lineAdded: Int, 20 | val lineDeleted: Int 21 | ) { 22 | constructor() : this("", "", "", 0, 0, "", "", "", 0, 0) 23 | } -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/code/scm/ScmCommit.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.code.scm 2 | 3 | import kotlinx.serialization.Serializable 4 | import javax.persistence.Entity 5 | import javax.persistence.Id 6 | 7 | @Entity 8 | @Serializable 9 | class ScmCommit( 10 | @Id 11 | val id: String, 12 | val commitTime: Long, 13 | val shortMessage: String, 14 | val committerName: String, 15 | val committerEmail: String, 16 | val repositoryId: String, 17 | ) { 18 | constructor() : this("", 0, "", "", "", "") 19 | } 20 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/code/scm/ScmPathChangeCount.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.code.scm 2 | 3 | import kotlinx.serialization.Serializable 4 | import javax.persistence.Entity 5 | import javax.persistence.Id 6 | 7 | @Entity 8 | @Serializable 9 | class ScmPathChangeCount( 10 | @Id 11 | val id: String, 12 | val path: String, 13 | val changes: Int, 14 | val lineCount: Long, 15 | val language: String, 16 | ) { 17 | constructor() : this("", "", 0, 0, "") 18 | } 19 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/code/scm/SourceCodeManagement.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.scm 2 | 3 | abstract class SourceCodeManagement { 4 | abstract fun getCommitHistory(): List 5 | 6 | abstract fun getBranches(): List 7 | 8 | abstract fun getTags(): List 9 | 10 | abstract fun getCloc(): Cloc 11 | } 12 | 13 | // todo: merge with analyser_git 14 | class Cloc { 15 | val language: String = "" 16 | val blank: Int = 0 17 | val comment: Int = 0 18 | val code: Int = 0 19 | } 20 | 21 | class Tag { 22 | val name: String = "" 23 | val date: String = "" 24 | } 25 | 26 | class Branch { 27 | val name: String = "" 28 | val date: String = "" 29 | } 30 | 31 | class Commit { 32 | val author: String = "" 33 | val date: String = "" 34 | val message: String = "" 35 | } 36 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/devops/ChangeFailureRate.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.devops 2 | 3 | /** 4 | * The change failure rate is the ratio of failed changes to the total number of changes. 5 | */ 6 | class ChangeFailureRate: Metric() { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/devops/DeploymentFrequency.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.devops 2 | 3 | /** 4 | * The deployment frequency is the number of deployments per unit of time. 5 | */ 6 | class DeploymentFrequency { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/devops/LeadTimeForChange.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.devops 2 | 3 | /** 4 | * Lead time for change (LTC) is the time between when a change is made to the code and when that change is deployed to production. 5 | */ 6 | class LeadTimeForChange { 7 | 8 | } 9 | 10 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/devops/MeanTimeToRestore.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * MeanTimeToRestore is a metric that measures the time it takes to restore a service 3 | */ 4 | class MeanTimeToRestore { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/devops/Metric.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.devops 2 | 3 | import kotlinx.serialization.Serializable 4 | 5 | enum class LEVEL { 6 | ELITE, HIGH, MEDIUM, LOW, INVALID 7 | } 8 | 9 | @Serializable 10 | open class Metric( 11 | val value: Double = 0.0, 12 | val level: LEVEL = LEVEL.INVALID, 13 | val startTimestamp: Long = 0, 14 | val endTimestamp: Long = 0 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/experience/developer/TimeToFirstCommit.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.experience.developer 2 | 3 | /** 4 | * Time to first commit measures the time between the first commit and the first commit of the developer. 5 | */ 6 | class TimeToFirstCommit { 7 | 8 | } -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/experience/user/Functionality.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.experience.user 2 | 3 | /** 4 | * Functionality is a factor that measures how many features a software system has. 5 | */ 6 | class Functionality { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/experience/user/Usability.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.experience.user 2 | 3 | /** 4 | * Usability is a factor that measures how easy it is to use a software system. 5 | */ 6 | class Usability { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/governance/document/ArchitectureDocument.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.governance.document 2 | 3 | /** 4 | * An architecture document is a document that describes the architecture of a software system. 5 | */ 6 | class ArchitectureDocumentType { 7 | /** 8 | * Architecture Decision Record (ADR) is a lightweight document format for capturing architecture decisions. 9 | */ 10 | class ArchitectureDecisionRecord : DocumentType() 11 | } 12 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/governance/gate/QualityGate.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.governance.gate 2 | 3 | import org.archguard.codedb.factor.uuid 4 | import javax.persistence.Entity 5 | import javax.persistence.Id 6 | 7 | /** 8 | * QualityGate is a class that represents a quality gate. 9 | */ 10 | @Entity 11 | class QualityGate( 12 | @Id 13 | val id: String = uuid(), 14 | val name: String = "", 15 | val description: String = "", 16 | val value: Double = 0.0, 17 | ) { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/governance/linting/IssuePosition.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.governance.linting 2 | 3 | import kotlinx.serialization.Serializable 4 | import org.archguard.codedb.factor.uuid 5 | import javax.persistence.Column 6 | import javax.persistence.Entity 7 | import javax.persistence.Id 8 | import javax.persistence.MapKeyColumn 9 | 10 | @Serializable 11 | @Entity 12 | class IssuePosition( 13 | @Id 14 | val id: String = uuid(), 15 | var startLine: Int = 0, 16 | var startColumn: Int = 0, 17 | var endLine: Int = 0, 18 | var endColumn: Int = 0, 19 | 20 | @MapKeyColumn(name = "additions") 21 | @Column(name = "value") 22 | var additions: Map = mapOf(), 23 | ) { 24 | override fun toString(): String { 25 | return "IssuePosition(startLine=$startLine, startColumn=$startColumn, endLine=$endLine, endColumn=$endColumn, additions=$additions)" 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/governance/linting/Linting.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.governance.linting 2 | 3 | /** 4 | * Linting is the process of running a program that will analyse code for potential errors. 5 | */ 6 | class Linting { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/governance/metric/MetricDef.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.governance.metric 2 | 3 | import javax.persistence.* 4 | 5 | /** 6 | * Metric is a class that represents a metric. 7 | * - Metric Label is a label of a metric. 8 | * - Metric Name is a unique name of a metric. 9 | * - Metric Definition is a description of the metric. 10 | * 11 | * for examples: 12 | * 13 | * | Label | Metric Name | Definition | 14 | * |-------|----------------------|-----------------------------------------------------------------------------------------------| 15 | * | LOC | Lines of Code | The number of lines of code of an operation or of a class, including blank lines and comments.| 16 | * | CYCLO | Cyclomatic Complexity| The maximum number of linearly independent paths in a method. | 17 | * 18 | */ 19 | @Entity 20 | class MetricDef( 21 | @Id 22 | @GeneratedValue(strategy = GenerationType.IDENTITY) 23 | var id: Long? = null, 24 | val name: String = "", 25 | val label: String = "", 26 | val definition: String = "" 27 | ) { 28 | 29 | } 30 | 31 | /** 32 | * Metric Value is a class that represents a metric value. 33 | */ 34 | class MetricValue( 35 | val name: String, 36 | val value: Double 37 | ) 38 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/governance/smell/Smell.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.governance.smell 2 | 3 | /** 4 | * A smell is a code smell. 5 | */ 6 | class Smell { 7 | } -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/meta/Level.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.meta 2 | 3 | enum class Level { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/meta/Todo.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.meta 2 | 3 | import org.archguard.codedb.factor.meta.model.DeadlineItem 4 | import javax.persistence.MappedSuperclass 5 | 6 | /** 7 | * A TODO means an item had :name, :description, :level, :deadline, :assignee, :status, :created_at, :updated_at ? 8 | */ 9 | @MappedSuperclass 10 | open class Todo ( 11 | val name: String = "", 12 | val description: String = "", 13 | ) : DeadlineItem() { 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/meta/model/DeadlineItem.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.meta.model 2 | 3 | import kotlinx.datetime.* 4 | import javax.persistence.Column 5 | import javax.persistence.MappedSuperclass 6 | 7 | /** 8 | * A deadline item has start date, end date, and duration. 9 | */ 10 | @MappedSuperclass 11 | open class DeadlineItem( 12 | @Column(columnDefinition = "TIMESTAMP") 13 | val startDate: LocalDateTime = Clock.System.now().toLocalDateTime(TimeZone.UTC), 14 | val endDate: LocalDateTime? = null 15 | ) { 16 | 17 | } -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/progress/CodeReview.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.progress 2 | 3 | class CodeReview { 4 | } -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/progress/TechnicalDebt.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.progress 2 | 3 | import org.archguard.codedb.factor.meta.Todo 4 | import java.util.UUID 5 | import javax.persistence.Entity 6 | import javax.persistence.Id 7 | import javax.persistence.MappedSuperclass 8 | 9 | @Entity 10 | @MappedSuperclass 11 | class TechnicalDebt( 12 | @Id 13 | val id: String = UUID.randomUUID().toString(), 14 | ) : Todo() { 15 | } -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/tracing/DynamicTracing.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.tracing 2 | 3 | /** 4 | * Dynamic tracing is for tracing the code at runtime, such as OpenTelemetry, Zipkin, etc. 5 | */ 6 | class DynamicTracing { 7 | 8 | } -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/tracing/ManualTracing.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.tracing 2 | 3 | /** 4 | * Other tracing methods can be added here. 5 | */ 6 | class ManualTracing : Tracing { 7 | 8 | } -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/tracing/StaticTracing.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.tracing 2 | 3 | /** 4 | * Static tracing is for tracing the code by static code analysis. 5 | * todo: thinking in compile time tracing. 6 | */ 7 | class StaticTracing { 8 | 9 | } 10 | 11 | -------------------------------------------------------------------------------- /workflow-lib/factor/src/main/kotlin/org/archguard/codedb/factor/tracing/Tracing.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.factor.tracing 2 | 3 | /** 4 | * Metrics Data Model: https://opentelemetry.io/docs/reference/specification/metrics/data-model/ 5 | * - Metric name 6 | * - Attributes (dimensions) 7 | * - Value type of the point (integer, floating point, etc) 8 | * - Unit of measurement 9 | */ 10 | interface Tracing { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | alias(libs.plugins.jvm) 4 | alias(libs.plugins.serialization) 5 | } 6 | 7 | dependencies { 8 | implementation(libs.kotlin.stdlib) 9 | 10 | testImplementation(libs.bundles.test) 11 | testRuntimeOnly(libs.test.junit.engine) 12 | } 13 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/core/CalculateEngine.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.core 2 | 3 | 4 | /** 5 | * eval by expression 6 | */ 7 | interface CalculateEngine { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/core/Level.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.core 2 | 3 | import java.io.Serializable 4 | 5 | /** 6 | * Sonar refs: https://docs.sonarqube.org/latest/user-guide/metric-definitions/ 7 | */ 8 | enum class Level { 9 | A, 10 | B, 11 | C, 12 | D, 13 | E, 14 | F, 15 | } 16 | 17 | interface Metric { 18 | fun name(): String 19 | 20 | fun valueType(): Class 21 | 22 | fun level(): Level 23 | } 24 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/compliance/Compliance.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.compliance 2 | 3 | /** 4 | * how to use gdpr? 5 | */ 6 | abstract class Compliance { 7 | 8 | } 9 | 10 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/deployment/Deployment.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.deployment 2 | 3 | abstract class Deployment { 4 | /** 5 | * deployment failure rate 6 | */ 7 | abstract fun errorRate(): Double 8 | } 9 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/document/Document.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.document 2 | 3 | class Document { 4 | companion object { 5 | /** 6 | * List of readme file names 7 | */ 8 | val README_RULES: List = listOf( 9 | "README", 10 | "README.md", 11 | "README.txt", 12 | "README.rst", 13 | "README.html", 14 | "README.htm", 15 | "README.adoc", 16 | "README.asciidoc", 17 | "README.asc", 18 | "README.org", 19 | "README.mkd", 20 | "README.markdown", 21 | "README.mdtext", 22 | "README.mdown", 23 | "README.rst.txt", 24 | "readme", 25 | "readme.md", 26 | "readme.txt", 27 | "readme.rst", 28 | "readme.html", 29 | "readme.htm", 30 | "readme.adoc", 31 | "readme.asciidoc", 32 | "readme.asc", 33 | "readme.org", 34 | "readme.mkd", 35 | "readme.markdown", 36 | "readme.mdtext", 37 | "readme.mdtxt", 38 | "readme.mdtext.txt", 39 | "readme.mdown", 40 | "readme.rst.txt" 41 | ) 42 | } 43 | } -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/document/DocumentCode.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.document 2 | 3 | abstract class DocumentCode { 4 | /** 5 | * @return true if the code has a readme file 6 | */ 7 | abstract fun hasReadmeFile(): Boolean 8 | 9 | /** 10 | * has architecture decision record 11 | */ 12 | abstract fun hasDecisionRecord(): Boolean 13 | } 14 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/operability/Operability.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.operability 2 | 3 | /** 4 | * cloud-native operability 5 | */ 6 | abstract class Operability { 7 | 8 | } 9 | 10 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/quality/QualityCode.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.quality 2 | 3 | /** 4 | * quality API 5 | */ 6 | abstract class QualityCode { 7 | /** 8 | * @return the quality of the code base 9 | */ 10 | abstract fun testCoverage(): Double 11 | 12 | /** 13 | * get from SonarQube or others.. 14 | */ 15 | abstract fun maintainability(): Double 16 | } 17 | 18 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/security/Security.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.security 2 | 3 | interface Security { 4 | } -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/security/SecurityCode.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.security 2 | 3 | abstract class SecurityCode: Security { 4 | /** 5 | * security code 6 | */ 7 | abstract fun owaspTopTenNumber(): Int 8 | 9 | abstract fun hasSecretsInCodeBase(): Boolean 10 | } 11 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/security/SecurityContainer.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.security 2 | 3 | abstract class SecurityContainer: Security { 4 | abstract fun cvesNumber(): Boolean 5 | } 6 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/security/SecurityLibrary.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.security 2 | 3 | abstract class SecurityLibrary : Security { 4 | abstract fun cvesNumber(): Boolean 5 | } 6 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/main/kotlin/org/archguard/codedb/fitness/slice/service/WebService.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness.slice.service 2 | 3 | /** 4 | * include web service 5 | */ 6 | abstract class WebService { 7 | /** 8 | * like SkyWalking, NewRelic or others. 9 | */ 10 | fun hasMetrics(): Boolean { 11 | return false 12 | } 13 | 14 | /** 15 | * use some framework, like Prometheus 16 | */ 17 | fun hasAlerts(): Boolean { 18 | return false 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /workflow-lib/fitness-engine/src/test/kotlin/org/archguard/codedb/fitness/FitnessDemoTest.kt: -------------------------------------------------------------------------------- 1 | package org.archguard.codedb.fitness 2 | 3 | import io.kotest.matchers.shouldBe 4 | import org.archguard.codedb.fitness.slice.document.DocumentCode 5 | import org.junit.jupiter.api.Test 6 | 7 | class FitnessDemoTest { 8 | @Test 9 | fun test() { 10 | val documentCode = object : DocumentCode() { 11 | override fun hasReadmeFile(): Boolean { 12 | return true 13 | } 14 | 15 | override fun hasDecisionRecord(): Boolean { 16 | return true 17 | } 18 | } 19 | 20 | documentCode.hasReadmeFile() shouldBe true 21 | } 22 | 23 | 24 | } 25 | --------------------------------------------------------------------------------