Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triangulate Example Commands #1357

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e03d75a
Add support for --base-branch in backward-compatibility-check command
yogeshnikam671 Aug 14, 2024
a7bfa42
Add support for --target-path argument in BackwardCompatibilityCheckC…
yogeshnikam671 Aug 15, 2024
8c7c110
Move the function to find referred spec files within BCC base class s…
yogeshnikam671 Aug 15, 2024
3ba68cb
Filter only the specs that have changed using targetPath in BackwardC…
yogeshnikam671 Aug 21, 2024
766f9fc
Fix the logs in backwardCompatibilityCheckCommand
yogeshnikam671 Aug 21, 2024
04c82dd
Bring back the existing backwardCompatibilityCheck command
yogeshnikam671 Aug 26, 2024
827a305
Update the import statement for exitWithMessage in BackwardCompatibil…
yogeshnikam671 Oct 7, 2024
5d82fd6
Refactor the logging logic of changed files
yogeshnikam671 Oct 10, 2024
6f1da35
Add a shutdown hook in backward compatibility check command which wil…
yogeshnikam671 Oct 10, 2024
768ac8e
Improve logging of backward compatibility report
yogeshnikam671 Oct 10, 2024
4a4ab17
Add ability to disable and enable info logging in LogStrategy to avoi…
yogeshnikam671 Oct 10, 2024
eff9834
Change scope getSpecsReferringTo method from internal to open to enab…
yogeshnikam671 Oct 10, 2024
67bc469
Make exitWithMessage method append and prepend newLine to the message
yogeshnikam671 Oct 11, 2024
a90557d
Rename getFileInTheBaseBranch to getFileInBranch
yogeshnikam671 Oct 11, 2024
3a560bf
Staged files should be considered during the backward compatibility c…
yogeshnikam671 Oct 11, 2024
37c001d
Update the description for the argument --target-path in backward-com…
yogeshnikam671 Oct 14, 2024
0a8dd21
Add tests for getFilesChangedInCurrentBranch function
yogeshnikam671 Oct 14, 2024
9b37ba7
Fix the failing test around git command
yogeshnikam671 Oct 14, 2024
c333ac6
Create abstract class ExamplesBaseCommand.
StarKhan6368 Sep 27, 2024
221b8c6
WIP Commit, Major Refactor For Examples Parity
StarKhan6368 Oct 3, 2024
c1178dc
Fix testRowExample method in interactive html js
StarKhan6368 Oct 3, 2024
dc7d1c7
CSS and JS alert fixes and improvements.
StarKhan6368 Oct 3, 2024
c0eb051
Revamp Example Parity architecture.
StarKhan6368 Oct 7, 2024
bc4e73e
Architecture Refactor and merge fixes.
StarKhan6368 Oct 8, 2024
a6200eb
Add tests OpenApi Examples Generate and Validate.
StarKhan6368 Oct 8, 2024
eaa05af
Fix logger based on verbosity on command execution
StarKhan6368 Oct 9, 2024
c3d2448
Minor refactor, update command descriptions
StarKhan6368 Oct 9, 2024
f567aa3
Examples Testing cleanup, minor refactorings.
StarKhan6368 Oct 10, 2024
2c2589f
Implement inline examples validation.
StarKhan6368 Oct 10, 2024
807c8b6
Refactor interactive example testing, better logs.
StarKhan6368 Oct 10, 2024
3d84087
Minor refactors, code cleanups, improvements.
StarKhan6368 Oct 11, 2024
5da5e51
Major Refactoring, moved InteractiveSever to core
StarKhan6368 Oct 11, 2024
08a7fe9
refactor use Kotlin.Result whenever possible.
StarKhan6368 Oct 11, 2024
9faf8a7
make contentType available in openapi interactive.
StarKhan6368 Oct 14, 2024
d447758
Fix bug causing example test to run twice.
StarKhan6368 Oct 14, 2024
0622ab0
modify logic for creating test from example file.
StarKhan6368 Oct 16, 2024
3b229f1
Merge branch 'main' into example_parity
StarKhan6368 Oct 16, 2024
01c1e36
Add tests for OpenApiExamplesInteractive.
StarKhan6368 Oct 16, 2024
f72df86
Implement Ability to load multiple existing exs.
StarKhan6368 Oct 17, 2024
f6affbd
[WIP] Major JS refactor, ability to gen multi exs.
StarKhan6368 Oct 18, 2024
2aa4f75
Remove multi generate flag, ui ux changes.
StarKhan6368 Oct 19, 2024
a739125
Remove http prefix from fetch calls in JS.
StarKhan6368 Oct 19, 2024
411f122
Fix - Unique file names issue on generations.
StarKhan6368 Oct 21, 2024
a73b85e
Rename counter in ExamplesGenerationStrategy.
StarKhan6368 Oct 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ dependencies {
implementation(project(':junit5-support'))

implementation "io.ktor:ktor-client-cio:$ktor_version"
implementation "io.ktor:ktor-server-core:$ktor_version"
implementation 'io.swagger.parser.v3:swagger-parser:2.1.22'

implementation "org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.6.3"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package application

import application.BackwardCompatibilityCheckCommand.CompatibilityResult.*
import application.BackwardCompatibilityCheckCommand.CompatibilityResult.FAILED
import application.BackwardCompatibilityCheckCommand.CompatibilityResult.PASSED
import io.specmatic.conversions.OpenApiSpecification
import io.specmatic.core.*
import io.specmatic.core.CONTRACT_EXTENSION
import io.specmatic.core.CONTRACT_EXTENSIONS
import io.specmatic.core.Feature
import io.specmatic.core.WSDL
import io.specmatic.core.git.GitCommand
import io.specmatic.core.git.SystemGit
import io.specmatic.core.log.logger
import io.specmatic.core.testBackwardCompatibility
import io.specmatic.stub.isOpenAPI
import org.springframework.stereotype.Component
import picocli.CommandLine.Command
Expand All @@ -26,7 +31,12 @@ const val TWO_INDENTS = "${ONE_INDENT}${ONE_INDENT}"
@Command(
name = "backwardCompatibilityCheck",
mixinStandardHelpOptions = true,
description = ["Checks backward compatibility of a directory across the current HEAD and the main branch"]
description = [
"""
Checks backward compatibility of a directory across the current HEAD and the main branch.
DEPRECATED: This command will be removed in the next major release. Use 'backward-compatibility-check' command instead.
"""
]
)
class BackwardCompatibilityCheckCommand(
private val gitCommand: GitCommand = SystemGit(),
Expand Down Expand Up @@ -149,7 +159,11 @@ class BackwardCompatibilityCheckCommand(
// newer => the file with changes on the branch
val (newer, unusedExamples) = OpenApiSpecification.fromFile(specFilePath).toFeature().loadExternalisedExamplesAndListUnloadableExamples()

val olderFile = gitCommand.getFileInTheDefaultBranch(specFilePath, treeishWithChanges)
val olderFile = gitCommand.getFileInBranch(
specFilePath,
treeishWithChanges,
gitCommand.defaultBranch()
)
if (olderFile == null) {
println("$specFilePath is a new file.$newLine")
return@mapIndexed PASSED
Expand Down Expand Up @@ -289,7 +303,9 @@ class BackwardCompatibilityCheckCommand(
}

private fun getOpenAPISpecFilesChangedInCurrentBranch(): Set<String> {
return gitCommand.getFilesChangeInCurrentBranch().filter {
return gitCommand.getFilesChangedInCurrentBranch(
gitCommand.defaultBranch()
).filter {
File(it).exists() && File(it).isOpenApiSpec()
}.toSet()
}
Expand Down
7 changes: 6 additions & 1 deletion application/src/main/kotlin/application/CompareCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import kotlin.system.exitProcess

@Command(name = "compare",
mixinStandardHelpOptions = true,
description = ["Checks if two contracts are equivalent"])
description = [
"""
Checks if two contracts are equivalent.
DEPRECATED: This command will be removed in the next major release. Use 'backward-compatibility-check' command instead.
"""
])
class CompareCommand : Callable<Unit> {
@Parameters(index = "0", description = ["Older contract file path"])
lateinit var olderContractFilePath: String
Expand Down
7 changes: 6 additions & 1 deletion application/src/main/kotlin/application/CompatibleCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ class GitCompatibleCommand : Callable<Int> {

@Command(name = "compatible",
mixinStandardHelpOptions = true,
description = ["Checks if the newer contract is backward compatible with the older one"],
description = [
"""
Checks if the newer contract is backward compatible with the older one
DEPRECATED: This command will be removed in the next major release. Use 'backward-compatibility-check' command instead.
"""
],
subcommands = [ GitCompatibleCommand::class ])
internal class CompatibleCommand : Callable<Unit> {
override fun call() {
Expand Down
8 changes: 7 additions & 1 deletion application/src/main/kotlin/application/DifferenceCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import kotlin.system.exitProcess

@Command(name = "similar",
mixinStandardHelpOptions = true,
description = ["Show the difference between two contracts"])
description = [
"""
Show the difference between two contracts.
DEPRECATED: This command will be removed in the next major release. Use 'backward-compatibility-check' command instead.
"""
]
)
class DifferenceCommand : Callable<Unit> {
@Parameters(index = "0", description = ["Older contract file path"])
lateinit var olderContractFilePath: String
Expand Down
289 changes: 0 additions & 289 deletions application/src/main/kotlin/application/ExamplesCommand.kt

This file was deleted.

Loading