From e1017293f78a2a948ce96d3fabe334314a7bb889 Mon Sep 17 00:00:00 2001 From: Christian Nunciato Date: Wed, 15 May 2024 14:30:09 -0700 Subject: [PATCH] Make the runtime blog post's examples testable (#4279) --- .github/workflows/scheduled-test.yml | 6 ++++++ .../__main__.py | 3 ++- .../index.ts | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scheduled-test.yml b/.github/workflows/scheduled-test.yml index 4a5dcb9c0c1..e62da7df2ab 100644 --- a/.github/workflows/scheduled-test.yml +++ b/.github/workflows/scheduled-test.yml @@ -54,6 +54,12 @@ jobs: with: dotnet-version: ${{ matrix.dotnet-version }} + - name: Install Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: "0.111.0" + extended: true + - name: Install Pulumi uses: pulumi/actions@v4 diff --git a/themes/default/static/programs/aws-static-website-with-runtime-logic-python/__main__.py b/themes/default/static/programs/aws-static-website-with-runtime-logic-python/__main__.py index 9aa43c2b7fc..8bbd7376db3 100644 --- a/themes/default/static/programs/aws-static-website-with-runtime-logic-python/__main__.py +++ b/themes/default/static/programs/aws-static-website-with-runtime-logic-python/__main__.py @@ -51,7 +51,8 @@ ) # Fetch some redirects from a hypothetical CMS. -response = requests.get(f"{os.environ['CMS_ENDPOINT']}/redirects.json") +endpoint = os.environ["CMS_ENDPOINT"] if "CMS_ENDPOINT" in os.environ else "https://gist.githubusercontent.com/cnunciato/013c2ffd2ced08fa31ab8c376d2d408e/raw/44f219160c8d9cd8febcaddd34fd5ac0b3631e02" +response = requests.get(f"{endpoint}/redirects.json") redirects = json.loads(response.text) # Create an S3 website redirect for each one. diff --git a/themes/default/static/programs/aws-static-website-with-runtime-logic-typescript/index.ts b/themes/default/static/programs/aws-static-website-with-runtime-logic-typescript/index.ts index 9a35796d0b4..8dec97f61c5 100644 --- a/themes/default/static/programs/aws-static-website-with-runtime-logic-typescript/index.ts +++ b/themes/default/static/programs/aws-static-website-with-runtime-logic-typescript/index.ts @@ -46,7 +46,8 @@ const homepage = new aws.s3.BucketObject( ); // Fetch some redirects from a hypothetical CMS. -const redirects = fetch(`${process.env.CMS_ENDPOINT}/redirects.json`) +const endpoint = process.env.CMS_ENDPOINT ?? "https://gist.githubusercontent.com/cnunciato/013c2ffd2ced08fa31ab8c376d2d408e/raw/44f219160c8d9cd8febcaddd34fd5ac0b3631e02"; +const redirects = fetch(`${endpoint}/redirects.json`) .then(response => response.json()) .then(items => items.forEach((redirect: any, i: number) => {