-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: add integration tests #69
Merged
Merged
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
3537795
feat: add integration tests
vincentsarago f1c1d1f
add eoapi-cdk upgrade command and pip cache
emileten aab0acb
test commit, to revert
emileten d9749de
Revert "test commit, to revert"
emileten 1300c4e
update workflow
emileten c47f6d6
update workflow to run when release happens, move tests here
emileten a63c909
instead of cloning the eoapi-template repo, copy the code here so tha…
emileten 6ebc271
trailing wsp
emileten 80f03ba
run action with push to try
emileten 4ff82c2
move the trigger of integration tests to distribute, right before rel…
emileten eb20644
feat!: custom runtime for bootstrapper and custom runtimes from Docke…
emileten 385ab1b
fix a couple bugs found in the first changes
emileten dbcada8
avoid maintaining custom interfaces for configurable lambda propertie…
emileten 7573398
expose bootstrapper props in pgstacdatabase construct constructor
emileten 926a6a1
merge database and boostrapper files to solve casting bug
emileten f725f28
bump and harmonize pypgstac to 0.7.10 across apps
emileten f48e334
bump cachetools
emileten 7b62f2a
some changes to allow for less security
emileten 7c75981
bump python to 3.11
emileten ccfce6b
change base image for bootstrapper to use python 311
emileten a7aea2b
fix linting issues
emileten 9e886a2
Merge branch 'feat/custom-runtimes' into feat/add-integration-tests
emileten b973fbc
Merge branch 'main' into feat/add-integration-tests
emileten 64e67b7
move integration tests to step before release, improve naming of work…
emileten c7904ef
lint
vincentsarago 92b4bf9
fix moto requirement
vincentsarago 97b5a32
test to fix deployment : try adding s3 endpoint and force allow publi…
emileten 4ede0a5
lint and make lambda functions more configurable
emileten b4de035
moving deploy to a separate workflow
emileten 92cec0d
remove useless dependencies in deployment tests, turn on pull request…
emileten b4fe0f6
when tearing down the infrastructure, synthesize the cloud formation …
emileten b08e8b3
update readmes and revive the artifact download in python distribution
emileten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: Deploy & Test Deployment | ||
|
||
permissions: | ||
id-token: write # required for requesting the JWT | ||
contents: read # required for actions/checkout | ||
|
||
on: | ||
# run this workflow when the `Distribute` workflow completes | ||
workflow_run: | ||
workflows: [Distribute] | ||
types: [completed] | ||
# ... or manually. | ||
workflow_dispatch: | ||
|
||
# remove later | ||
push: | ||
branches: | ||
- "feat/add-integration-tests" | ||
|
||
jobs: | ||
# run a job on a successful `Workflow` run. | ||
on-successful-release: | ||
runs-on: ubuntu-latest | ||
env: | ||
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION_DEPLOY }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEPLOY }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEPLOY }} | ||
|
||
|
||
steps: | ||
|
||
- name: Checkout repository # for runs after `Distribute`, pulling from main will always give the latest eoapi-cdk. | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up python | ||
uses: actions/setup-python@v2 | ||
with: | ||
cache: pip | ||
|
||
- name: Set up node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install deployment environment | ||
working-directory: integration_tests/cdk | ||
run: | | ||
python -m venv .deployment_venv | ||
source .deployment_venv/bin/activate | ||
pip install -r requirements.txt | ||
pip install --upgrade eoapi-cdk # make sure to take the latest version of eoapi-cdk since we're integration-testing the newest release. | ||
npm install | ||
deactivate | ||
|
||
- name: Synthesize the stack | ||
working-directory: integration_tests/cdk | ||
run: | | ||
source .deployment_venv/bin/activate | ||
npx cdk synth --debug --all --require-approval never | ||
deactivate | ||
|
||
# deploys and grabs URLs from the output for later tests | ||
- name: Deploy the stack | ||
id: deploy_step | ||
working-directory: integration_tests/cdk | ||
run: | | ||
source .deployment_venv/bin/activate | ||
npx cdk deploy --ci --all --require-approval never | ||
echo "ingestor_url=$(aws cloudformation describe-stacks --stack-name eoapi-template-demo-test-pgSTAC-infra --query "Stacks[0].Outputs[?starts_with(OutputKey, 'stacingestor')].OutputValue | [0]" --output text)" >> $GITHUB_OUTPUT | ||
echo "stac_api_url=$(aws cloudformation describe-stacks --stack-name eoapi-template-demo-test-pgSTAC-infra --query "Stacks[0].Outputs[?starts_with(OutputKey, 'pgstacapi')].OutputValue | [0]" --output text)" >> $GITHUB_OUTPUT | ||
echo "titiler_pgstac_api_url=$(aws cloudformation describe-stacks --stack-name eoapi-template-demo-test-pgSTAC-infra --query "Stacks[0].Outputs[?starts_with(OutputKey, 'titilerpgstac')].OutputValue | [0]" --output text)" >> $GITHUB_OUTPUT | ||
deactivate | ||
|
||
- name: Install test environment | ||
working-directory: integration_tests/tests | ||
run: | | ||
python -m venv .tests_venv | ||
source .tests_venv/bin/activate | ||
pip install -r requirements.txt | ||
deactivate | ||
|
||
- name: Test the stack | ||
working-directory: integration_tests/tests | ||
env: | ||
ingestor_url: ${{ steps.deploy_step.outputs.ingestor_url }} | ||
stac_api_url: ${{ steps.deploy_step.outputs.stac_api_url }} | ||
titiler_pgstac_api_url: ${{ steps.deploy_step.outputs.titiler_pgstac_api_url }} | ||
run: | | ||
source .tests_venv/bin/activate | ||
pytest eoapi_tests | ||
deactivate | ||
|
||
- name: Always tear down the stack | ||
if: always() | ||
working-directory: integration_tests/cdk | ||
run: | | ||
vincentsarago marked this conversation as resolved.
Show resolved
Hide resolved
|
||
source .deployment_venv/bin/activate | ||
npx cdk destroy --ci --all --force | ||
deactivate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ docs | |
__pycache__ | ||
.venv | ||
.tox | ||
tests/*.egg* | ||
tests/*venv* | ||
tests/__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
This is a non-forked version of [eoapi-template](https://github.com/developmentseed/eoapi-template). | ||
|
||
# Deployment CDK code for eoapi-cdk integration tests | ||
|
||
This is a wrapper CDK code that provides the `eoapi-cdk` deployment to run integration tests on the latest releases of the `eoapi-cdk` constructs. | ||
|
||
## Requirements | ||
|
||
- python | ||
- docker | ||
- node | ||
- AWS credentials environment variables configured to point to an account. | ||
- **Optional** a `config.yaml` file to override the default deployment settings defined in `config.py`. | ||
|
||
## Installation | ||
|
||
Install python dependencies with | ||
|
||
``` | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
python -m pip install -r requirements.txt | ||
``` | ||
|
||
Note that `eoapi-cdk` isn't pinned, so that the latest version is always installed. Also install node dependencies with | ||
|
||
``` | ||
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 | ||
``` | ||
|
||
## Deployment | ||
|
||
First, synthesize the app | ||
|
||
``` | ||
npx cdk synth --all | ||
``` | ||
|
||
Then, deploy | ||
|
||
``` | ||
npx cdk deploy --all --require-approval never | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from aws_cdk import App | ||
|
||
from config import build_app_config | ||
from eoapi_template import pgStacInfra, vpc | ||
|
||
app = App() | ||
|
||
app_config = build_app_config() | ||
|
||
vpc_stack = vpc.VpcStack(scope=app, app_config=app_config) | ||
|
||
pgstac_infra_stack = pgStacInfra.pgStacInfraStack( | ||
scope=app, | ||
vpc=vpc_stack.vpc, | ||
app_config=app_config, | ||
) | ||
app.synth() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"app": "python3 app.py", | ||
"watch": { | ||
"include": [ | ||
"**" | ||
], | ||
"exclude": [ | ||
"README.md", | ||
"cdk*.json", | ||
"requirements*.txt", | ||
"source.bat", | ||
"**/*.pyc", | ||
"**/*.tmp", | ||
"**/__pycache__", | ||
"tests", | ||
"scripts", | ||
"*venv" | ||
] | ||
}, | ||
"context": { | ||
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, | ||
"@aws-cdk/core:stackRelativeExports": true, | ||
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true, | ||
"@aws-cdk/aws-lambda:recognizeVersionProps": true, | ||
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, | ||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, | ||
"@aws-cdk/core:target-partitions": [ | ||
"aws", | ||
"aws-cn" | ||
] | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we testing the latest available version on pypi or the one in this repo?
It might be
dangerous
to test the version on pypi because there could be alag
from the push to the publicationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice catch, I hadn't thought of the lag possibility...
However, I'd have to compile the typescript constructs locally to have access to the python modules.
How about setting up this workflow so that it waits (with a timeout) for the latest pypi to match for the latest github tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but then what will it means if the tests fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah 🤦♂️ doesn't make much sense indeed. We should be doing
build -> integration test -> release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets see if @sharkinsspatial or @alukach have opinions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be missing something from the CI logic, but one way to do it could be to add a
job
namedintegration-test
here that reuses thepackage
job's output. We then addintegration-test
as a dependency to both subsequentdistribute-*
jobs so that we're sure releases happen only if integration-tests ran.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, to illustrate the idea, I pushed another commit (can always revert). See 4ff82c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emileten I would recommend relying on the local python modules from the output of the TS build from the
package
output as you outlined in 4ff82c2.