Skip to content

Commit

Permalink
add-check-descriptions-phase-2 (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven Harrison authored Nov 9, 2023
1 parent 909d77e commit 0a87e36
Show file tree
Hide file tree
Showing 15 changed files with 620 additions and 594 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: true
matrix:
go: ['1.21.1']
go: ['1.21.4']
os:
- ubuntu-latest
- windows-latest
Expand All @@ -23,7 +23,7 @@ jobs:
name: ${{ matrix.go }} on ${{ matrix.os }}
steps:

- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fetch-depth: 0 # See: https://goreleaser.com/ci/actions/

- name: Set up Go 1.21
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "1.21"
id: go
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Go get dependecies and build ###
FROM golang:1.21.1 as builder
FROM golang:1.21.4 as builder
ENV PLATFORM docker
WORKDIR /go/src/app
COPY go.mod go.sum ./
Expand Down
4 changes: 2 additions & 2 deletions checker/check-api-operation-id-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestOperationIdRemoved(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIOperationIdUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "api-operation-id-removed",
Id: checker.APIOperationIdRemovedId,
Text: "api operation id 'createOneGroup' removed and replaced with ''",
Comment: "",
Level: checker.INFO,
Expand All @@ -47,7 +47,7 @@ func TestOperationIdUpdated(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIOperationIdUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "api-operation-id-removed",
Id: checker.APIOperationIdRemovedId,
Text: "api operation id 'createOneGroup' removed and replaced with 'newOperationId'",
Comment: "",
Level: checker.INFO,
Expand Down
6 changes: 3 additions & 3 deletions checker/check-components-security-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestComponentSecurityOauthURLUpdated(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ComponentChange{
Id: "api-security-component-oauth-url-changed",
Id: checker.APIComponentsSecurityComponentOauthUrlUpdatedId,
Text: "the component security scheme 'petstore_auth' oauth url changed from 'http://example.org/api/oauth/dialog' to 'http://example.new.org/api/oauth/dialog'",
Comment: "",
Level: checker.INFO,
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestComponentSecurityAdded(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ComponentChange{
Id: "api-security-component-added",
Id: checker.APIComponentsSecurityAddedId,
Text: "the component security scheme 'BasicAuth' was added",
Comment: "",
Level: checker.INFO,
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestComponentSecurityOauthScopeAdded(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ComponentChange{
Id: "api-security-component-oauth-scope-added",
Id: checker.APIComponentSecurityOauthScopeAddedId,
Text: "the component security scheme 'petstore_auth' oauth scope 'admin:pets' was added",
Comment: "",
Level: checker.INFO,
Expand Down
16 changes: 8 additions & 8 deletions checker/checker_breaking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestBreaking_DeletedOp(t *testing.T) {
errs := checker.CheckBackwardCompatibility(checker.GetDefaultChecks(), d, osm)
require.NotEmpty(t, errs)
require.Len(t, errs, 1)
require.Equal(t, "api-removed-without-deprecation", errs[0].GetId())
require.Equal(t, checker.APIRemovedWithoutDeprecationId, errs[0].GetId())
}

// BC: adding a required request body is breaking
Expand All @@ -76,7 +76,7 @@ func TestBreaking_AddingRequiredRequestBody(t *testing.T) {
errs := checker.CheckBackwardCompatibility(checker.GetDefaultChecks(), d, osm)
require.NotEmpty(t, errs)
require.Len(t, errs, 1)
require.Equal(t, "added-required-request-body", errs[0].GetId())
require.Equal(t, checker.AddedRequiredRequestBodyId, errs[0].GetId())
}

// BC: changing an existing request body from optional to required is breaking
Expand Down Expand Up @@ -289,14 +289,14 @@ func TestBreaking_OperationIdRemoved(t *testing.T) {
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), &s1, &s2)
require.NoError(t, err)

errs := checker.CheckBackwardCompatibility(checker.GetChecks(utils.StringList{"api-operation-id-removed"}), d, osm)
errs := checker.CheckBackwardCompatibility(checker.GetChecks(utils.StringList{checker.APIOperationIdRemovedId}), d, osm)
for _, err := range errs {
require.Equal(t, checker.ERR, err.GetLevel())
}
require.NotEmpty(t, errs)
require.Len(t, errs, 1)
require.Equal(t, "api-operation-id-removed", errs[0].GetId())
verifyNonBreakingChangeIsChangelogEntry(t, d, osm, "api-operation-id-removed")
require.Equal(t, checker.APIOperationIdRemovedId, errs[0].GetId())
verifyNonBreakingChangeIsChangelogEntry(t, d, osm, checker.APIOperationIdRemovedId)
}

// BC: removing/updating an enum in request body is breaking (optional)
Expand Down Expand Up @@ -620,15 +620,15 @@ func TestBreaking_SchemaRemoved(t *testing.T) {

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), &s1, &s2)
require.NoError(t, err)
checks := checker.GetChecks(utils.StringList{"api-schema-removed"})
checks := checker.GetChecks(utils.StringList{checker.APISchemasRemovedId})
errs := checker.CheckBackwardCompatibility(checks, d, osm)
for _, err := range errs {
require.Equal(t, checker.ERR, err.GetLevel())
}
require.NotEmpty(t, errs)
require.Equal(t, "api-schema-removed", errs[0].GetId())
require.Equal(t, checker.APISchemasRemovedId, errs[0].GetId())
require.Equal(t, "removed the schema 'network-policies'", errs[0].GetText())
require.Equal(t, "api-schema-removed", errs[1].GetId())
require.Equal(t, checker.APISchemasRemovedId, errs[1].GetId())
require.Equal(t, "removed the schema 'rules'", errs[1].GetText())
}

Expand Down
18 changes: 9 additions & 9 deletions checker/checker_deprecation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestBreaking_RemoveBeforeSunset(t *testing.T) {
errs := checker.CheckBackwardCompatibility(singleCheckConfig(checker.APIRemovedCheck), d, osm)
require.NotEmpty(t, errs)
require.Len(t, errs, 1)
require.Equal(t, "api-removed-before-sunset", errs[0].GetId())
require.Equal(t, checker.APIRemovedBeforeSunsetId, errs[0].GetId())
}

// BC: deleting an operation without sunset date is breaking
Expand All @@ -62,7 +62,7 @@ func TestBreaking_DeprecationNoSunset(t *testing.T) {
require.NoError(t, err)
require.NotEmpty(t, errs)
require.Len(t, errs, 1)
require.Equal(t, "api-path-sunset-parse", errs[0].GetId())
require.Equal(t, checker.APIPathSunsetParseId, errs[0].GetId())
}

// BC: deleting an operation after sunset date is not breaking
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestBreaking_DeprecationWithoutSunset(t *testing.T) {
errs := checker.CheckBackwardCompatibility(c, d, osm)
require.NotEmpty(t, errs)
require.Len(t, errs, 1)
require.Equal(t, "api-deprecated-sunset-parse", errs[0].GetId())
require.Equal(t, checker.APIDeprecatedSunsetParseId, errs[0].GetId())
}

// BC: deprecating an operation without a deprecation policy and without specifying sunset date is not breaking
Expand Down Expand Up @@ -147,8 +147,8 @@ func TestBreaking_RemovedPathForAlphaBreaking(t *testing.T) {
require.NoError(t, err)
errs := checker.CheckBackwardCompatibility(singleCheckConfig(checker.APIRemovedCheck), d, osm)
require.Len(t, errs, 2)
require.Equal(t, errs[0].GetId(), "api-path-removed-without-deprecation")
require.Equal(t, errs[1].GetId(), "api-path-removed-without-deprecation")
require.Equal(t, errs[0].GetId(), checker.APIPathRemovedWithoutDeprecationId)
require.Equal(t, errs[1].GetId(), checker.APIPathRemovedWithoutDeprecationId)
}

// BC: deprecating an operation without a deprecation policy and without specifying sunset date is not breaking for draft level
Expand Down Expand Up @@ -203,8 +203,8 @@ func TestBreaking_RemovedPathForDraftBreaking(t *testing.T) {
require.NoError(t, err)
errs := checker.CheckBackwardCompatibility(singleCheckConfig(checker.APIRemovedCheck), d, osm)
require.Len(t, errs, 2)
require.Equal(t, errs[0].GetId(), "api-path-removed-without-deprecation")
require.Equal(t, errs[1].GetId(), "api-path-removed-without-deprecation")
require.Equal(t, errs[0].GetId(), checker.APIPathRemovedWithoutDeprecationId)
require.Equal(t, errs[1].GetId(), checker.APIPathRemovedWithoutDeprecationId)
}

func toJson(t *testing.T, value string) json.RawMessage {
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestBreaking_DeprecationPathMixed(t *testing.T) {
errs := checker.CheckBackwardCompatibility(singleCheckConfig(checker.APIRemovedCheck), d, osm)
require.NotEmpty(t, errs)
require.Len(t, errs, 1)
require.Equal(t, "api-path-removed-before-sunset", errs[0].GetId())
require.Equal(t, checker.APIPathRemovedBeforeSunsetId, errs[0].GetId())
}

// BC: deleting sunset header for a deprecated endpoint is breaking
Expand Down Expand Up @@ -317,7 +317,7 @@ func TestBreaking_DeprecationPathMixed_RFC3339_Sunset(t *testing.T) {
errs := checker.CheckBackwardCompatibility(singleCheckConfig(checker.APIRemovedCheck), d, osm)
require.NotEmpty(t, errs)
require.Len(t, errs, 1)
require.Equal(t, "api-path-removed-before-sunset", errs[0].GetId())
require.Equal(t, checker.APIPathRemovedBeforeSunsetId, errs[0].GetId())
}

// CL: path operations that became deprecated
Expand Down
6 changes: 3 additions & 3 deletions checker/checker_not_breaking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func TestBreaking_DeletedTag(t *testing.T) {
require.Len(t, r, 6)
require.Equal(t, "response-body-type-changed", r[0].GetId())
require.Equal(t, "response-success-status-removed", r[1].GetId())
require.Equal(t, "api-path-removed-without-deprecation", r[2].GetId())
require.Equal(t, "api-path-removed-without-deprecation", r[3].GetId())
require.Equal(t, checker.APIPathRemovedWithoutDeprecationId, r[2].GetId())
require.Equal(t, checker.APIPathRemovedWithoutDeprecationId, r[3].GetId())
require.Equal(t, "optional-response-header-removed", r[4].GetId())
require.Equal(t, "request-parameter-removed", r[5].GetId())
}
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestBreaking_OperationIdAdded(t *testing.T) {

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), &s1, &s2)
require.NoError(t, err)
verifyNonBreakingChangeIsChangelogEntry(t, d, osm, "api-operation-id-added")
verifyNonBreakingChangeIsChangelogEntry(t, d, osm, checker.APIOperationIdAddId)
}

// BC: adding a required property to response is not breaking
Expand Down
2 changes: 1 addition & 1 deletion checker/ignore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestIgnoreComponent(t *testing.T) {

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), &s1, &s2)
require.NoError(t, err)
errs := checker.CheckBackwardCompatibility(checker.GetChecks(utils.StringList{"api-schema-removed"}), d, osm)
errs := checker.CheckBackwardCompatibility(checker.GetChecks(utils.StringList{checker.APISchemasRemovedId}), d, osm)
require.Equal(t, 8, len(errs))

errs, err = checker.ProcessIgnoredBackwardCompatibilityErrors(checker.ERR, errs, "../data/ignore-err-example.txt")
Expand Down
Loading

0 comments on commit 0a87e36

Please sign in to comment.