Skip to content

Commit

Permalink
chore: add pre-commit lint to remove trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed May 14, 2024
1 parent c7a4b0e commit af726bd
Show file tree
Hide file tree
Showing 22 changed files with 114 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "VS Code DEV Container for AWS CDK development",
"image": "jsii/superchain:1-buster-slim-node16"
}
}
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## :warning: Checklist if your PR is changing anything else than documentation
- [ ] Posted the link to a successful manually triggered deployment workflow (successful including the resources destruction)

## Merge request description
## Merge request description
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
required: false
DS_RELEASE_BOT_PRIVATE_KEY:
required: false

jobs:
build_and_package:
name: Build and package
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deployment

on:
workflow_dispatch:

jobs:
build_package_and_deploy:
name: Build, package and deploy
Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Generate distribution packages
run: npm run package


- name: Install deployment environment
id: install_deploy_env
run: |
Expand All @@ -40,7 +40,7 @@ jobs:
pip install dist/python/*.gz
cd integration_tests/cdk
pip install -r requirements.txt
npm install
npm install
deactivate
cd -
Expand All @@ -56,7 +56,7 @@ jobs:
PROJECT_ID: ${{ steps.short-sha.outputs.sha }}
run: |
source .deployment_venv/bin/activate
# synthesize the stack
cd integration_tests/cdk
npx cdk synth --debug --all --require-approval never
Expand All @@ -65,7 +65,7 @@ jobs:
npx cdk deploy --ci --all --require-approval never
deactivate
cd -
- name: Tear down any infrastructure
if: always()
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/distribute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
name: python
path: dist

- run: pip install twine

- run: twine upload dist/*
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
push:
branches:
- main
pull_request:

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

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ __pycache__
.tox
tests/*.egg*
tests/*venv*
tests/__pycache__
tests/__pycache__
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

# Optionally both commit and push
default_stages: [commit]

# Regex for files to exclude
# Don't lint the generated JSON metadata files
exclude: "diagrams/"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ _Warning_: If you rebase `main`, you must ensure that the commits referenced by

## Tests

Each pull request to `main` is added to a [merge queue](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue#triggering-merge-group-checks-with-github-actions) so that a "deployment test" workflow can run before the merge actually happens. If the deployment fails, the merge is cancelled. Here is [the definition of this workflow](https://github.com/developmentseed/eoapi-cdk/blob/main/.github/workflows/deploy.yaml) and the [tests definition](https://github.com/developmentseed/eoapi-cdk/blob/main/tests).
Each pull request to `main` is added to a [merge queue](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue#triggering-merge-group-checks-with-github-actions) so that a "deployment test" workflow can run before the merge actually happens. If the deployment fails, the merge is cancelled. Here is [the definition of this workflow](https://github.com/developmentseed/eoapi-cdk/blob/main/.github/workflows/deploy.yaml) and the [tests definition](https://github.com/developmentseed/eoapi-cdk/blob/main/tests).
10 changes: 5 additions & 5 deletions integration_tests/cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ This is a wrapper CDK code that is used to test a deployment of the `eoapi-cdk`
- python
- docker
- node
- AWS credentials environment variables configured to point to an account.
- AWS credentials environment variables configured to point to an account.

## Installation

Install python dependencies with
Install python dependencies with

```
python -m venv .venv
Expand All @@ -28,7 +28,7 @@ pip install eoapi-cdk

Or alternatively, compile and package from the root of this repository to get the python version of the constructs locally.

Also install node dependencies with
Also install node dependencies with

```
npm install
Expand All @@ -42,7 +42,7 @@ npx cdk --version

## Deployment

First, synthesize the app
First, synthesize the app

```
npx cdk synth --all
Expand All @@ -52,4 +52,4 @@ Then, deploy

```
npx cdk deploy --all --require-approval never
```
```
2 changes: 1 addition & 1 deletion integration_tests/cdk/cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
"aws-cn"
]
}
}
}
1 change: 0 additions & 1 deletion integration_tests/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
"aws-cdk": "2.130.0"
}
}

2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export * from "./stac-api";
export * from "./titiler-pgstac-api";
export * from "./stac-browser";
export * from "./tipg-api";
export * from "./utils";
export * from "./utils";
14 changes: 7 additions & 7 deletions lib/ingestor-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class StacIngestor extends Construct {
),
],
});

const handler = this.buildApiLambda({
table: this.table,
env,
Expand Down Expand Up @@ -113,7 +113,7 @@ export class StacIngestor extends Construct {
subnetSelection: undefined | ec2.SubnetSelection
lambdaFunctionOptions?: CustomLambdaFunctionProps;
}): lambda.Function {

const handler = new lambda.Function(this, "api-handler", {
// defaults
runtime: lambda.Runtime.PYTHON_3_11,
Expand Down Expand Up @@ -162,7 +162,7 @@ export class StacIngestor extends Construct {
lambdaFunctionOptions?: CustomLambdaFunctionProps;
}): lambda.Function {


const handler = new lambda.Function(this, "stac-ingestor",{
// defaults
runtime: lambda.Runtime.PYTHON_3_11,
Expand Down Expand Up @@ -319,17 +319,17 @@ export interface StacIngestorProps {
readonly ingestorDomainNameOptions?: apigateway.DomainNameOptions;

/**
* Can be used to override the default lambda function properties.
* Can be used to override the default lambda function properties.
*
* @default - default settings are defined in the construct.
*/
readonly apiLambdaFunctionOptions?: CustomLambdaFunctionProps;

/**
* Can be used to override the default lambda function properties.
* Can be used to override the default lambda function properties.
*
* @default - default settings are defined in the construct.
*/
readonly ingestorLambdaFunctionOptions?: CustomLambdaFunctionProps;
}

}
2 changes: 1 addition & 1 deletion lib/ingestor-api/runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUN python -m pip install -r requirements.txt "mangum>=0.14,<0.15" -t /asset --n
RUN mkdir -p /asset/src
COPY runtime/src/*.py /asset/src/

CMD ["echo", "hello world"]
CMD ["echo", "hello world"]
5 changes: 2 additions & 3 deletions lib/stac-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class PgStacApiLambda extends Construct {

constructor(scope: Construct, id: string, props: PgStacApiLambdaProps) {
super(scope, id);

console.log(props)
console.log(props.lambdaFunctionOptions);
this.stacApiLambdaFunction = new lambda.Function(this, "lambda", {
Expand Down Expand Up @@ -51,7 +51,7 @@ export class PgStacApiLambda extends Construct {
this.stacApiLambdaFunction.connections.allowTo(props.db, ec2.Port.tcp(5432));
}
const stacApi = new HttpApi(this, `${Stack.of(this).stackName}-stac-api`, {
defaultDomainMapping: props.stacApiDomainName ? {
defaultDomainMapping: props.stacApiDomainName ? {
domainName: props.stacApiDomainName
} : undefined,
defaultIntegration: new HttpLambdaIntegration("integration", this.stacApiLambdaFunction),
Expand Down Expand Up @@ -104,4 +104,3 @@ export interface PgStacApiLambdaProps {
*/
readonly lambdaFunctionOptions?: CustomLambdaFunctionProps;
}

2 changes: 1 addition & 1 deletion lib/stac-api/runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN python -m pip install -r requirements.txt "mangum>=0.14,<0.15" -t /asset --n
RUN mkdir -p /asset/src
COPY runtime/src/*.py /asset/src/

CMD ["echo", "hello world"]
CMD ["echo", "hello world"]
2 changes: 1 addition & 1 deletion lib/stac-api/runtime/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ stac-fastapi.pgstac==2.4.8
stac-fastapi.types==2.4.8
# https://github.com/stac-utils/stac-fastapi/pull/466
pygeoif==0.7
starlette_cramjam
starlette_cramjam
26 changes: 13 additions & 13 deletions lib/stac-browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export class StacBrowser extends Construct {
websiteIndexDocument: props.websiteIndexDocument
})
}

// if props.cloudFrontDistributionArn is defined and props.bucketArn is not defined, add a bucket policy to allow read access from the cloudfront distribution
if (props.cloudFrontDistributionArn && !props.bucketArn) {
this.bucket.addToResourcePolicy(new PolicyStatement({
sid: 'AllowCloudFrontServicePrincipal',
effect: Effect.ALLOW,
effect: Effect.ALLOW,
actions: ['s3:GetObject'],
principals: [new ServicePrincipal('cloudfront.amazonaws.com')],
resources: [this.bucket.arnForObjects('*')],
Expand All @@ -44,7 +44,7 @@ export class StacBrowser extends Construct {
}
}));
}

// add the compiled code to the bucket as a bucket deployment
this.bucketDeployment = new s3_deployment.BucketDeployment(this, 'BucketDeployment', {
destinationBucket: this.bucket,
Expand All @@ -59,12 +59,12 @@ export class StacBrowser extends Construct {
}

private buildApp(props: StacBrowserProps, cloneDirectory: string): string {

// Define where to clone and build
const githubRepoUrl = 'https://github.com/radiantearth/stac-browser.git';


// Maybe the repo already exists in cloneDirectory. Try checking out the desired version and if it fails, delete and reclone.
// Maybe the repo already exists in cloneDirectory. Try checking out the desired version and if it fails, delete and reclone.
try {
console.log(`Checking if a valid cloned repo exists with version ${props.githubRepoTag}...`)
execSync(`git checkout tags/${props.githubRepoTag}`, { cwd: cloneDirectory });
Expand Down Expand Up @@ -116,17 +116,17 @@ export class StacBrowser extends Construct {
export interface StacBrowserProps {

/**
* Bucket ARN. If specified, the identity used to deploy the stack must have the appropriate permissions to create a deployment for this bucket.
* Bucket ARN. If specified, the identity used to deploy the stack must have the appropriate permissions to create a deployment for this bucket.
* In addition, if specified, `cloudFrontDistributionArn` is ignored since the policy of an imported resource can't be modified.
*
*
* @default - No bucket ARN. A new bucket will be created.
*/

readonly bucketArn?: string;

/**
* STAC catalog URL. Overrides the catalog URL in the stac-browser configuration.
*/
*/
readonly stacCatalogUrl: string;

/**
Expand All @@ -144,11 +144,11 @@ export interface StacBrowserProps {
/**
* The ARN of the cloudfront distribution that will be added to the bucket policy with read access.
* If `bucketArn` is specified, this parameter is ignored since the policy of an imported bucket can't be modified.
*
*
* @default - No cloudfront distribution ARN. The bucket policy will not be modified.
*/
*/
readonly cloudFrontDistributionArn?: string;

/**
* The name of the index document (e.g. "index.html") for the website. Enables static website
* hosting for this bucket.
Expand All @@ -158,8 +158,8 @@ export interface StacBrowserProps {
readonly websiteIndexDocument?: string;

/**
* Location in the filesystem where to compile the browser code.
*
* Location in the filesystem where to compile the browser code.
*
* @default - DEFAULT_CLONE_DIRECTORY
*/
readonly cloneDirectory?: string;
Expand Down
10 changes: 5 additions & 5 deletions lib/tipg-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
this.tiPgLambdaFunction.connections.allowTo(props.db, ec2.Port.tcp(5432), "allow connections from tipg");
}
const tipgApi = new HttpApi(this, `${Stack.of(this).stackName}-tipg-api`, {
defaultDomainMapping: props.tipgApiDomainName ? {
defaultDomainMapping: props.tipgApiDomainName ? {
domainName: props.tipgApiDomainName
} : undefined,
defaultIntegration: new HttpLambdaIntegration("integration", this.tiPgLambdaFunction),
Expand Down Expand Up @@ -91,11 +91,11 @@ import {
* Customized environment variables to send to titiler-pgstac runtime.
*/
readonly apiEnv?: Record<string, string>;

/**
* Custom Domain Name for tipg API. If defined, will create the
* domain name and integrate it with the tipg API.
*
* Custom Domain Name for tipg API. If defined, will create the
* domain name and integrate it with the tipg API.
*
* @default - undefined
*/
readonly tipgApiDomainName?: IDomainName;
Expand Down
Loading

0 comments on commit af726bd

Please sign in to comment.