Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of specifying collections to be tested in pull request body #92

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/build_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- if: github.event.pull_request.body == ''
run: |
echo "::error::Pull request body text can't be empty, please define which collections to test"
exit 1
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
Expand All @@ -27,14 +31,24 @@ jobs:
run: |
pip install -U pip
pip install -r generators/requirements.txt
- name: Build
- if: github.event.pull_request.body == 'all'
name: Build all
env:
SH_INSTANCE_ID: ${{ secrets.SH_INSTANCE_ID }}
SH_CLIENT_ID: ${{ secrets.SH_CLIENT_ID }}
SH_CLIENT_SECRET: ${{ secrets.SH_CLIENT_SECRET }}
run: |
cd generators/
python generate_indicators.py
- if: github.event.pull_request.body != 'all'
name: Build only specified collections
env:
SH_INSTANCE_ID: ${{ secrets.SH_INSTANCE_ID }}
SH_CLIENT_ID: ${{ secrets.SH_CLIENT_ID }}
SH_CLIENT_SECRET: ${{ secrets.SH_CLIENT_SECRET }}
run: |
cd generators/
python generate_indicators.py -ni
python generate_indicators.py -c ${{ github.event.pull_request.body }}
# Upload build to S3
- name: sync client s3
uses: jakejarvis/[email protected]
Expand Down
37 changes: 33 additions & 4 deletions generators/generate_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,28 @@
as possible and generating a STAC catalog with the information''',
)

argparser.add_argument("-vd", action="store_true", help="validation flag, if set, validation will be run on generated catalogs")
argparser.add_argument("-ni", action="store_true", help="no items flag, if set, items will not be saved")
argparser.add_argument("-tn", action="store_true", help="generate additionally thumbnail image for supported collections")
argparser.add_argument(
"-vd",
action="store_true",
help="validation flag, if set, validation will be run on generated catalogs"
)
argparser.add_argument(
"-ni",
action="store_true",
help="no items flag, if set, items will not be saved"
)
argparser.add_argument(
"-tn",
action="store_true",
help="generate additionally thumbnail image for supported collections"
)
argparser.add_argument(
"-c", "--collections",
help="list of collection identifiers to be generated for test build",
nargs='+',
required=False,
default=[]
)

def recursive_save(stac_object, no_items=False):
stac_object.save_object()
Expand All @@ -69,13 +88,23 @@ def process_catalog_file(file_path, options):
print("Processing catalog:", file_path)
with open(file_path) as f:
config = yaml.load(f, Loader=SafeLoader)

if len(options.collections) > 0:
# create only catalogs containing the passed collections
process_collections = [c for c in config["collections"] if c in options.collections]
elif (len(options.collections) == 1 and options.collections == "all") or len(options.collections) == 0:
# create full catalog
process_collections = config["collections"]
if len(process_collections) == 0:
print("No applicable collections found for catalog, skipping creation")
return
catalog = Catalog(
id = config["id"],
description = config["description"],
title = config["title"],
catalog_type=CatalogType.RELATIVE_PUBLISHED,
)
for collection in config["collections"]:
for collection in process_collections:
process_collection_file(config, "../collections/%s.yaml"%(collection), catalog)

strategy = TemplateLayoutStrategy(item_template="${collection}/${year}")
Expand Down
Loading