Skip to content

Commit 70bf214

Browse files
authored
add scheduled run to trivy CI (#2455)
1 parent 2663070 commit 70bf214

8 files changed

Lines changed: 29 additions & 15 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ jobs:
131131
pip3 install .
132132
pip3 install GDAL==`gdal-config --version`
133133
pip3 install "pyproj<3.8"
134+
pip3 install "SQLAlchemy==2.0.54"
134135
- name: setup test data ⚙️
135136
run: |
136137
pybabel compile -d locale -l es
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
release:
1313
types:
1414
- released
15+
schedule:
16+
- cron: '0 8 * * *' # runs daily at 8h UTC
1517

1618
jobs:
1719

@@ -24,7 +26,7 @@ jobs:
2426
- name: Checkout pygeoapi
2527
uses: actions/checkout@master
2628
- name: Scan vulnerabilities with trivy
27-
uses: aquasecurity/trivy-action@v0.35.0
29+
uses: aquasecurity/trivy-action@v0.36.0
2830
with:
2931
scan-type: fs
3032
exit-code: 1
@@ -39,7 +41,7 @@ jobs:
3941
run: |
4042
docker buildx build -t ${{ env.IMAGE_NAME }}:${{ github.sha }} --platform linux/amd64 --no-cache -f Dockerfile .
4143
- name: Scan locally built Docker image for vulnerabilities with trivy
42-
uses: aquasecurity/trivy-action@v0.35.0
44+
uses: aquasecurity/trivy-action@v0.36.0
4345
env:
4446
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
4547
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![DOI](https://zenodo.org/badge/121585259.svg)](https://zenodo.org/badge/latestdoi/121585259)
44
[![Build](https://github.com/geopython/pygeoapi/actions/workflows/main.yml/badge.svg)](https://github.com/geopython/pygeoapi/actions/workflows/main.yml)
55
[![Docker](https://github.com/geopython/pygeoapi/actions/workflows/containers.yml/badge.svg)](https://github.com/geopython/pygeoapi/actions/workflows/containers.yml)
6-
[![Vulnerabilities](https://github.com/geopython/pygeoapi/actions/workflows/vulnerabilities.yml/badge.svg)](https://github.com/geopython/pygeoapi/actions/workflows/vulnerabilities.yml)
6+
[![Vulnerabilities](https://github.com/geopython/pygeoapi/actions/workflows/trivy.yml/badge.svg)](https://github.com/geopython/pygeoapi/actions/workflows/trivy.yml)
77

88
[pygeoapi](https://pygeoapi.io) is a Python server implementation of the [OGC API](https://ogcapi.ogc.org) suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is [open source](https://opensource.org/) and released under an [MIT license](https://github.com/geopython/pygeoapi/blob/master/LICENSE.md).
99

‎docs/source/development.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A given GitHub Pull Request is evaluated against the following GitHub Actions:
1616
- ``main``: mainline testing harness (as defined in ``tests``)
1717
- ``flake8``: code linting
1818
- ``docs``: documentation updates (for files updated in ``docs/**.rst``)
19-
- ``vulnerabilities``: Trivy vulnerability scanning
19+
- ``trivy``: Trivy vulnerability scanning
2020

2121
Testing
2222
-------

‎pygeoapi/provider/xarray_.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ def __init__(self, provider_def):
6464

6565
open_options = {}
6666
squeeze = provider_def.get('options', {}).get('squeeze', False)
67-
zarr_options = provider_def.get('options', {}).get('zarr', {})
67+
self.zarr_options = provider_def.get('options', {}).get('zarr', {})
6868

6969
try:
7070
if provider_def['data'].endswith('.zarr'):
7171
open_func = xarray.open_zarr
72-
open_options = zarr_options
72+
open_options = self.zarr_options
7373
else:
7474
if '*' in self.data:
7575
LOGGER.debug('Detected multi file dataset')
@@ -158,7 +158,8 @@ def query(self, properties=[], subsets={}, bbox=[], bbox_crs=4326,
158158
if not properties and not subsets and format_ != 'json':
159159
LOGGER.debug('No parameters specified, returning native data')
160160
if format_ == 'zarr':
161-
return _get_zarr_data(self._data)
161+
zarr_format = self.zarr_options.get('zarr_format')
162+
return _get_zarr_data(self._data, zarr_format)
162163
else:
163164
return read_data(self.data)
164165

@@ -658,7 +659,7 @@ def _zip_dir(path, ziph, cwd):
658659
os.chdir(cwd)
659660

660661

661-
def _get_zarr_data(data):
662+
def _get_zarr_data(data, zarr_format=None):
662663
"""
663664
Returns bytes to read from Zarr directory zip
664665
:param data: Xarray dataset of coverage data
@@ -671,7 +672,7 @@ def _get_zarr_data(data):
671672
zarr_data_filename = f'{tmp_dir}zarr.zarr'
672673
zarr_zip_filename = f'{tmp_dir}zarr.zarr.zip'
673674

674-
data.to_zarr(zarr_data_filename, mode='w')
675+
data.to_zarr(zarr_data_filename, mode='w', zarr_format=zarr_format)
675676

676677
with zipfile.ZipFile(zarr_zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf: # noqa
677678
_zip_dir(zarr_data_filename, zipf, os.getcwd())

‎requirements-docker.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ pygeofilter[backend-sqlalchemy]
44
pygeoif
55
pygeometa
66
sodapy
7-
s3fs<=2023.6.0
7+
s3fs
88
Flask>=2.2.0
99
Flask-Cors
1010
urllib3>2
11-
botocore>1.42
11+
botocore>1.42

‎requirements-provider.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ pyarrow
1818
pygeofilter[backend-sqlalchemy]
1919
pygeoif
2020
pygeometa
21-
pymongo==4.18.3
21+
pymongo
2222
pymysql
2323
scipy
2424
sodapy
2525
xarray
26-
zarr<3
27-
s3fs<=2023.6.0
26+
zarr
27+
s3fs

‎tests/provider/test_xarray_zarr_provider.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def config():
5252
'format': {
5353
'name': 'zarr',
5454
'mimetype': 'application/zip'
55+
},
56+
'options': {
57+
'zarr': {
58+
'zarr_format': 2
59+
}
5560
}
5661
}
5762

@@ -61,12 +66,17 @@ def config_no_time(tmp_path):
6166
ds = xr.open_zarr(path)
6267
ds = ds.sel(time=ds.time[0])
6368
ds = ds.drop_vars('time')
64-
ds.to_zarr(tmp_path / 'no_time.zarr')
69+
ds.to_zarr(tmp_path / 'no_time.zarr', zarr_format=2)
6570
return {
6671
'name': 'zarr',
6772
'type': 'coverage',
6873
'data': str(tmp_path / 'no_time.zarr'),
6974
'format': {'name': 'zarr', 'mimetype': 'application/zip'},
75+
'options': {
76+
'zarr': {
77+
'zarr_format': 2
78+
}
79+
}
7080
}
7181

7282

0 commit comments

Comments
 (0)