From 1b71368bfcd4941c4687a2ed699b269e83490718 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Wed, 14 Aug 2024 17:40:54 +0000 Subject: [PATCH 01/13] mark the git repo as safe --- .devcontainer/devcontainer.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 889854d..4ba79b3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,9 +10,6 @@ }, "ghcr.io/devcontainers/features/aws-cli:1": {} }, - "postCreateCommand": [ - "pip install --user -U pre-commit && pre-commit install-hooks", - "npm install -g aws-cdk@2.151.0" - ], + "postCreateCommand": "npm install -g aws-cdk@2.151.0 && pip install --user -U pre-commit && git config --global --add safe.directory \"$PWD\" && pre-commit install-hooks", "shutdownAction": "stopContainer" } From 8314dc8dcbb84663c792756ecacec84636c971a0 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Wed, 14 Aug 2024 15:16:41 -0700 Subject: [PATCH 02/13] add tools/setup.sh --- .devcontainer/devcontainer.json | 2 +- requirements-dev.txt | 3 ++- tools/setup.sh | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 tools/setup.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4ba79b3..3746fd1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,6 +10,6 @@ }, "ghcr.io/devcontainers/features/aws-cli:1": {} }, - "postCreateCommand": "npm install -g aws-cdk@2.151.0 && pip install --user -U pre-commit && git config --global --add safe.directory \"$PWD\" && pre-commit install-hooks", + "postCreateCommand": "./tools/setup.sh", "shutdownAction": "stopContainer" } diff --git a/requirements-dev.txt b/requirements-dev.txt index 9270945..269e644 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1 +1,2 @@ -pytest==6.2.5 +pre-commit==3.8.0 +pytest==6.2.5 \ No newline at end of file diff --git a/tools/setup.sh b/tools/setup.sh new file mode 100755 index 0000000..386a83b --- /dev/null +++ b/tools/setup.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Safer bash scripts +set -euxo pipefail + +npm install -g aws-cdk@2.151.0 + +pip install --upgrade pip +pip install -r requirements.txt -r requirements-dev.txt + +git config --global --add safe.directory "$PWD" +pre-commit install-hooks \ No newline at end of file From 899b15cc14f98f4dc62a0ca205e726a3525ceb36 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Wed, 14 Aug 2024 15:21:33 -0700 Subject: [PATCH 03/13] add new line --- tools/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/setup.sh b/tools/setup.sh index 386a83b..3b4bceb 100755 --- a/tools/setup.sh +++ b/tools/setup.sh @@ -9,4 +9,4 @@ pip install --upgrade pip pip install -r requirements.txt -r requirements-dev.txt git config --global --add safe.directory "$PWD" -pre-commit install-hooks \ No newline at end of file +pre-commit install-hooks From 5c2f3ec31c90d5dd146a3fd0ed9ce0123faa8a9a Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Wed, 14 Aug 2024 22:24:42 +0000 Subject: [PATCH 04/13] add new line --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 269e644..320d403 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,2 @@ pre-commit==3.8.0 -pytest==6.2.5 \ No newline at end of file +pytest==6.2.5 From ef53facbbaf76642f25acf10eae0bdf8809ccd49 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 15 Aug 2024 16:44:28 +0000 Subject: [PATCH 05/13] add FOO --- FOO | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 FOO diff --git a/FOO b/FOO new file mode 100644 index 0000000..e69de29 From 27dfcfd5f81b83985bb7fe3b6e8af46bf97f61df Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 15 Aug 2024 16:54:01 +0000 Subject: [PATCH 06/13] add BAR --- BAR | 1 + 1 file changed, 1 insertion(+) create mode 100644 BAR diff --git a/BAR b/BAR new file mode 100644 index 0000000..ba578e4 --- /dev/null +++ b/BAR @@ -0,0 +1 @@ +BAR From 949172241c6ced21dfdb9d080fbe8500eabe7ff0 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 15 Aug 2024 20:07:27 +0000 Subject: [PATCH 07/13] add PLOP --- PLOP | 1 + 1 file changed, 1 insertion(+) create mode 100644 PLOP diff --git a/PLOP b/PLOP new file mode 100644 index 0000000..8f81a50 --- /dev/null +++ b/PLOP @@ -0,0 +1 @@ +PLOP From 7cb22b0ffa03f2cd1168fb8126c8c21ef56c0ee6 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 15 Aug 2024 20:08:20 +0000 Subject: [PATCH 08/13] test commit hook --- README.md | 1 + tools/setup.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 6accc16..a8a84cf 100644 --- a/README.md +++ b/README.md @@ -240,3 +240,4 @@ Example to get an interactive shell run into a container: ```console AWS_PROFILE=my-aws-profile aws ecs execute-command --cluster OpenChallengesEcs-ClusterEB0386A7-BygXkQgSvdjY --task a2916461f65747f390fd3e29f1b387d8 --container opcenchallenges-mariadb --command "/bin/sh" --interactive ``` +test\n diff --git a/tools/setup.sh b/tools/setup.sh index 3b4bceb..d0ff83d 100755 --- a/tools/setup.sh +++ b/tools/setup.sh @@ -6,6 +6,8 @@ set -euxo pipefail npm install -g aws-cdk@2.151.0 pip install --upgrade pip +python -m venv .venv +source .venv/bin/activate pip install -r requirements.txt -r requirements-dev.txt git config --global --add safe.directory "$PWD" From 38ce7dfc0c899abba95668e0906e979daca33168 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 15 Aug 2024 20:12:12 +0000 Subject: [PATCH 09/13] add HELLO --- HELLO | 1 + 1 file changed, 1 insertion(+) create mode 100644 HELLO diff --git a/HELLO b/HELLO new file mode 100644 index 0000000..e427984 --- /dev/null +++ b/HELLO @@ -0,0 +1 @@ +HELLO From 3c7df32c85743abde9ac80205d6ba3fb8b203512 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 15 Aug 2024 20:13:22 +0000 Subject: [PATCH 10/13] remove debug files --- BAR | 1 - FOO | 0 HELLO | 1 - PLOP | 1 - 4 files changed, 3 deletions(-) delete mode 100644 BAR delete mode 100644 FOO delete mode 100644 HELLO delete mode 100644 PLOP diff --git a/BAR b/BAR deleted file mode 100644 index ba578e4..0000000 --- a/BAR +++ /dev/null @@ -1 +0,0 @@ -BAR diff --git a/FOO b/FOO deleted file mode 100644 index e69de29..0000000 diff --git a/HELLO b/HELLO deleted file mode 100644 index e427984..0000000 --- a/HELLO +++ /dev/null @@ -1 +0,0 @@ -HELLO diff --git a/PLOP b/PLOP deleted file mode 100644 index 8f81a50..0000000 --- a/PLOP +++ /dev/null @@ -1 +0,0 @@ -PLOP From e0b3735bb1c1b2482ca607270a5f35ad4f9f7051 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 15 Aug 2024 20:20:13 +0000 Subject: [PATCH 11/13] add comment to setup.sh --- tools/setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/setup.sh b/tools/setup.sh index d0ff83d..b7a077a 100755 --- a/tools/setup.sh +++ b/tools/setup.sh @@ -3,12 +3,15 @@ # Safer bash scripts set -euxo pipefail +# Install Node.js dependencies npm install -g aws-cdk@2.151.0 +# Install Python dependencies pip install --upgrade pip python -m venv .venv source .venv/bin/activate pip install -r requirements.txt -r requirements-dev.txt +# Install git hooks git config --global --add safe.directory "$PWD" -pre-commit install-hooks +pre-commit install --install-hooks From 86416448dad8a94532a8e0676cebe85e9517665c Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 15 Aug 2024 20:29:09 +0000 Subject: [PATCH 12/13] update README --- README.md | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index a8a84cf..4c7723b 100644 --- a/README.md +++ b/README.md @@ -32,40 +32,24 @@ That's it! You are now inside the dev container and have access to all the devel # Development -The `cdk.json` file tells the CDK Toolkit how to execute your app. +All the development tools are provided when developing inside the dev container +(see above). These tools include Python, AWS CLI, AWS CDK CLI, etc. These tools +also include a Python virtual environment where all the Python packages needed +are already installed. -This project is set up like a standard Python project. The initialization -process also creates a virtualenv within this project, stored under the `.venv` -directory. To create the virtualenv it assumes that there is a `python3` -(or `python` for Windows) executable in your path with access to the `venv` -package. If for any reason the automatic creation of the virtualenv fails, -you can create the virtualenv manually. +If you decide the develop outside of the dev container, some of the development +tools can be installed by running: -To manually create a virtualenv on MacOS and Linux: - -``` -$ python3 -m venv .venv +```console +./tools/setup.sh ``` -After the init process completes and the virtualenv is created, you can use the following -step to activate your virtualenv. +Development requires the activation of the Python virtual environment: ``` $ source .venv/bin/activate ``` -If you are a Windows platform, you would activate the virtualenv like this: - -``` -% .venv\Scripts\activate.bat -``` - -Once the virtualenv is activated, you can install the required dependencies. - -``` -$ pip install -r requirements.txt -r requirements-dev.txt -``` - At this point you can now synthesize the CloudFormation template for this code. ``` From cf978c6fcd67681ded36b06c7cd47229a5f0f793 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Fri, 16 Aug 2024 17:11:01 +0000 Subject: [PATCH 13/13] use a range for pre-commit --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 320d403..1f2bf77 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,2 @@ -pre-commit==3.8.0 +pre-commit~=3.8.0 pytest==6.2.5