Skip to content

Commit 01816fe

Browse files
committed
move integration tests to step before release, improve naming of workflows
1 parent b973fbc commit 01816fe

File tree

12 files changed

+131
-140
lines changed

12 files changed

+131
-140
lines changed

.github/workflows/build.yaml

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,30 @@ on:
1212
required: false
1313
DS_RELEASE_BOT_PRIVATE_KEY:
1414
required: false
15-
15+
AWS_DEFAULT_REGION_DEPLOY:
16+
required: false
17+
AWS_ACCESS_KEY_ID_DEPLOY:
18+
required: false
19+
AWS_SECRET_ACCESS_KEY_DEPLOY:
20+
required: false
21+
AWS_ACCOUNT_ID:
22+
required: false
1623
jobs:
1724
build_and_package:
1825
name: Build and package
1926
runs-on: ubuntu-latest
27+
timeout-minutes: 60
28+
env:
29+
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION_DEPLOY }}
30+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEPLOY }}
31+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEPLOY }}
32+
AWS_DEFAULT_ACCOUNT: ${{ secrets.AWS_ACCOUNT_ID }}
2033
steps:
2134
- uses: actions/checkout@v3
2235

2336
- uses: actions/setup-node@v3
2437
with:
25-
node-version: 16
38+
node-version: 18
2639
cache: "npm"
2740

2841
- name: Install Dependencies
@@ -65,8 +78,86 @@ jobs:
6578
app_id: ${{ secrets.DS_RELEASE_BOT_ID }}
6679
private_key: ${{ secrets.DS_RELEASE_BOT_PRIVATE_KEY }}
6780

68-
- name: Maybe Release 🚀
81+
- name: Check release
82+
id: check_release
6983
if: ${{ inputs.release }}
84+
run: |
85+
SHOULD_RELEASE=false
86+
npm run semantic-release --dry-run > check_release_output.txt
87+
if grep -q "Published release" check_release_output.txt; then
88+
echo "SHOULD_RELEASE=true" >> $GITHUB_OUTPUT
89+
else
90+
echo "SHOULD_RELEASE=false" >> $GITHUB_OUTPUT
91+
fi
92+
93+
- name: Install deployment environment
94+
if: "${{ inputs.release && steps.check_release.outputs.SHOULD_RELEASE }}"
95+
id: install_deploy_env
96+
run: |
97+
# install deployment environment with eoapi-cdk from build
98+
python -m venv .deployment_venv
99+
source .deployment_venv/bin/activate
100+
pip install dist/python/*.gz
101+
cd integration_tests/cdk
102+
pip install -r requirements.txt
103+
npm install
104+
deactivate
105+
cd -
106+
107+
108+
- name: Deploy test stack
109+
if: "${{ inputs.release && steps.check_release.outputs.SHOULD_RELEASE }}"
110+
id: deploy_step
111+
run: |
112+
source .deployment_venv/bin/activate
113+
114+
# synthesize the stack
115+
cd integration_tests/cdk
116+
npx cdk synth --debug --all --require-approval never
117+
118+
# deploy the stack and grab URLs for testing
119+
npx cdk deploy --ci --all --require-approval never
120+
echo "ingestor_url=$(aws cloudformation describe-stacks --stack-name eoapi-cdk-integration-test-pgSTAC-infra --query "Stacks[0].Outputs[?starts_with(OutputKey, 'stacingestor')].OutputValue | [0]" --output text)" >> $GITHUB_OUTPUT
121+
echo "stac_api_url=$(aws cloudformation describe-stacks --stack-name eoapi-cdk-integration-test-pgSTAC-infra --query "Stacks[0].Outputs[?starts_with(OutputKey, 'pgstacapi')].OutputValue | [0]" --output text)" >> $GITHUB_OUTPUT
122+
echo "titiler_pgstac_api_url=$(aws cloudformation describe-stacks --stack-name eoapi-cdk-integration-test-pgSTAC-infra --query "Stacks[0].Outputs[?starts_with(OutputKey, 'titilerpgstac')].OutputValue | [0]" --output text)" >> $GITHUB_OUTPUT
123+
deactivate
124+
cd -
125+
126+
- name: Run integration tests
127+
id: run_tests
128+
if: "${{ inputs.release && steps.check_release.outputs.SHOULD_RELEASE }}"
129+
env:
130+
ingestor_url: ${{ steps.deploy_step.outputs.ingestor_url }}
131+
stac_api_url: ${{ steps.deploy_step.outputs.stac_api_url }}
132+
titiler_pgstac_api_url: ${{ steps.deploy_step.outputs.titiler_pgstac_api_url }}
133+
run: |
134+
cd integration_tests/tests
135+
python -m venv .tests_venv
136+
source .tests_venv/bin/activate
137+
pip install -e .
138+
pytest eoapi_tests
139+
deactivate
140+
cd -
141+
142+
- name: Tear down any infrastructure
143+
if: always()
144+
run: |
145+
cd integration_tests/cdk
146+
# run this only if we find a 'cdk.out' directory, which means there might be things to tear down
147+
if [ -d "cdk.out" ]; then
148+
cd -
149+
source .deployment_venv/bin/activate
150+
cd integration_tests/cdk
151+
# see https://github.com/aws/aws-cdk/issues/24946
152+
rm -f cdk.out/synth.lock
153+
npx cdk destroy --ci --all --force
154+
fi
155+
156+
157+
# run if the previous step set SHOULD_RELEASE to true
158+
- name: Maybe Release 🚀
159+
# only run if the previous step set SHOULD_RELEASE to true
160+
if: "${{ inputs.release && steps.check_release.outputs.SHOULD_RELEASE }}"
70161
run: |
71162
npm run semantic-release
72163
env:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build & try to release
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
package:
8+
uses: ./.github/workflows/build.yaml
9+
with:
10+
release: true
11+
secrets:
12+
DS_RELEASE_BOT_ID: ${{ secrets.DS_RELEASE_BOT_ID }}
13+
DS_RELEASE_BOT_PRIVATE_KEY: ${{ secrets.DS_RELEASE_BOT_PRIVATE_KEY }}
14+
AWS_DEFAULT_REGION_DEPLOY: ${{ secrets.AWS_DEFAULT_REGION_DEPLOY }}
15+
AWS_ACCESS_KEY_ID_DEPLOY: ${{ secrets.AWS_ACCESS_KEY_ID_DEPLOY }}
16+
AWS_SECRET_ACCESS_KEY_DEPLOY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEPLOY }}
17+
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}

.github/workflows/distribute.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ jobs:
99
package:
1010
uses: ./.github/workflows/build.yaml
1111

12-
integration-test:
13-
uses: ./.github/workflows/integration-test.yaml
14-
needs: package
15-
1612
distribute-python:
1713
runs-on: ubuntu-latest
1814
needs: package

.github/workflows/integration-test.yaml

Lines changed: 0 additions & 104 deletions
This file was deleted.

.github/workflows/test.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.

integration_tests/cdk/config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
import yaml
55
from aws_cdk import aws_ec2
66
from pydantic_core.core_schema import FieldValidationInfo
7-
from pydantic_settings import BaseSettings
8-
7+
from pydantic_settings import BaseSettings, SettingsConfigDict
98

109
class AppConfig(BaseSettings):
10+
model_config = SettingsConfigDict(
11+
env_file=".env"
12+
)
13+
aws_default_account: str = pydantic.Field(
14+
description="AWS account ID"
15+
)
1116
project_id: str = pydantic.Field(
12-
description="Project ID", default="eoapi-template-demo"
17+
description="Project ID", default="eoapi-cdk-integration"
1318
)
1419
stage: str = pydantic.Field(description="Stage of deployment", default="test")
1520
# because of its validator, `tags` should always come after `project_id` and `stage`

integration_tests/cdk/eoapi_template/pgStacInfra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def __init__(
232232
# must be already set up, or set up after this deployment.
233233
if not app_config.data_access_role_arn:
234234
data_access_role = self._grant_assume_role_with_principal_pattern(
235-
data_access_role, stac_ingestor.handler_role.role_name
235+
data_access_role, stac_ingestor.handler_role.role_name, app_config.aws_default_account
236236
)
237237

238238
def _create_data_access_role(self) -> aws_iam.Role:
@@ -261,7 +261,7 @@ def _grant_assume_role_with_principal_pattern(
261261
self,
262262
role_to_assume: aws_iam.Role,
263263
principal_pattern: str,
264-
account_id: str = boto3.client("sts").get_caller_identity().get("Account"),
264+
account_id: str,
265265
) -> aws_iam.Role:
266266
"""
267267
Grants assume role permissions to the role of the given

integration_tests/cdk/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration_tests/cdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "eoapi-template",
33
"version": "0.1.0",
44
"dependencies": {
5-
"aws-cdk": "^2.81.0"
5+
"aws-cdk": "^2.99.1"
66
}
77
}
88

integration_tests/cdk/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
aws-cdk-lib>=2.75.0
2-
aws_cdk.aws_cognito_identitypool_alpha>=2.75.0a0
3-
aws-cdk.aws-apigatewayv2-alpha==2.95.1a0
1+
aws-cdk-lib>=2.99.1
2+
aws_cdk.aws_cognito_identitypool_alpha>=2.99.0a0
3+
aws-cdk.aws-apigatewayv2-alpha>=2.99.0a0
44
constructs>=10.0.0,<11.0.0
55
pydantic==2.0.2
66
pydantic-settings==2.0.1

lib/database/bootstrapper_runtime/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def send(
5858
headers = {"content-type": "", "content-length": str(len(json_responseBody))}
5959

6060
try:
61-
response = httpx.put(responseUrl, data=json_responseBody, headers=headers)
61+
response = httpx.put(responseUrl, data=json_responseBody, headers=headers, timeout=30)
6262
print("Status code: " + response.status_code)
6363
except Exception as e:
6464
print("send(..) failed executing httpx.put(..): " + str(e))

lib/database/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ export class PgStacDatabase extends Construct {
7373
// overwrites defaults with user-provided configurable properties
7474
...props.bootstrapperLambdaFunctionOptions,
7575
// Non configurable properties that are going to be overwritten even if provided by the user
76-
vpc: hasVpc(this.db) ? this.db.vpc : props.vpc,
77-
allowPublicSubnet: true
76+
vpc: hasVpc(this.db) ? this.db.vpc : props.vpc
7877
});
7978

8079
this.pgstacSecret = new secretsmanager.Secret(this, "bootstrappersecret", {

0 commit comments

Comments
 (0)