Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
36 changes: 36 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Unit tests

on:
workflow_dispatch:
push:
branches:
- main
tags:
- 'v*'
pull_request:

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.7.*"
enable-cache: true

- name: Install PostgreSQL and PostGIS
run: |
sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib postgresql-16-postgis-3
sudo service postgresql start
pg_isready

- name: Install dependencies
run: |
uv sync

- name: Run tests
run: uv run pytest
18 changes: 18 additions & 0 deletions integration_tests/cdk/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
PgStacApiLambda,
PgStacDatabase,
StacIngestor,
StacItemGenerator,
StacItemLoader,
TiPgApiLambda,
TitilerPgstacApiLambda,
)
Expand Down Expand Up @@ -168,6 +170,22 @@ def __init__(
},
)

self.stac_item_loader = StacItemLoader(
self,
"stac-item-loader",
pgstac_db=pgstac_db,
)

self.stac_item_generator = StacItemGenerator(
self,
"stac-item-generator",
item_load_topic_arn=self.stac_item_loader.topic.topic_arn,
)

self.stac_item_loader.topic.grant_publish(
self.stac_item_generator.lambda_function
)


app = App()

Expand Down
79 changes: 40 additions & 39 deletions integration_tests/cdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions integration_tests/cdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eoapi-template",
"version": "0.1.0",
"dependencies": {
"aws-cdk": "2.130.0"
}
"name": "eoapi-template",
"version": "0.1.0",
"dependencies": {
"aws-cdk": "2.1016.1"
}
}
2 changes: 1 addition & 1 deletion integration_tests/cdk/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aws-cdk-lib==2.130.0
aws-cdk-lib==2.190.0
constructs==10.3.0
pydantic==2.0.2
pydantic-settings==2.0.1
Expand Down
9 changes: 6 additions & 3 deletions lib/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class PgStacDatabase extends Construct {
pgstacSecret: secretsmanager.ISecret;
private _pgBouncerServer?: PgBouncer;

public readonly pgstacVersion: string;
public readonly connectionTarget: rds.IDatabaseInstance | ec2.Instance;
public readonly securityGroup?: ec2.SecurityGroup;
public readonly secretBootstrapper?: CustomResource;
Expand Down Expand Up @@ -68,7 +69,9 @@ export class PgStacDatabase extends Construct {
parameterGroup,
...props,
});
const pgstac_version = props.pgstacVersion || DEFAULT_PGSTAC_VERSION;

this.pgstacVersion = props.pgstacVersion || DEFAULT_PGSTAC_VERSION;

const handler = new aws_lambda.Function(this, "lambda", {
// defaults
runtime: aws_lambda.Runtime.PYTHON_3_11,
Expand All @@ -80,7 +83,7 @@ export class PgStacDatabase extends Construct {
file: "bootstrapper_runtime/Dockerfile",
buildArgs: {
PYTHON_VERSION: "3.11",
PGSTAC_VERSION: pgstac_version,
PGSTAC_VERSION: this.pgstacVersion,
},
}),
vpc: hasVpc(this.db) ? this.db.vpc : props.vpc,
Expand Down Expand Up @@ -131,7 +134,7 @@ export class PgStacDatabase extends Construct {

// if props.lambdaFunctionOptions doesn't have 'code' defined, update pgstac_version (needed for default runtime)
if (!props.bootstrapperLambdaFunctionOptions?.code) {
customResourceProperties["pgstac_version"] = pgstac_version;
customResourceProperties["pgstac_version"] = this.pgstacVersion;
}

// add timestamp to properties to ensure the Lambda gets re-executed on each deploy
Expand Down
2 changes: 2 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export * from "./bastion-host";
export * from "./database";
export * from "./ingestor-api";
export * from "./stac-item-generator";
export * from "./stac-item-loader";
export * from "./stac-api";
export * from "./titiler-pgstac-api";
export * from "./stac-browser";
Expand Down
Loading
Loading