From 72ffe5bde220c2394aa8a417149db8d77c268831 Mon Sep 17 00:00:00 2001 From: Sagar Date: Fri, 30 Apr 2021 17:04:53 -0700 Subject: [PATCH 1/3] CI Fix attempt --- .github/workflows/ci.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- go.sum | 1 + pkg/discovery/discover_test.go | 14 +++++++------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 019b3d2..7f76446 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: make build-discovery . go test ./... - name: Discovery Release (Snapshot) - uses: goreleaser/goreleaser-action@master + uses: goreleaser/goreleaser-action@v2.5.0 with: workdir: . args: release --snapshot --skip-publish --rm-dist @@ -47,7 +47,7 @@ jobs: make build-trace go test ./... - name: Traceability Release (Snapshot) - uses: goreleaser/goreleaser-action@master + uses: goreleaser/goreleaser-action@v2.5.0 with: workdir: . args: release --snapshot --skip-publish --rm-dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de263d5..110b93d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: with: go-version: '^1.13.0' - name: Discovery Release - uses: goreleaser/goreleaser-action@master + uses: goreleaser/goreleaser-action@v2.5.0 with: workdir: . args: release @@ -33,7 +33,7 @@ jobs: with: go-version: '^1.13.0' - name: Traceability Release - uses: goreleaser/goreleaser-action@master + uses: goreleaser/goreleaser-action@v2.5.0 with: workdir: . args: release diff --git a/go.sum b/go.sum index 414d4bb..b8001ef 100644 --- a/go.sum +++ b/go.sum @@ -330,6 +330,7 @@ github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 h1:f0n1xnMSmBLzVf github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA= github.com/gorilla/mux v1.7.2 h1:zoNxOV7WjqXptQOVngLmcSQgXmgk4NMz1HibBchjl/I= github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= diff --git a/pkg/discovery/discover_test.go b/pkg/discovery/discover_test.go index 9a495d8..97c86e3 100644 --- a/pkg/discovery/discover_test.go +++ b/pkg/discovery/discover_test.go @@ -44,7 +44,7 @@ func (m *mockAnypointClient) ListAssets(*anypoint.Page) ([]anypoint.Asset, error ExchangeAssetName: "dummyasset", APIs: []anypoint.API{{ ID: 6789, - EndpointURI: "google.com", + EndpointURI: "http://google.com", AssetID: "12345", }}, }} @@ -52,8 +52,8 @@ func (m *mockAnypointClient) ListAssets(*anypoint.Page) ([]anypoint.Asset, error return assets, nil } -func (m *mockAnypointClient) GetPolicies(*anypoint.API) ([]anypoint.Policy, error) { - return nil, nil +func (m *mockAnypointClient) GetPolicies(*anypoint.API) (anypoint.Policies, error) { + return anypoint.Policies{}, nil } func (m *mockAnypointClient) GetExchangeAsset(*anypoint.API) (*anypoint.ExchangeAsset, error) { @@ -110,7 +110,7 @@ func TestDiscoverAPIs(t *testing.T) { assert.Equal(t, "12345", sd.APIName) assert.Equal(t, "oas2", sd.ResourceType) assert.Equal(t, "6789", sd.ID) - assert.Equal(t, []byte("{\"basePath\":\"google.com\",\"host\":\"\",\"schemes\":[\"\"],\"swagger\":\"2.0\"}"), sd.APISpec) + assert.Equal(t, []byte("{\"schemes\":[\"http\"],\"swagger\":\"2.0\",\"host\":\"google.com\",\"basePath\":\"/\",\"paths\":null,\"definitions\":null}"), sd.APISpec) assert.NotEmpty(t, sd.ServiceAttributes["checksum"]) case <-time.After(time.Second * 1): t.Errorf("Timed out waiting for the discovery") @@ -227,7 +227,7 @@ func TestGetServiceDetailWhenExchangeAssetSpecFileIsEmpty(t *testing.T) { mc.Reqs["/apimanager/api/v1/organizations/333/environments/111/apis/456/policies"] = &api.Response{ Code: 200, - Body: []byte(`[{}]`), + Body: []byte(`[]`), } mc.Reqs["/exchange/api/v2/assets/123/456/89"] = &api.Response{ @@ -457,8 +457,8 @@ func TestSetOAS2Endpoint(t *testing.T) { { name: "Should return spec that has OAS2 endpoint set", endPointURL: "http://google.com", - specContent: []byte("{\"basePath\":\"google.com\",\"host\":\"\",\"schemes\":[\"\"],\"swagger\":\"2.0\"}"), - result: []byte("{\"basePath\":\"\",\"host\":\"google.com\",\"schemes\":[\"http\"],\"swagger\":\"2.0\"}"), + specContent: []byte("{\"basePath\":\"\",\"host\":\"\",\"schemes\":[\"\"],\"swagger\":\"2.0\"}"), + result: []byte("{\"basePath\":\"/\",\"host\":\"google.com\",\"schemes\":[\"http\"],\"swagger\":\"2.0\"}"), err: nil, }, } From 50fdc0a18a69ee9abb7b3e030f2e0eb23f1eba16 Mon Sep 17 00:00:00 2001 From: Sagar Date: Fri, 30 Apr 2021 17:13:58 -0700 Subject: [PATCH 2/3] CI Fix attempt - 2 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f76446..16b1a2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Discovery Release (Snapshot) uses: goreleaser/goreleaser-action@v2.5.0 with: - workdir: . + workdir: ./cmd/discovery args: release --snapshot --skip-publish --rm-dist build-traceability: @@ -49,5 +49,5 @@ jobs: - name: Traceability Release (Snapshot) uses: goreleaser/goreleaser-action@v2.5.0 with: - workdir: . + workdir: ./cmd/traceability args: release --snapshot --skip-publish --rm-dist From 1a35606e4be9c6e7a22d7848886535056d90f88a Mon Sep 17 00:00:00 2001 From: Sagar Date: Fri, 30 Apr 2021 17:20:53 -0700 Subject: [PATCH 3/3] Fix release CI --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 110b93d..949dfdb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: - name: Discovery Release uses: goreleaser/goreleaser-action@v2.5.0 with: - workdir: . + workdir: ./cmd/discovery args: release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -35,7 +35,7 @@ jobs: - name: Traceability Release uses: goreleaser/goreleaser-action@v2.5.0 with: - workdir: . + workdir: ./cmd/traceability args: release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}