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

Testing of deployment of catalog on pull requests #45

Merged
merged 21 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c7d3c60
feat: adding deployment of test deployments when creating pull reques…
santilland Sep 18, 2023
c9495be
chore: name change
santilland Sep 18, 2023
37298a4
chore: update of workflow name
santilland Sep 18, 2023
66bc5db
feat: adding workflow dispatch option
santilland Sep 18, 2023
96b1675
chore: merged latest main
santilland Sep 18, 2023
207f20d
fix: removed wrong quote symbol in workflow config
santilland Sep 19, 2023
9c8de39
chore: added synchronize to pull request action trigger to also trigg…
santilland Sep 19, 2023
681c037
Merge branch 'main' of github.com:eurodatacube/eodash-catalog into me…
santilland Sep 19, 2023
c6b9a70
fix: changed to use pull_request instead of pull_request_target event…
santilland Sep 19, 2023
892d4bb
fix: updated used version for cp action
santilland Sep 19, 2023
48327ff
chore: changing version to master for cp action
santilland Sep 19, 2023
37b53e3
chore: testing use of artifacts as possible testing deployment
santilland Sep 19, 2023
82d7f53
chore: artifacts not really accessible, retrying bucket with recuresi…
santilland Sep 19, 2023
e40a72e
chore: reverting to using s3 sync
santilland Sep 19, 2023
53d0dd5
feat: using pull request preview for gh-pages to deploy catalog build
santilland Sep 19, 2023
b03a208
chore: reverted catalog definitions
santilland Sep 25, 2023
7276c51
feat: added option to not save items when generating catalog
santilland Sep 25, 2023
c4b4415
chore: reverted to pushing build catalog to bucket, not creating cata…
santilland Sep 25, 2023
98f55d7
chore: removed sync arguments from action, had typo
santilland Sep 25, 2023
7703a60
chore: updated to use different ref name on preview creation; added c…
santilland Sep 25, 2023
07c5f00
chore: trying to get correct branch name for pull request action
santilland Sep 25, 2023
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
23 changes: 7 additions & 16 deletions .github/workflows/build_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,19 @@
name: Deploy test static content to s3 bucket

on:
pull_request_target:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
branches:
- 'main'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "bucket_deploy"
cancel-in-progress: false
concurrency: preview-${{ github.ref }}

jobs:
deploy:
environment:
name: test_deploy
deploy-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -42,15 +35,13 @@ jobs:
SH_CLIENT_SECRET: ${{ secrets.SH_CLIENT_SECRET }}
run: |
cd generators/
python generate_indicators.py
python generate_indicators.py -ni
# Upload build to S3
- name: sync client s3
uses: jakejarvis/[email protected]
with:
args: --delete --follow-symlinks
env:
SOURCE_DIR: 'build'
DEST_DIR: 'catalog/${GITHUB_REF##*/}'
DEST_DIR: 'catalog/${{ github.event.pull_request.head.ref }}'
AWS_REGION: 'eu-central-1'
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/test_deploy_cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Delete catalog test deployment when pull request is closed / deleted

on:
pull_request:
types:
- closed
branches:
- 'main'

jobs:
delete_folder:
runs-on: ubuntu-latest
steps:
# Set up AWS credentials
- name: Set up AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1

# Delete the folder from the S3 bucket
- name: Delete folder from S3
run: |
aws s3 rm s3://${{ secrets.AWS_S3_BUCKET }}/catalog/${{ github.event.pull_request.head.ref }} --recursive
27 changes: 23 additions & 4 deletions generators/generate_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Indicator generator to harvest information from endpoints and generate catalog

"""

import time
import requests
import json
from pystac_client import Client
Expand Down Expand Up @@ -46,7 +46,17 @@
as possible and generating a STAC catalog with the information''',
)

argparser.add_argument("-vd", action="store_true", help="if flag set validation will be run on generated catalogs")
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")

def recursive_save(stac_object, no_items=False):
stac_object.save_object()
for child in stac_object.get_children():
recursive_save(child, no_items)
if not no_items:
# try to save items if available
for item in stac_object.get_items():
item.save_object()

def process_catalog_file(file_path, options):
print("Processing catalog:", file_path)
Expand All @@ -62,9 +72,18 @@ def process_catalog_file(file_path, options):
process_collection_file(config, "../collections/%s.yaml"%(collection), catalog)

strategy = TemplateLayoutStrategy(item_template="${collection}/${year}")
catalog.normalize_hrefs(config["endpoint"], strategy=strategy)
catalog.save(dest_href="../build/%s"%config["id"])
catalog.normalize_hrefs("../build/%s"%config["id"], strategy=strategy)

print("Started creation of collection files")
start = time.time()
if options.ni:
recursive_save(catalog, options.ni)
else:
# For full catalog save with items this still seems to be faster
catalog.save(dest_href="../build/%s"%config["id"])
end = time.time()
print("Time consumed in saving: ", end - start)

if options.vd:
# try to validate catalog if flag was set
print("Running validation of catalog %s"%file_path)
Expand Down