Skip to content

Commit

Permalink
feat: finer user agent (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle authored Feb 7, 2023
1 parent 3865bea commit f0e08a9
Show file tree
Hide file tree
Showing 151 changed files with 873 additions and 833 deletions.
4 changes: 4 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ If you’ve found a bug, please file an issue that illustrates the bug with a mi

* We use [testthat](https://cran.r-project.org/package=testthat) and [httptest](https://books.ropensci.org/http-testing/httptest.html) for unit tests.
Contributions with test cases included are easier to accept.

## Collaborators

Regular contributors should be listed in inst/collaborators.txt to ensure the user-agent used by the package flags them as developers.
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
EMODNETWFS_CI: yes

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/Test-Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
EMODNETWFS_CI: yes

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pkgcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ on:
jobs:
pkgcheck:
runs-on: ubuntu-latest
env:
EMODNETWFS_CI: yes
steps:
- uses: ropensci-review-tools/pkgcheck-action@main
1 change: 1 addition & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
EMODNETWFS_CI: yes
steps:
- uses: actions/checkout@v2

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
EMODNETWFS_CI: yes
steps:
- uses: actions/checkout@v2

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
runs-on: windows-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
EMODNETWFS_CI: yes

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-no-fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
runs-on: windows-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
EMODNETWFS_CI: yes

steps:
- uses: actions/checkout@v2
Expand All @@ -37,7 +38,7 @@ jobs:
run1 <- as.data.frame(devtools::test())
if (sum(run1$error, run1$failed, run1$warning) > 0) {
stop("Tests did not pass with devtools::test()")
}
}
shell: Rscript {0}

- name: Upload check results
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Imports:
sf,
tibble,
tidyr,
utils
utils,
whoami
Suggests:
covr,
dplyr,
Expand Down
17 changes: 16 additions & 1 deletion R/EMODnetWFS-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
## usethis namespace: end
NULL

emodnetwfs_collaborators <- function() {
readLines(system.file("collaborators.txt", package = "EMODnetWFS"))
}

emodnetwfs_user_agent <- function() {
"EMODnetWFS R package https://github.com/EMODnet/EMODnetWFS"
version <- as.character(packageVersion("EMODnetWFS"))

if (nzchar(Sys.getenv("EMODNETWFS_CI"))) {
return(sprintf("EMODnetWFS R package %s CI https://github.com/EMODnet/EMODnetWFS", version))
}

gh_username <- try(whoami::gh_username(), silent = TRUE)
if (!inherits(gh_username, "try-error") && gh_username %in% emodnetwfs_collaborators()) {
return(sprintf("EMODnetWFS R package %s DEV https://github.com/EMODnet/EMODnetWFS", version))
}

sprintf("EMODnetWFS R package %s https://github.com/EMODnet/EMODnetWFS", version)
}
3 changes: 3 additions & 0 deletions inst/collaborators.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
annakrystalli
salvafern
maelle
12 changes: 6 additions & 6 deletions tests/fixtures/Malta-Israele/api/wfs-0a8298.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ structure(list(url = "https://geo.vliz.be/geoserver/Emodnetbio/wfs?service=WFS&v
status_code = 200L, headers = structure(list(server = "Apache-Coyote/1.1",
`content-disposition` = "inline; filename=geoserver-DescribeFeatureType.text",
`content-encoding` = "gzip", `content-type` = "text/xml; subtype=gml/3.2",
`transfer-encoding` = "chunked", date = "Fri, 07 Oct 2022 13:21:58 GMT"), class = c("insensitive",
`transfer-encoding` = "chunked", date = "Fri, 14 Oct 2022 09:11:29 GMT"), class = c("insensitive",
"list")), all_headers = list(list(status = 200L, version = "HTTP/1.1",
headers = structure(list(server = "Apache-Coyote/1.1",
`content-disposition` = "inline; filename=geoserver-DescribeFeatureType.text",
`content-encoding` = "gzip", `content-type` = "text/xml; subtype=gml/3.2",
`transfer-encoding` = "chunked", date = "Fri, 07 Oct 2022 13:21:58 GMT"), class = c("insensitive",
`transfer-encoding` = "chunked", date = "Fri, 14 Oct 2022 09:11:29 GMT"), class = c("insensitive",
"list")))), cookies = structure(list(domain = logical(0),
flag = logical(0), path = logical(0), secure = logical(0),
expiration = structure(numeric(0), class = c("POSIXct",
"POSIXt")), name = logical(0), value = logical(0)), row.names = integer(0), class = "data.frame"),
content = charToRaw("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsd:schema xmlns:Emodnetbio=\"geo.vliz.be/Emodnetbio\" xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:wfs=\"http://www.opengis.net/wfs/2.0\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" targetNamespace=\"geo.vliz.be/Emodnetbio\">\n <xsd:import namespace=\"http://www.opengis.net/gml/3.2\" schemaLocation=\"http://geo.vliz.be:80/geoserver/schemas/gml/3.2.1/gml.xsd\"/>\n <xsd:complexType name=\"OOPS_metadataType\">\n <xsd:complexContent>\n <xsd:extension base=\"gml:AbstractFeatureType\">\n <xsd:sequence>\n <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"id\" nillable=\"false\" type=\"xsd:int\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"AphiaID\" nillable=\"true\" type=\"xsd:int\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"scientificName\" nillable=\"true\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"startYearCollection\" nillable=\"true\" type=\"xsd:short\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"endYearCollection\" nillable=\"true\" type=\"xsd:short\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"season\" nillable=\"true\" type=\"xsd:short\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"measurementUnit\" nillable=\"true\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"fileName\" nillable=\"true\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"datasetID\" nillable=\"true\" type=\"xsd:int\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"uploadDate\" nillable=\"true\" type=\"xsd:dateTime\"/>\n </xsd:sequence>\n </xsd:extension>\n </xsd:complexContent>\n </xsd:complexType>\n <xsd:element name=\"OOPS_metadata\" substitutionGroup=\"gml:AbstractFeature\" type=\"Emodnetbio:OOPS_metadataType\"/>\n</xsd:schema>\n"),
date = structure(1665148918, class = c("POSIXct", "POSIXt"
), tzone = "GMT"), times = c(redirect = 0, namelookup = 3e-05,
connect = 3.1e-05, pretransfer = 0.000105, starttransfer = 0.02874,
total = 0.028826)), class = "response")
date = structure(1665738689, class = c("POSIXct", "POSIXt"
), tzone = "GMT"), times = c(redirect = 0, namelookup = 2.2e-05,
connect = 2.2e-05, pretransfer = 8.3e-05, starttransfer = 0.029419,
total = 0.029503)), class = "response")
12 changes: 6 additions & 6 deletions tests/fixtures/Malta-Israele/api/wfs-13e85b.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ structure(list(url = "https://geo.vliz.be/geoserver/Emodnetbio/wfs?service=WFS&v
status_code = 200L, headers = structure(list(server = "Apache-Coyote/1.1",
`content-disposition` = "inline; filename=geoserver-DescribeFeatureType.text",
`content-encoding` = "gzip", `content-type` = "text/xml; subtype=gml/3.2",
`transfer-encoding` = "chunked", date = "Fri, 07 Oct 2022 13:21:58 GMT"), class = c("insensitive",
`transfer-encoding` = "chunked", date = "Fri, 14 Oct 2022 09:11:30 GMT"), class = c("insensitive",
"list")), all_headers = list(list(status = 200L, version = "HTTP/1.1",
headers = structure(list(server = "Apache-Coyote/1.1",
`content-disposition` = "inline; filename=geoserver-DescribeFeatureType.text",
`content-encoding` = "gzip", `content-type` = "text/xml; subtype=gml/3.2",
`transfer-encoding` = "chunked", date = "Fri, 07 Oct 2022 13:21:58 GMT"), class = c("insensitive",
`transfer-encoding` = "chunked", date = "Fri, 14 Oct 2022 09:11:30 GMT"), class = c("insensitive",
"list")))), cookies = structure(list(domain = logical(0),
flag = logical(0), path = logical(0), secure = logical(0),
expiration = structure(numeric(0), class = c("POSIXct",
"POSIXt")), name = logical(0), value = logical(0)), row.names = integer(0), class = "data.frame"),
content = charToRaw("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsd:schema xmlns:Emodnetbio=\"geo.vliz.be/Emodnetbio\" xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:wfs=\"http://www.opengis.net/wfs/2.0\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" targetNamespace=\"geo.vliz.be/Emodnetbio\">\n <xsd:import namespace=\"http://www.opengis.net/gml/3.2\" schemaLocation=\"http://geo.vliz.be:80/geoserver/schemas/gml/3.2.1/gml.xsd\"/>\n <xsd:complexType name=\"mediseh_posidonia_nodataType\">\n <xsd:complexContent>\n <xsd:extension base=\"gml:AbstractFeatureType\">\n <xsd:sequence>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"id\" nillable=\"true\" type=\"xsd:int\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"km\" nillable=\"true\" type=\"xsd:decimal\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"the_geom\" nillable=\"true\" type=\"gml:MultiCurvePropertyType\"/>\n </xsd:sequence>\n </xsd:extension>\n </xsd:complexContent>\n </xsd:complexType>\n <xsd:element name=\"mediseh_posidonia_nodata\" substitutionGroup=\"gml:AbstractFeature\" type=\"Emodnetbio:mediseh_posidonia_nodataType\"/>\n</xsd:schema>\n"),
date = structure(1665148918, class = c("POSIXct", "POSIXt"
), tzone = "GMT"), times = c(redirect = 0, namelookup = 2.7e-05,
connect = 2.8e-05, pretransfer = 9.2e-05, starttransfer = 0.028778,
total = 0.028858)), class = "response")
date = structure(1665738690, class = c("POSIXct", "POSIXt"
), tzone = "GMT"), times = c(redirect = 0, namelookup = 2.5e-05,
connect = 2.6e-05, pretransfer = 8.8e-05, starttransfer = 0.029118,
total = 0.029194)), class = "response")
14 changes: 7 additions & 7 deletions tests/fixtures/Malta-Israele/api/wfs-25981b.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ structure(list(url = "https://geo.vliz.be/geoserver/Emodnetbio/wfs?service=WFS&v
status_code = 200L, headers = structure(list(server = "Apache-Coyote/1.1",
`content-disposition` = "inline; filename=geoserver-GetFeature.text",
`content-encoding` = "gzip", `content-type` = "text/xml; subtype=gml/3.2",
`transfer-encoding` = "chunked", date = "Fri, 07 Oct 2022 13:21:59 GMT"), class = c("insensitive",
`transfer-encoding` = "chunked", date = "Fri, 14 Oct 2022 09:11:31 GMT"), class = c("insensitive",
"list")), all_headers = list(list(status = 200L, version = "HTTP/1.1",
headers = structure(list(server = "Apache-Coyote/1.1",
`content-disposition` = "inline; filename=geoserver-GetFeature.text",
`content-encoding` = "gzip", `content-type` = "text/xml; subtype=gml/3.2",
`transfer-encoding` = "chunked", date = "Fri, 07 Oct 2022 13:21:59 GMT"), class = c("insensitive",
`transfer-encoding` = "chunked", date = "Fri, 14 Oct 2022 09:11:31 GMT"), class = c("insensitive",
"list")))), cookies = structure(list(domain = logical(0),
flag = logical(0), path = logical(0), secure = logical(0),
expiration = structure(numeric(0), class = c("POSIXct",
"POSIXt")), name = logical(0), value = logical(0)), row.names = integer(0), class = "data.frame"),
content = charToRaw("<?xml version=\"1.0\" encoding=\"UTF-8\"?><wfs:FeatureCollection xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:Emodnetbio=\"geo.vliz.be/Emodnetbio\" xmlns:wfs=\"http://www.opengis.net/wfs/2.0\" xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" numberMatched=\"3\" numberReturned=\"3\" timeStamp=\"2022-10-07T13:22:00.778Z\" xsi:schemaLocation=\"http://www.opengis.net/wfs/2.0 http://geo.vliz.be:80/geoserver/schemas/wfs/2.0/wfs.xsd geo.vliz.be/Emodnetbio http://geo.vliz.be:80/geoserver/Emodnetbio/wfs?service=WFS&amp;version=2.0.0&amp;request=DescribeFeatureType&amp;typeName=Emodnetbio%3Amediseh_cymodocea_pnt http://www.opengis.net/gml/3.2 http://geo.vliz.be:80/geoserver/schemas/gml/3.2.1/gml.xsd\"><wfs:boundedBy><gml:Envelope><gml:lowerCorner>32.91777958700004 14.379386510410153</gml:lowerCorner><gml:upperCorner>35.988571738846716 35.075850495000054</gml:upperCorner></gml:Envelope></wfs:boundedBy><wfs:member><Emodnetbio:mediseh_cymodocea_pnt gml:id=\"mediseh_cymodocea_pnt.1160\"><gml:boundedBy><gml:Envelope srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:lowerCorner>32.91778 35.07585</gml:lowerCorner><gml:upperCorner>32.91778 35.07585</gml:upperCorner></gml:Envelope></gml:boundedBy><Emodnetbio:id>0</Emodnetbio:id><Emodnetbio:country>Israele</Emodnetbio:country><Emodnetbio:the_geom><gml:Point srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:pos>32.91778 35.07585</gml:pos></gml:Point></Emodnetbio:the_geom></Emodnetbio:mediseh_cymodocea_pnt></wfs:member><wfs:member><Emodnetbio:mediseh_cymodocea_pnt gml:id=\"mediseh_cymodocea_pnt.1264\"><gml:boundedBy><gml:Envelope srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:lowerCorner>35.953397 14.448711</gml:lowerCorner><gml:upperCorner>35.953397 14.448711</gml:upperCorner></gml:Envelope></gml:boundedBy><Emodnetbio:id>0</Emodnetbio:id><Emodnetbio:country>Malta</Emodnetbio:country><Emodnetbio:the_geom><gml:Point srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:pos>35.953397 14.448711</gml:pos></gml:Point></Emodnetbio:the_geom></Emodnetbio:mediseh_cymodocea_pnt></wfs:member><wfs:member><Emodnetbio:mediseh_cymodocea_pnt gml:id=\"mediseh_cymodocea_pnt.1265\"><gml:boundedBy><gml:Envelope srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:lowerCorner>35.988572 14.379387</gml:lowerCorner><gml:upperCorner>35.988572 14.379387</gml:upperCorner></gml:Envelope></gml:boundedBy><Emodnetbio:id>0</Emodnetbio:id><Emodnetbio:country>Malta</Emodnetbio:country><Emodnetbio:the_geom><gml:Point srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:pos>35.988572 14.379387</gml:pos></gml:Point></Emodnetbio:the_geom></Emodnetbio:mediseh_cymodocea_pnt></wfs:member></wfs:FeatureCollection>"),
date = structure(1665148919, class = c("POSIXct", "POSIXt"
), tzone = "GMT"), times = c(redirect = 0, namelookup = 2.1e-05,
connect = 2.2e-05, pretransfer = 7.7e-05, starttransfer = 0.035895,
total = 0.035977)), class = "response")
content = charToRaw("<?xml version=\"1.0\" encoding=\"UTF-8\"?><wfs:FeatureCollection xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:Emodnetbio=\"geo.vliz.be/Emodnetbio\" xmlns:wfs=\"http://www.opengis.net/wfs/2.0\" xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" numberMatched=\"3\" numberReturned=\"3\" timeStamp=\"2022-10-14T09:11:31.805Z\" xsi:schemaLocation=\"http://www.opengis.net/wfs/2.0 http://geo.vliz.be:80/geoserver/schemas/wfs/2.0/wfs.xsd geo.vliz.be/Emodnetbio http://geo.vliz.be:80/geoserver/Emodnetbio/wfs?service=WFS&amp;version=2.0.0&amp;request=DescribeFeatureType&amp;typeName=Emodnetbio%3Amediseh_cymodocea_pnt http://www.opengis.net/gml/3.2 http://geo.vliz.be:80/geoserver/schemas/gml/3.2.1/gml.xsd\"><wfs:boundedBy><gml:Envelope><gml:lowerCorner>32.91777958700004 14.379386510410153</gml:lowerCorner><gml:upperCorner>35.988571738846716 35.075850495000054</gml:upperCorner></gml:Envelope></wfs:boundedBy><wfs:member><Emodnetbio:mediseh_cymodocea_pnt gml:id=\"mediseh_cymodocea_pnt.1160\"><gml:boundedBy><gml:Envelope srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:lowerCorner>32.91778 35.07585</gml:lowerCorner><gml:upperCorner>32.91778 35.07585</gml:upperCorner></gml:Envelope></gml:boundedBy><Emodnetbio:id>0</Emodnetbio:id><Emodnetbio:country>Israele</Emodnetbio:country><Emodnetbio:the_geom><gml:Point srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:pos>32.91778 35.07585</gml:pos></gml:Point></Emodnetbio:the_geom></Emodnetbio:mediseh_cymodocea_pnt></wfs:member><wfs:member><Emodnetbio:mediseh_cymodocea_pnt gml:id=\"mediseh_cymodocea_pnt.1264\"><gml:boundedBy><gml:Envelope srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:lowerCorner>35.953397 14.448711</gml:lowerCorner><gml:upperCorner>35.953397 14.448711</gml:upperCorner></gml:Envelope></gml:boundedBy><Emodnetbio:id>0</Emodnetbio:id><Emodnetbio:country>Malta</Emodnetbio:country><Emodnetbio:the_geom><gml:Point srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:pos>35.953397 14.448711</gml:pos></gml:Point></Emodnetbio:the_geom></Emodnetbio:mediseh_cymodocea_pnt></wfs:member><wfs:member><Emodnetbio:mediseh_cymodocea_pnt gml:id=\"mediseh_cymodocea_pnt.1265\"><gml:boundedBy><gml:Envelope srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:lowerCorner>35.988572 14.379387</gml:lowerCorner><gml:upperCorner>35.988572 14.379387</gml:upperCorner></gml:Envelope></gml:boundedBy><Emodnetbio:id>0</Emodnetbio:id><Emodnetbio:country>Malta</Emodnetbio:country><Emodnetbio:the_geom><gml:Point srsName=\"urn:ogc:def:crs:EPSG::4326\" srsDimension=\"2\"><gml:pos>35.988572 14.379387</gml:pos></gml:Point></Emodnetbio:the_geom></Emodnetbio:mediseh_cymodocea_pnt></wfs:member></wfs:FeatureCollection>"),
date = structure(1665738691, class = c("POSIXct", "POSIXt"
), tzone = "GMT"), times = c(redirect = 0, namelookup = 2.3e-05,
connect = 2.4e-05, pretransfer = 8.1e-05, starttransfer = 0.039096,
total = 0.039157)), class = "response")
Loading

0 comments on commit f0e08a9

Please sign in to comment.