Skip to content

Commit

Permalink
updates for deployment via gh actions (#19)
Browse files Browse the repository at this point in the history
* add deploy job to ci.yaml

* upgrade aws-cdk in package.json

* Upgrade to new version of aws credentials action
  • Loading branch information
hrodmn authored Feb 3, 2025
1 parent bc93177 commit 8587437
Show file tree
Hide file tree
Showing 8 changed files with 967 additions and 34 deletions.
75 changes: 58 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
- '.github/workflows/ci.yml'
- '.pre-commit-config.yaml'
pull_request:
workflow_dispatch:
release:
types: [published]

jobs:
tests:
Expand All @@ -21,32 +24,23 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- uses: astral-sh/setup-uv@v5
- name: Install
run: uv sync
- name: Run pre-commit
run: |
python -m pip install --upgrade pip
python -m pip install pre-commit
pre-commit run --all-files
run: uv run pre-commit run --all-files

- name: Launch services
run: docker compose up -d

- name: install lib postgres
uses: nyurik/action-setup-postgis@v2

- name: Install python dependencies
run: |
python -m pip install pytest httpx pypgstac==0.9.2 psycopg[pool]
- name: Ingest Stac Items/Collection
run: |
pypgstac pgready --dsn postgresql://username:[email protected]:5439/postgis
pypgstac load collections .github/workflows/data/noaa-emergency-response.json --dsn postgresql://username:[email protected]:5439/postgis --method insert_ignore
pypgstac load items .github/workflows/data/noaa-eri-nashville2020.json --dsn postgresql://username:[email protected]:5439/postgis --method insert_ignore
uv run pypgstac pgready --dsn postgresql://username:[email protected]:5439/postgis
uv run pypgstac load collections .github/workflows/data/noaa-emergency-response.json --dsn postgresql://username:[email protected]:5439/postgis --method insert_ignore
uv run pypgstac load items .github/workflows/data/noaa-eri-nashville2020.json --dsn postgresql://username:[email protected]:5439/postgis --method insert_ignore
psql postgresql://username:[email protected]:5439/postgis -f .github/workflows/data/my_data.sql
# see https://github.com/developmentseed/tipg/issues/37
Expand All @@ -59,7 +53,54 @@ jobs:
shell: bash

- name: Integrations tests
run: python -m pytest .github/workflows/tests/
run: uv run pytest .github/workflows/tests/

- name: Stop services
run: docker compose stop

deploy:
name: Deploy
environment: dev
needs: [tests]
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
env:
STACK_NAME: eoapi-dev

steps:

- uses: actions/checkout@v4

- name: Create config file
run: |
echo "${{ vars.CONFIG_YAML }}" > config.yaml
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::390960605471:role/eoapi-devseed
role-session-name: eoapi-devseed
aws-region: us-west-2

- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 22

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: |
uv sync --only-group deploy
uv run --only-group deploy npm install
- name: CDK Synth
run: uv run --only-group deploy npm run cdk -- synth

- name: CDK Deploy
run: |
uv run --only-group deploy npm run cdk -- deploy --require-approval never
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
args: ["-m", "3","--trailing-comma", "-l", "88"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
rev: v0.9.4
hooks:
- id: ruff
args: ["--fix"]
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ Once the applications are *up*, you'll need to add STAC **Collections** and **It

Then you can start exploring your dataset with:

- the STAC Metadata service [http://localhost:8081](http://localhost:8081)
- the Raster service [http://localhost:8082](http://localhost:8082)
- the browser UI [http://localhost:8085](http://localhost:8085)
- the STAC Metadata service [http://localhost:8081](http://localhost:8081)
- the Raster service [http://localhost:8082](http://localhost:8082)
- the browser UI [http://localhost:8085](http://localhost:8085)

If you've added a vector dataset to the `public` schema in the Postgres database, they will be available through the **Vector** service at [http://localhost:8083](http://localhost:8083).

Expand All @@ -85,31 +85,32 @@ If you've added a vector dataset to the `public` schema in the Postgres database
Install python dependencies with

```
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
uv sync --group deploy
```

> [!NOTE]
> [install `uv`](https://docs.astral.sh/uv/getting-started/installation/#installing-uv)
And node dependencies with

```
npm install
uv run npm install
```

Verify that the `cdk` CLI is available. Since `aws-cdk` is installed as a local dependency, you can use the `npx` node package runner tool, that comes with `npm`.

```
npx cdk --version
uv run npx cdk --version
```

First, synthesize the app

```
npx cdk synth --all
uv run npx cdk synth --all
```

Then, deploy

```
npx cdk deploy --all --require-approval never
uv run npx cdk deploy --all --require-approval never
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "eoapi-template",
"version": "0.1.0",
"dependencies": {
"aws-cdk": "2.130.0"
"aws-cdk": "^2.177.0"
}
}
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[project]
name = "eoapi-devseed"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = []

[dependency-groups]
deploy = [
"boto3==1.24.15",
"eoapi-cdk==7.4.1",
"pydantic-settings[yaml]==2.2.1",
"pydantic==2.7",
"typing-extensions>=4.12.2",
]
dev = [
"httpx>=0.28.1",
"pre-commit>=4.1.0",
"psycopg[pool]>=3.2.4",
"pypgstac==0.9.2",
"pytest>=8.3.4",
]
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

Loading

0 comments on commit 8587437

Please sign in to comment.