Skip to content

Commit b7d2ab3

Browse files
committed
issue/194: Add snyk scan to cicd workflow
1 parent f294787 commit b7d2ab3

3 files changed

Lines changed: 59 additions & 1 deletion

File tree

.github/workflows/cicd-pipeline.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,26 @@ jobs:
169169
-Dsonar.projectName=${{ github.repository }}
170170
-Dsonar.projectVersion=${{ env.software_version }}
171171
-Dsonar.python.version=3.12
172+
- name: Run Snyk as a blocking step
173+
uses: snyk/actions/python-3.12@master
174+
env:
175+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
176+
with:
177+
command: test
178+
args: >
179+
--org=${{ secrets.SNYK_ORG_ID }}
180+
--project-name=${{ github.repository }}
181+
--severity-threshold=high
182+
--fail-on=all
183+
- name: Run Snyk on Python
184+
uses: snyk/actions/python-3.12@master
185+
env:
186+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
187+
with:
188+
command: monitor
189+
args: >
190+
--org=${{ secrets.SNYK_ORG_ID }}
191+
--project-name=${{ github.repository }}
172192
- name: Build Python Artifact
173193
id: poetry-build
174194
run: |
@@ -265,6 +285,18 @@ jobs:
265285
provenance: false
266286
tags: ${{ steps.meta.outputs.tags }}
267287
labels: ${{ steps.meta.outputs.labels }}
288+
- name: Run Snyk on Docker Image
289+
# Snyk can be used to break the build when it detects vulnerabilities.
290+
# In this case we want to upload the issues to GitHub Code Scanning
291+
continue-on-error: true
292+
uses: snyk/actions/docker@master
293+
env:
294+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
295+
with:
296+
image: ${{ steps.meta.outputs.tags[0] }}
297+
args: >
298+
--severity-threshold=high
299+
268300
- name: Set output
269301
id: set-outputs
270302
run: |

bignbit/submit_harmony_job.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,15 @@ def determine_output_dimensions(big_config, output_crs):
9898

9999
def generate_harmony_request(collection_concept_id, granule_concept_id, variable, output_width, output_height, output_crs, big_config, destination_bucket_url):
100100
"""Generate the harmony request to be made and return request object"""
101+
if ',' in variable:
102+
variable_list = variable.split(',')
103+
else:
104+
variable_list = [variable]
101105

102106
kwargs = {
103107
'collection': Collection(id=collection_concept_id),
104108
'granule_id': [granule_concept_id],
105-
'variables': [variable],
109+
'variables': variable_list,
106110
'format': big_config['config'].get('format', 'image/png'),
107111
'destination_url': destination_bucket_url,
108112
'labels': ['bignbit']

tests/test_submit_harmony_job.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,28 @@ def test_generate_harmony_request_variables_list(self):
334334
assert result.variables[0] == variable
335335
assert result.labels == ['bignbit']
336336

337+
def test_generate_harmony_request_comma_separated_variables(self):
338+
"""Test that a comma-separated variable list is properly converted"""
339+
collection_concept_id = 'C9999999999-POCLOUD'
340+
granule_concept_id = 'G9999999999-POCLOUD'
341+
variable = 'u,v'
342+
output_crs = 'EPSG:3857'
343+
output_width = 512
344+
output_height = 512
345+
big_config = {'config': {'width': 512, 'height': 512}}
346+
destination_bucket_url = 's3://bucket/path'
347+
348+
result = generate_harmony_request(
349+
collection_concept_id, granule_concept_id, variable, output_width, output_height,
350+
output_crs, big_config, destination_bucket_url
351+
)
352+
353+
assert isinstance(result.variables, list)
354+
assert len(result.variables) == 2
355+
assert result.variables[0] == 'u'
356+
assert result.variables[1] == 'v'
357+
assert result.labels == ['bignbit']
358+
337359

338360
class TestSubmitHarmonyJobIntegration:
339361
"""Integration-style tests for submit_harmony_job module"""

0 commit comments

Comments
 (0)