Skip to content

Commit

Permalink
Merge pull request #458 from onc-healthit/HOTFIX-static-analysis-and-…
Browse files Browse the repository at this point in the history
…tests-failure-fix

HOTFIX: Resolved Static Analysis and Tests failures in GitHub Actions
  • Loading branch information
vishnu-mettles authored Nov 27, 2024
2 parents 97c3462 + 4abe706 commit f957959
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 146 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ on: [push]
jobs:
Golintr:
name: Go Lintr
runs-on: macOS-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Install golangci-lint\
run: brew install golangci-lint
run: sudo snap install golangci-lint --classic

- name: Run Go Lintr
run: make lint_go
Rlintr:
runs-on: macOS-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v2

with:
r-version: '4.1.3'

- name: Lint R Files
run: cd ./scripts && ./lintr.sh
run: cd ./scripts && ./lintr.sh
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on: [push]

jobs:
test-unit:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Go Unit Tests
id: go-unit-tests
run: make test
test-integration:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Start System
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
id: go-integration-tests
run: ./scripts/wait-for-it.sh localhost:5432 -- ./scripts/wait-for-it.sh localhost:15672 -- ./scripts/wait-for-it.sh localhost:5672 -- make test_int
test-e2e:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Start System
Expand Down
10 changes: 6 additions & 4 deletions endpointmanager/pkg/chplendpointquerier/aspmdewebscraper.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package chplendpointquerier

import (
"strings"

"github.com/PuerkitoBio/goquery"
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers"
log "github.com/sirupsen/logrus"
"strings"
)

func AspMDeWebscraper(chplURL string, fileToWriteTo string) {
func AspMDeWebscraper(chplURL string, fileToWriteTo string) error {
found := false

baseURL := strings.TrimSuffix(chplURL, "/fhir_aspmd.asp#apiendpoints")
baseURL = strings.TrimSuffix(baseURL, "/fhir_aspmd.asp")

doc, err := helpers.ChromedpQueryEndpointList(chplURL, "p")
if err != nil {
log.Fatal(err)
return err
}

doc.Find("h1").Each(func(i int, s *goquery.Selection) {
Expand All @@ -35,4 +35,6 @@ func AspMDeWebscraper(chplURL string, fileToWriteTo string) {
})
}
})

return nil
}
18 changes: 12 additions & 6 deletions endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ func contains(arr [30]string, str string) bool {

func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {

var err error

if URLsEqual(chplURL, MedHostURL) {
MedHostQuerier(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, NextGenURL) {
Expand Down Expand Up @@ -543,9 +545,9 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
} else if URLsEqual(chplURL, anthemURL) {
AnthemURLParser("https://patient360.anthem.com/P360Member/fhir/endpoints", fileToWriteTo)
} else if URLsEqual(chplURL, hcscURL) {
HcscURLWebscraper(chplURL, fileToWriteTo)
err = HcscURLWebscraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, guidewellPatAccURL) || URLsEqual(chplURL, guidewellP2PURL) {
GuidewellURLWebscraper(chplURL, fileToWriteTo)
err = GuidewellURLWebscraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, humanaURL) {
HumanaURLWebscraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, kaiserURL) {
Expand All @@ -561,11 +563,11 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
} else if URLsEqual(chplURL, nextgenPracticeURL) {
NextgenPracticeWebscraper(nextgenPracticeURL, fileToWriteTo)
} else if URLsEqual(chplURL, aspmdURL) {
AspMDeWebscraper(aspmdURL, fileToWriteTo)
err = AspMDeWebscraper(aspmdURL, fileToWriteTo)
} else if URLsEqual(chplURL, axeiumURL) {
AxeiumeWebscraper(axeiumURL, fileToWriteTo)
} else if URLsEqual(chplURL, ezemrxURL) {
EzemrxWebscraper(chplURL, fileToWriteTo)
err = EzemrxWebscraper(chplURL, fileToWriteTo)
} else if contains(bundleQuerierArray, chplURL) {
BundleQuerierParser(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, curemdURL) {
Expand All @@ -575,9 +577,9 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
} else if URLsEqual(chplURL, betaAfoundriaURL) {
BetaAfoundriaWebScraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, ontadaURL) {
OntadaWebscraper(chplURL, fileToWriteTo)
err = OntadaWebscraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, mdlandURL) {
MdlandWebscraper("https://api.mdland.com/Mdland%20SMART%20on%20FHIR%20OAuth%202.0%20Guide.htm", fileToWriteTo)
err = MdlandWebscraper("https://api.mdland.com/Mdland%20SMART%20on%20FHIR%20OAuth%202.0%20Guide.htm", fileToWriteTo)
} else if URLsEqual(abeoURL, chplURL) {
CustomCSVParser(chplURL, fileToWriteTo, "./FHIRServiceURLs.csv", -1, 0, true, 1, 0)
} else if URLsEqual(nextechURL2, chplURL) {
Expand All @@ -589,6 +591,10 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
} else {
log.Warnf("Handler is required for url %s", chplURL)
}

if err != nil {
log.Info(err)
}
}

// WriteCHPLFile writes the given endpointEntryList to a json file and stores it in the prod resources directory
Expand Down
28 changes: 16 additions & 12 deletions endpointmanager/pkg/chplendpointquerier/commomwebscrapers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
log "github.com/sirupsen/logrus"
)

type WebScraperFunc func(string, string)
type WebScraperFunc func(string, string) error

type ScraperTestCase struct {
scraperFunc WebScraperFunc
Expand Down Expand Up @@ -49,19 +49,23 @@ func TestWebScrapers(t *testing.T) {
}

func runWebScraperTest(t *testing.T, scraperFunc WebScraperFunc, url, fileName string) {
scraperFunc(url, fileName)
err := scraperFunc(url, fileName)

fileExists, err := doesfileExist(fileName)
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "File does not exist")
if err == nil {
fileExists, err := doesfileExist(fileName)
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "File does not exist")

fileEmpty, err := isFileEmpty(fileName)
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "File is empty")
fileEmpty, err := isFileEmpty(fileName)
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "File is empty")

err = os.Remove("../../../resources/prod_resources/" + fileName)
th.Assert(t, err == nil, err)
err = os.Remove("../../../resources/prod_resources/" + fileName)
th.Assert(t, err == nil, err)

err = os.Remove("../../../resources/dev_resources/" + fileName)
th.Assert(t, err == nil, err)
err = os.Remove("../../../resources/dev_resources/" + fileName)
th.Assert(t, err == nil, err)
} else {
log.Info(err)
}
}
8 changes: 4 additions & 4 deletions endpointmanager/pkg/chplendpointquerier/ezemrxwebscraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ import (
"strings"

"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers"
log "github.com/sirupsen/logrus"
)

func EzemrxWebscraper(CHPLURL string, fileToWriteTo string) {
func EzemrxWebscraper(CHPLURL string, fileToWriteTo string) error {

var lanternEntryList []LanternEntry
var endpointEntryList EndpointList
var entry LanternEntry

doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, "#comp-lb6njyhb")
if err != nil {
log.Fatal(err)
return err
}

divElem := doc.Find("#comp-lb6njyhb").First()
Expand All @@ -32,7 +31,8 @@ func EzemrxWebscraper(CHPLURL string, fileToWriteTo string) {

err = WriteCHPLFile(endpointEntryList, fileToWriteTo)
if err != nil {
log.Fatal(err)
return err
}

return nil
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package chplendpointquerier

import (
"log"

"github.com/PuerkitoBio/goquery"
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers"
)
Expand All @@ -16,13 +14,13 @@ func entryExists(lanternEntryList []LanternEntry, lanternEntry LanternEntry) boo
return false
}

func GuidewellURLWebscraper(CHPLURL string, fileToWriteTo string) {
func GuidewellURLWebscraper(CHPLURL string, fileToWriteTo string) error {
var lanternEntryList []LanternEntry
var endpointEntryList EndpointList

doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, "div.apiEndpointUrl")
if err != nil {
log.Fatal(err)
return err
}
doc.Find("div.apiEndpointUrl").Each(func(index int, urlElements *goquery.Selection) {

Expand All @@ -38,7 +36,8 @@ func GuidewellURLWebscraper(CHPLURL string, fileToWriteTo string) {
endpointEntryList.Endpoints = lanternEntryList
err = WriteCHPLFile(endpointEntryList, fileToWriteTo)
if err != nil {
log.Fatal(err)
return err
}

return nil
}
106 changes: 61 additions & 45 deletions endpointmanager/pkg/chplendpointquerier/guidewellurlwebscraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,78 +5,94 @@ import (
"testing"

th "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/testhelper"
log "github.com/sirupsen/logrus"
)

func Test_GuidewellURLWebscraper(t *testing.T) {

// Patient Access API Test Cases
// 1. Happy case: Valid url, valid file format
GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/306/api/285#/CMSInteroperabilityPatientAccessMetadata_100/operation/%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPatientAccessEndpointSources.json")
err := GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/306/api/285#/CMSInteroperabilityPatientAccessMetadata_100/operation/%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPatientAccessEndpointSources.json")

fileExists, err := doesfileExist("TEST_Medicare_GuidewellPatientAccessEndpointSources.json")
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "JSON file does not exist")
if err == nil {
fileExists, err := doesfileExist("TEST_Medicare_GuidewellPatientAccessEndpointSources.json")
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "JSON file does not exist")

fileEmpty, err := isFileEmpty("TEST_Medicare_GuidewellPatientAccessEndpointSources.json")
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "Empty JSON file")
fileEmpty, err := isFileEmpty("TEST_Medicare_GuidewellPatientAccessEndpointSources.json")
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "Empty JSON file")

err = os.Remove("../../../resources/prod_resources/TEST_Medicare_GuidewellPatientAccessEndpointSources.json")
th.Assert(t, err == nil, err)
err = os.Remove("../../../resources/prod_resources/TEST_Medicare_GuidewellPatientAccessEndpointSources.json")
th.Assert(t, err == nil, err)

err = os.Remove("../../../resources/dev_resources/TEST_Medicare_GuidewellPatientAccessEndpointSources.json")
th.Assert(t, err == nil, err)
err = os.Remove("../../../resources/dev_resources/TEST_Medicare_GuidewellPatientAccessEndpointSources.json")
th.Assert(t, err == nil, err)
} else {
log.Info(err)
}

// 2. Different file format
GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/306/api/285#/CMSInteroperabilityPatientAccessMetadata_100/operation/%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")
err = GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/306/api/285#/CMSInteroperabilityPatientAccessMetadata_100/operation/%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")

fileExists, err = doesfileExist("TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "CSV file does not exist")
if err == nil {
fileExists, err := doesfileExist("TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "CSV file does not exist")

fileEmpty, err = isFileEmpty("TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "Empty CSV file")
fileEmpty, err := isFileEmpty("TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "Empty CSV file")

err = os.Remove("../../../resources/prod_resources/TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")
th.Assert(t, err == nil, err)
err = os.Remove("../../../resources/prod_resources/TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")
th.Assert(t, err == nil, err)

err = os.Remove("../../../resources/dev_resources/TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")
th.Assert(t, err == nil, err)
err = os.Remove("../../../resources/dev_resources/TEST_Medicare_GuidewellPatientAccessEndpointSources.csv")
th.Assert(t, err == nil, err)
} else {
log.Info(err)
}

// Payer2Payer API Test Cases
// 1. Happy case: Valid url, valid file format
GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/309/api/288#/CMSInteroperabilityPayer2PayerOutboundMetadata_100/operation/%2FP2P%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")
err = GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/309/api/288#/CMSInteroperabilityPayer2PayerOutboundMetadata_100/operation/%2FP2P%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")

fileExists, err = doesfileExist("TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "JSON file does not exist")
if err == nil {
fileExists, err := doesfileExist("TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "JSON file does not exist")

fileEmpty, err = isFileEmpty("TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "Empty JSON file")
fileEmpty, err := isFileEmpty("TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "Empty JSON file")

err = os.Remove("../../../resources/prod_resources/TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")
th.Assert(t, err == nil, err)
err = os.Remove("../../../resources/prod_resources/TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")
th.Assert(t, err == nil, err)

err = os.Remove("../../../resources/dev_resources/TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")
th.Assert(t, err == nil, err)
err = os.Remove("../../../resources/dev_resources/TEST_Medicare_GuidewellPayer2PayerEndpointSources.json")
th.Assert(t, err == nil, err)
} else {
log.Info(err)
}

// 2. Different file format
GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/309/api/288#/CMSInteroperabilityPayer2PayerOutboundMetadata_100/operation/%2FP2P%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")
err = GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/309/api/288#/CMSInteroperabilityPayer2PayerOutboundMetadata_100/operation/%2FP2P%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")

fileExists, err = doesfileExist("TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "CSV file does not exist")
if err == nil {
fileExists, err := doesfileExist("TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")
th.Assert(t, err == nil, err)
th.Assert(t, fileExists, "CSV file does not exist")

fileEmpty, err = isFileEmpty("TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "Empty CSV file")
fileEmpty, err := isFileEmpty("TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")
th.Assert(t, err == nil, err)
th.Assert(t, !fileEmpty, "Empty CSV file")

err = os.Remove("../../../resources/prod_resources/TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")
th.Assert(t, err == nil, err)

err = os.Remove("../../../resources/dev_resources/TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")
th.Assert(t, err == nil, err)
err = os.Remove("../../../resources/prod_resources/TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")
th.Assert(t, err == nil, err)

err = os.Remove("../../../resources/dev_resources/TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv")
th.Assert(t, err == nil, err)
} else {
log.Info(err)
}
}
Loading

0 comments on commit f957959

Please sign in to comment.