From 9d016b50591dc1b3e03f7c62b1b175a8e7d78a0c Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Fri, 3 Apr 2020 21:16:00 +0200 Subject: [PATCH 1/5] Bump to 0.39.0 --- .github/workflows/ci.yml | 128 +++++++++++++++--------------- example-sam/template.yml | 6 +- example-serverless/deps.ts | 4 +- example-serverless/serverless.yml | 2 +- example-serverless/test.ts | 24 +++--- tests/Dockerfile | 2 +- tests/deps.ts | 6 +- tests/test_bundle.json | 4 +- tests/test_example_zip.json | 4 +- tests/test_js.json | 4 +- tests/test_run_deno.json | 4 +- tests/test_self_contained.json | 4 +- tests/test_simple.json | 4 +- 13 files changed, 98 insertions(+), 98 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8e2b1d7..4b6af86a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,69 +4,69 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Build docker image - working-directory: ./tests - run: | - docker build -f Dockerfile -t test-runner .. - docker create --name extract test-runner - - name: Run tests - run: | - docker run test-runner - - name: Extract artifacts - run: | - docker cp extract:/bin/deno amz-deno - docker cp extract:/src/runtime/deno-lambda-layer.zip deno-lambda-layer.zip - docker cp extract:/src/runtime/deno-lambda-example.zip deno-lambda-example.zip - gzip -9 amz-deno - - name: Verify Release Version Matches Deno Version - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' - run: | - export DENO_LAMBDA_VERSION=$(echo $GITHUB_REF | tr / '\n' | tail -n 1) - docker run -e DENO_LAMBDA_VERSION=$DENO_LAMBDA_VERSION test-runner test --allow-env /src/tests/version_check.ts - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: | - amz-deno.gz - deno-lambda-layer.zip - deno-lambda-example.zip - draft: true - - name: Publish to SAR - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - DENO_LAMBDA_BUCKET: ${{ secrets.DENO_LAMBDA_BUCKET }} - run: | - export DENO_LAMBDA_VERSION=$(echo $GITHUB_REF | tr / '\n' | tail -n 1) - echo tag: $DENO_LAMBDA_VERSION - # FIXME: Installation of sam is fiddly. - export DEBIAN_FRONTEND=noninteractive - sudo apt -qq update &> /dev/null - sudo apt -qq install -y awscli python3-setuptools &> /dev/null - pip3 -q install -U --force pip - export PATH=/home/runner/.local/bin:$PATH - export SAM_CLI_TELEMETRY=1 - python3 -m pip -q install --user aws-sam-cli - aws s3 cp --quiet deno-lambda-layer.zip s3://$DENO_LAMBDA_BUCKET/deno-lambda-layer_$DENO_LAMBDA_VERSION.zip --acl public-read - aws s3 cp --quiet deno-lambda-example.zip s3://$DENO_LAMBDA_BUCKET/deno-lambda-example_$DENO_LAMBDA_VERSION.zip --acl public-read - echo --- - cd SAR - sed -i -e s/DENO_LAMBDA_BUCKET/$DENO_LAMBDA_BUCKET/g template.yml - sed -i -e s/DENO_LAMBDA_VERSION/$DENO_LAMBDA_VERSION/g template.yml - cat template.yml - sam publish --region us-east-1 - echo --- - cd blueprint - sed -i -e s/DENO_LAMBDA_BUCKET/$DENO_LAMBDA_BUCKET/g template.yml - sed -i -e s/DENO_LAMBDA_VERSION/$DENO_LAMBDA_VERSION/g template.yml - cat template.yml - sam publish --region us-east-1 - echo --- + - uses: actions/checkout@v1 + - name: Build docker image + working-directory: ./tests + run: | + docker build -f Dockerfile -t test-runner .. + docker create --name extract test-runner + - name: Run tests + run: | + docker run test-runner + - name: Extract artifacts + run: | + docker cp extract:/bin/deno amz-deno + docker cp extract:/src/runtime/deno-lambda-layer.zip deno-lambda-layer.zip + docker cp extract:/src/runtime/deno-lambda-example.zip deno-lambda-example.zip + gzip -9 amz-deno + - name: Verify Release Version Matches Deno Version + if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' + run: | + export DENO_LAMBDA_VERSION=$(echo $GITHUB_REF | tr / '\n' | tail -n 1) + docker run -e DENO_LAMBDA_VERSION=$DENO_LAMBDA_VERSION test-runner test --allow-env /src/tests/version_check.ts + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + amz-deno.gz + deno-lambda-layer.zip + deno-lambda-example.zip + draft: true + - name: Publish to SAR + if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + DENO_LAMBDA_BUCKET: ${{ secrets.DENO_LAMBDA_BUCKET }} + run: | + export DENO_LAMBDA_VERSION=$(echo $GITHUB_REF | tr / '\n' | tail -n 1) + echo tag: $DENO_LAMBDA_VERSION + # FIXME: Installation of sam is fiddly. + export DEBIAN_FRONTEND=noninteractive + sudo apt -qq update &> /dev/null + sudo apt -qq install -y awscli python3-setuptools &> /dev/null + pip3 -q install -U --force pip + export PATH=/home/runner/.local/bin:$PATH + export SAM_CLI_TELEMETRY=1 + python3 -m pip -q install --user aws-sam-cli + aws s3 cp --quiet deno-lambda-layer.zip s3://$DENO_LAMBDA_BUCKET/deno-lambda-layer_$DENO_LAMBDA_VERSION.zip --acl public-read + aws s3 cp --quiet deno-lambda-example.zip s3://$DENO_LAMBDA_BUCKET/deno-lambda-example_$DENO_LAMBDA_VERSION.zip --acl public-read + echo --- + cd SAR + sed -i -e s/DENO_LAMBDA_BUCKET/$DENO_LAMBDA_BUCKET/g template.yml + sed -i -e s/DENO_LAMBDA_VERSION/$DENO_LAMBDA_VERSION/g template.yml + cat template.yml + sam publish --region us-east-1 + echo --- + cd blueprint + sed -i -e s/DENO_LAMBDA_BUCKET/$DENO_LAMBDA_BUCKET/g template.yml + sed -i -e s/DENO_LAMBDA_VERSION/$DENO_LAMBDA_VERSION/g template.yml + cat template.yml + sam publish --region us-east-1 + echo --- test_example: runs-on: ubuntu-latest @@ -74,7 +74,7 @@ jobs: - uses: actions/checkout@v2 - uses: denolib/setup-deno@v1.2.0 with: - deno-version: 0.38.0 + deno-version: 0.39.0 - name: start a local dynamodb run: | mkdir dyno diff --git a/example-sam/template.yml b/example-sam/template.yml index 880a4ce1..4b082491 100644 --- a/example-sam/template.yml +++ b/example-sam/template.yml @@ -1,4 +1,4 @@ -AWSTemplateFormatVersion: '2010-09-09' +AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Description: > sam-hello @@ -11,10 +11,10 @@ Resources: Properties: Location: ApplicationId: arn:aws:serverlessrepo:us-east-1:390065572566:applications/deno - SemanticVersion: 0.38.0 + SemanticVersion: 0.39.0 HelloWorldFunction: - Type: AWS::Serverless::Function + Type: AWS::Serverless::Function Properties: CodeUri: . MemorySize: 128 diff --git a/example-serverless/deps.ts b/example-serverless/deps.ts index f05b8fa8..a7a605d5 100644 --- a/example-serverless/deps.ts +++ b/example-serverless/deps.ts @@ -1,8 +1,8 @@ export { createClient, Doc, - DynamoDBClient + DynamoDBClient, } from "https://deno.land/x/dynamodb@v0.3.1/mod.ts"; -import { v4 } from "https://deno.land/std@v0.38.0/uuid/mod.ts"; +import { v4 } from "https://deno.land/std@v0.39.0/uuid/mod.ts"; export const uuid = v4.generate; diff --git a/example-serverless/serverless.yml b/example-serverless/serverless.yml index 0312fec6..0c880c94 100644 --- a/example-serverless/serverless.yml +++ b/example-serverless/serverless.yml @@ -64,7 +64,7 @@ resources: Properties: Location: ApplicationId: arn:aws:serverlessrepo:us-east-1:390065572566:applications/deno - SemanticVersion: 0.38.0 + SemanticVersion: 0.39.0 candidatesTable: Type: AWS::DynamoDB::Table diff --git a/example-serverless/test.ts b/example-serverless/test.ts index d26a80df..129e7ef0 100644 --- a/example-serverless/test.ts +++ b/example-serverless/test.ts @@ -6,11 +6,11 @@ import { assert, - assertEquals -} from "https://deno.land/std@v0.38.0/testing/asserts.ts"; + assertEquals, +} from "https://deno.land/std@v0.39.0/testing/asserts.ts"; import { APIGatewayProxyEvent, - Context + Context, } from "https://deno.land/x/lambda/mod.ts"; import { client } from "./client.ts"; @@ -19,7 +19,7 @@ import { list as listCandidate, get as getCandidate, submit as submitCandidate, - TableName + TableName, } from "./api/candidate.ts"; test({ @@ -27,11 +27,11 @@ test({ fn: async () => { const result = await client.getItem({ TableName, - Key: { id: "abc" } + Key: { id: "abc" }, }); const user = result.Item; assertEquals(user.role, "admin"); - } + }, }); test({ @@ -44,7 +44,7 @@ test({ assertEquals(result.statusCode, 200); const body = JSON.parse(result.body); assertEquals(body.candidates.length, 2); - } + }, }); test({ @@ -58,7 +58,7 @@ test({ const body = JSON.parse(result.body); assertEquals(body.id, "abc"); assertEquals(body.role, "admin"); - } + }, }); test({ @@ -71,7 +71,7 @@ test({ assertEquals(result.statusCode, 404); const body = JSON.parse(result.body); assertEquals(body.message, "Not Found: bad"); - } + }, }); test({ @@ -79,7 +79,7 @@ test({ fn: async () => { const event = { body: - '{"fullname":"Shekhar Gulati","email": "shekhargulati84@gmail.com", "experience":12}' + '{"fullname":"Shekhar Gulati","email": "shekhargulati84@gmail.com", "experience":12}', }; const result = await submitCandidate( event as APIGatewayProxyEvent, @@ -91,7 +91,7 @@ test({ body.message, "Sucessfully submitted candidate with email shekhargulati84@gmail.com" ); - } + }, }); test({ @@ -105,5 +105,5 @@ test({ assertEquals(result.statusCode, 422); const body = JSON.parse(result.body); assertEquals(body.message, "invalid input"); - } + }, }); diff --git a/tests/Dockerfile b/tests/Dockerfile index 9028504a..17e67478 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,6 +1,6 @@ # Note: This must be built in the .. context -FROM hayd/amazonlinux1-deno:0.38.0 +FROM hayd/amazonlinux1-deno:0.39.0 # This is the runtime used by AWS Lambda # plus a compatible deno executable /bin/deno. # https://github.com/hayd/deno_docker diff --git a/tests/deps.ts b/tests/deps.ts index 56719271..9dfde51c 100644 --- a/tests/deps.ts +++ b/tests/deps.ts @@ -1,5 +1,5 @@ export { assert, - assertEquals -} from "https://deno.land/std@v0.38.0/testing/asserts.ts"; -export { serve } from "https://deno.land/std@v0.38.0/http/server.ts"; + assertEquals, +} from "https://deno.land/std@v0.39.0/testing/asserts.ts"; +export { serve } from "https://deno.land/std@v0.39.0/http/server.ts"; diff --git a/tests/test_bundle.json b/tests/test_bundle.json index f9aeabdf..0174e0d1 100644 --- a/tests/test_bundle.json +++ b/tests/test_bundle.json @@ -7,11 +7,11 @@ "expected": [ { "status": "ok", - "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.39.0 🦕\"}" }, { "status": "ok", - "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.39.0 🦕\"}" } ], "files": ["hello.bundle.js"], diff --git a/tests/test_example_zip.json b/tests/test_example_zip.json index 58eee8b4..646728bf 100644 --- a/tests/test_example_zip.json +++ b/tests/test_example_zip.json @@ -4,11 +4,11 @@ "expected": [ { "status": "ok", - "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.39.0 🦕\"}" }, { "status": "ok", - "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.39.0 🦕\"}" } ], "files": "deno-lambda-example.zip", diff --git a/tests/test_js.json b/tests/test_js.json index 7d398e00..ced88b8d 100644 --- a/tests/test_js.json +++ b/tests/test_js.json @@ -4,11 +4,11 @@ "expected": [ { "status": "ok", - "content": "{\"statusCode\":200,\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"body\":\"Welcome to deno 0.39.0 🦕\"}" }, { "status": "ok", - "content": "{\"statusCode\":200,\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"body\":\"Welcome to deno 0.39.0 🦕\"}" } ], "files": ["hello.js"], diff --git a/tests/test_run_deno.json b/tests/test_run_deno.json index cddfd1e5..e61b41c2 100644 --- a/tests/test_run_deno.json +++ b/tests/test_run_deno.json @@ -4,11 +4,11 @@ "expected": [ { "status": "ok", - "content": "{\"out\":\"deno 0.38.0\"}" + "content": "{\"out\":\"deno 0.39.0\"}" }, { "status": "ok", - "content": "{\"out\":\"deno 0.38.0\"}" + "content": "{\"out\":\"deno 0.39.0\"}" } ], "files": ["handlers.ts"], diff --git a/tests/test_self_contained.json b/tests/test_self_contained.json index 6eed276b..5d60f305 100644 --- a/tests/test_self_contained.json +++ b/tests/test_self_contained.json @@ -4,11 +4,11 @@ "expected": [ { "status": "ok", - "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.39.0 🦕\"}" }, { "status": "ok", - "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.39.0 🦕\"}" } ], "files": ["hello.ts", "bootstrap", "bin/deno"] diff --git a/tests/test_simple.json b/tests/test_simple.json index 918af673..2172490c 100644 --- a/tests/test_simple.json +++ b/tests/test_simple.json @@ -4,11 +4,11 @@ "expected": [ { "status": "ok", - "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.39.0 🦕\"}" }, { "status": "ok", - "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.38.0 🦕\"}" + "content": "{\"statusCode\":200,\"headers\":{\"content-type\":\"text/html;charset=utf8\"},\"body\":\"Welcome to deno 0.39.0 🦕\"}" } ], "files": ["hello.ts"], From 21eddbdf3378008b8cadb4985375ecd4b9a828b4 Mon Sep 17 00:00:00 2001 From: Andy Hayden Date: Fri, 3 Apr 2020 22:58:23 -0700 Subject: [PATCH 2/5] Move publish code to publish.yml Run ci.yml tests on pull_requests --- .github/workflows/ci.yml | 50 +------------------------ .github/workflows/publish.yml | 69 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b6af86a..c83e295f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ name: Test -on: push +on: [push, pull_request] jobs: build: runs-on: ubuntu-latest @@ -19,54 +19,6 @@ jobs: docker cp extract:/src/runtime/deno-lambda-layer.zip deno-lambda-layer.zip docker cp extract:/src/runtime/deno-lambda-example.zip deno-lambda-example.zip gzip -9 amz-deno - - name: Verify Release Version Matches Deno Version - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' - run: | - export DENO_LAMBDA_VERSION=$(echo $GITHUB_REF | tr / '\n' | tail -n 1) - docker run -e DENO_LAMBDA_VERSION=$DENO_LAMBDA_VERSION test-runner test --allow-env /src/tests/version_check.ts - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: | - amz-deno.gz - deno-lambda-layer.zip - deno-lambda-example.zip - draft: true - - name: Publish to SAR - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - DENO_LAMBDA_BUCKET: ${{ secrets.DENO_LAMBDA_BUCKET }} - run: | - export DENO_LAMBDA_VERSION=$(echo $GITHUB_REF | tr / '\n' | tail -n 1) - echo tag: $DENO_LAMBDA_VERSION - # FIXME: Installation of sam is fiddly. - export DEBIAN_FRONTEND=noninteractive - sudo apt -qq update &> /dev/null - sudo apt -qq install -y awscli python3-setuptools &> /dev/null - pip3 -q install -U --force pip - export PATH=/home/runner/.local/bin:$PATH - export SAM_CLI_TELEMETRY=1 - python3 -m pip -q install --user aws-sam-cli - aws s3 cp --quiet deno-lambda-layer.zip s3://$DENO_LAMBDA_BUCKET/deno-lambda-layer_$DENO_LAMBDA_VERSION.zip --acl public-read - aws s3 cp --quiet deno-lambda-example.zip s3://$DENO_LAMBDA_BUCKET/deno-lambda-example_$DENO_LAMBDA_VERSION.zip --acl public-read - echo --- - cd SAR - sed -i -e s/DENO_LAMBDA_BUCKET/$DENO_LAMBDA_BUCKET/g template.yml - sed -i -e s/DENO_LAMBDA_VERSION/$DENO_LAMBDA_VERSION/g template.yml - cat template.yml - sam publish --region us-east-1 - echo --- - cd blueprint - sed -i -e s/DENO_LAMBDA_BUCKET/$DENO_LAMBDA_BUCKET/g template.yml - sed -i -e s/DENO_LAMBDA_VERSION/$DENO_LAMBDA_VERSION/g template.yml - cat template.yml - sam publish --region us-east-1 - echo --- test_example: runs-on: ubuntu-latest diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..85da019b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,69 @@ +name: Publish +on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Build docker image + working-directory: ./tests + run: | + docker build -f Dockerfile -t test-runner .. + docker create --name extract test-runner + - name: Run tests + run: | + docker run test-runner + - name: Extract artifacts + run: | + docker cp extract:/bin/deno amz-deno + docker cp extract:/src/runtime/deno-lambda-layer.zip deno-lambda-layer.zip + docker cp extract:/src/runtime/deno-lambda-example.zip deno-lambda-example.zip + gzip -9 amz-deno + - name: Verify Release Version Matches Deno Version + if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' + run: | + export DENO_LAMBDA_VERSION=$(echo $GITHUB_REF | tr / '\n' | tail -n 1) + docker run -e DENO_LAMBDA_VERSION=$DENO_LAMBDA_VERSION test-runner test --allow-env /src/tests/version_check.ts + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + amz-deno.gz + deno-lambda-layer.zip + deno-lambda-example.zip + draft: true + - name: Publish to SAR + if: startsWith(github.ref, 'refs/tags/') && github.repository == 'hayd/deno-lambda' + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + DENO_LAMBDA_BUCKET: ${{ secrets.DENO_LAMBDA_BUCKET }} + run: | + export DENO_LAMBDA_VERSION=$(echo $GITHUB_REF | tr / '\n' | tail -n 1) + echo tag: $DENO_LAMBDA_VERSION + # FIXME: Installation of sam is fiddly. + export DEBIAN_FRONTEND=noninteractive + sudo apt -qq update &> /dev/null + sudo apt -qq install -y awscli python3-setuptools &> /dev/null + pip3 -q install -U --force pip + export PATH=/home/runner/.local/bin:$PATH + export SAM_CLI_TELEMETRY=1 + python3 -m pip -q install --user aws-sam-cli + aws s3 cp --quiet deno-lambda-layer.zip s3://$DENO_LAMBDA_BUCKET/deno-lambda-layer_$DENO_LAMBDA_VERSION.zip --acl public-read + aws s3 cp --quiet deno-lambda-example.zip s3://$DENO_LAMBDA_BUCKET/deno-lambda-example_$DENO_LAMBDA_VERSION.zip --acl public-read + echo --- + cd SAR + sed -i -e s/DENO_LAMBDA_BUCKET/$DENO_LAMBDA_BUCKET/g template.yml + sed -i -e s/DENO_LAMBDA_VERSION/$DENO_LAMBDA_VERSION/g template.yml + cat template.yml + sam publish --region us-east-1 + echo --- + cd blueprint + sed -i -e s/DENO_LAMBDA_BUCKET/$DENO_LAMBDA_BUCKET/g template.yml + sed -i -e s/DENO_LAMBDA_VERSION/$DENO_LAMBDA_VERSION/g template.yml + cat template.yml + sam publish --region us-east-1 + echo --- \ No newline at end of file From 8668cfdd4393a4f40366cfb1cc103dda4507bff6 Mon Sep 17 00:00:00 2001 From: Andy Hayden Date: Fri, 3 Apr 2020 23:25:19 -0700 Subject: [PATCH 3/5] Fix tests - temporarily point to v0.38.0 version of pad.ts This should be removed. Note: The importmap etc. _should_ point to a version --- tests/importmap.json | 2 +- tests/importmap.ts | 1 + tests/pad.ts | 7 +++++-- tests/test_badlock.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/importmap.json b/tests/importmap.json index c77c59b0..a70d4df3 100644 --- a/tests/importmap.json +++ b/tests/importmap.json @@ -1,5 +1,5 @@ { "imports": { - "std/": "https://deno.land/std/" + "std/": "https://deno.land/std@v0.38.0/" } } diff --git a/tests/importmap.ts b/tests/importmap.ts index 53680764..9e9b11f9 100644 --- a/tests/importmap.ts +++ b/tests/importmap.ts @@ -2,6 +2,7 @@ import { APIGatewayProxyEvent, Context } from "https://deno.land/x/lambda/mod.ts"; +// FIXME use a different file here (see also pad.ts) import { pad } from "std/strings/pad.ts"; export function handler(event: any, context: Context) { diff --git a/tests/pad.ts b/tests/pad.ts index 239865c8..0453fa95 100644 --- a/tests/pad.ts +++ b/tests/pad.ts @@ -1,12 +1,15 @@ -// pad.ts is chosen since it has no dependencies. +// pad.ts was chosen since it has no dependencies. // i.e. we must download precisely one file from deno.land. -import { pad } from "https://deno.land/std/strings/pad.ts"; +// FIXME: it has since been removed from std so this should be refactored. +// (see also importmap.ts) +import { pad } from "https://deno.land/std@v0.38.0/strings/pad.ts"; export function handler(event: any, context: any) { const strLen: number = Number(event.strLen) || 5; return pad("deno", strLen); } +// FIXME why is this function in pad.ts? export async function assertLock(event: any, context: any) { // assert --lock was passed // Note: This is a file with external imports in order for -lock to be used. diff --git a/tests/test_badlock.json b/tests/test_badlock.json index af49049d..c00f2cfe 100644 --- a/tests/test_badlock.json +++ b/tests/test_badlock.json @@ -4,7 +4,7 @@ "expected": [ { "status": "error", - "content": "{\"errorMessage\" : \"lock file error: Subresource integrity check failed --lock=badlock.json\nhttps://deno.land/std/strings/pad.ts\", \"errorType\" : \"InitException\"}" + "content": "{\"errorMessage\" : \"lock file error: Subresource integrity check failed --lock=badlock.json\nhttps://deno.land/std@v0.38.0/strings/pad.ts\", \"errorType\" : \"InitException\"}" } ], "files": ["pad.ts", "badlock.json"], From a3c1b901acd459c5fdf15e41e7f2970653ad201f Mon Sep 17 00:00:00 2001 From: Andy Hayden Date: Fri, 3 Apr 2020 23:32:02 -0700 Subject: [PATCH 4/5] Temporarily use master branch of setup-deno --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c83e295f..5ca58293 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: denolib/setup-deno@v1.2.0 + - uses: denolib/setup-deno@master with: deno-version: 0.39.0 - name: start a local dynamodb From 71607dcce0ae4564d93c67009d5fc7a6045ec0fd Mon Sep 17 00:00:00 2001 From: Andy Hayden Date: Fri, 3 Apr 2020 23:38:04 -0700 Subject: [PATCH 5/5] deno fmt --- example-sam/hello.ts | 4 ++-- example-serverless/api/candidate.ts | 12 ++++++------ example-serverless/deps.ts | 2 +- example-serverless/test.ts | 18 +++++++++--------- example-serverless/test_util.ts | 16 ++++++++-------- hello.ts | 4 ++-- tests/decorate.ts | 2 +- tests/deps.ts | 2 +- tests/handlers.ts | 10 +++++----- tests/hello.js | 2 +- tests/server.ts | 10 +++++----- tests/test.ts | 18 +++++++++--------- 12 files changed, 50 insertions(+), 50 deletions(-) diff --git a/example-sam/hello.ts b/example-sam/hello.ts index ad374926..4b575a4a 100644 --- a/example-sam/hello.ts +++ b/example-sam/hello.ts @@ -6,11 +6,11 @@ import { export async function handler( event: APIGatewayProxyEvent, - context: Context + context: Context, ): Promise { return { statusCode: 200, headers: { "content-type": "text/html;charset=utf8" }, - body: `Hello World! Sent from deno ${Deno.version.deno} 🦕` + body: `Hello World! Sent from deno ${Deno.version.deno} 🦕`, }; } diff --git a/example-serverless/api/candidate.ts b/example-serverless/api/candidate.ts index 8e5e32dc..3dc10ed7 100644 --- a/example-serverless/api/candidate.ts +++ b/example-serverless/api/candidate.ts @@ -11,7 +11,7 @@ export const TableName = "candidates"; function ok(body: any, statusCode: number = 200) { return { statusCode, - body: JSON.stringify(body) + body: JSON.stringify(body), }; } function error(message: string, statusCode: number = 500) { @@ -27,8 +27,8 @@ export async function get(event: APIGatewayProxyEvent, context: Context) { const params = { TableName, Key: { - id: id - } + id: id, + }, }; let result: Doc; try { @@ -46,7 +46,7 @@ export async function get(event: APIGatewayProxyEvent, context: Context) { export async function list(event: APIGatewayProxyEvent, context: Context) { var params = { TableName, - ProjectionExpression: "id, fullname, email" + ProjectionExpression: "id, fullname, email", }; let result: any; try { @@ -94,7 +94,7 @@ export async function submit(event: APIGatewayProxyEvent, context: Context) { email, experience, submittedAt: now, - updatedAt: now + updatedAt: now, }; try { @@ -105,6 +105,6 @@ export async function submit(event: APIGatewayProxyEvent, context: Context) { } return ok({ message: `Sucessfully submitted candidate with email ${email}`, - candidateId: candidate.id + candidateId: candidate.id, }); } diff --git a/example-serverless/deps.ts b/example-serverless/deps.ts index a7a605d5..bacec25b 100644 --- a/example-serverless/deps.ts +++ b/example-serverless/deps.ts @@ -1,7 +1,7 @@ export { createClient, Doc, - DynamoDBClient, + DynamoDBClient } from "https://deno.land/x/dynamodb@v0.3.1/mod.ts"; import { v4 } from "https://deno.land/std@v0.39.0/uuid/mod.ts"; diff --git a/example-serverless/test.ts b/example-serverless/test.ts index 129e7ef0..d0aa3706 100644 --- a/example-serverless/test.ts +++ b/example-serverless/test.ts @@ -6,11 +6,11 @@ import { assert, - assertEquals, + assertEquals } from "https://deno.land/std@v0.39.0/testing/asserts.ts"; import { APIGatewayProxyEvent, - Context, + Context } from "https://deno.land/x/lambda/mod.ts"; import { client } from "./client.ts"; @@ -19,7 +19,7 @@ import { list as listCandidate, get as getCandidate, submit as submitCandidate, - TableName, + TableName } from "./api/candidate.ts"; test({ @@ -39,7 +39,7 @@ test({ fn: async () => { const result = await listCandidate( {} as APIGatewayProxyEvent, - {} as Context + {} as Context, ); assertEquals(result.statusCode, 200); const body = JSON.parse(result.body); @@ -52,7 +52,7 @@ test({ fn: async () => { const result = await getCandidate( ({ pathParameters: { id: "abc" } } as unknown) as APIGatewayProxyEvent, - {} as Context + {} as Context, ); assertEquals(result.statusCode, 200); const body = JSON.parse(result.body); @@ -66,7 +66,7 @@ test({ fn: async () => { const result = await getCandidate( ({ pathParameters: { id: "bad" } } as unknown) as APIGatewayProxyEvent, - {} as Context + {} as Context, ); assertEquals(result.statusCode, 404); const body = JSON.parse(result.body); @@ -83,13 +83,13 @@ test({ }; const result = await submitCandidate( event as APIGatewayProxyEvent, - {} as Context + {} as Context, ); assertEquals(result.statusCode, 200); const body = JSON.parse(result.body); assertEquals( body.message, - "Sucessfully submitted candidate with email shekhargulati84@gmail.com" + "Sucessfully submitted candidate with email shekhargulati84@gmail.com", ); }, }); @@ -100,7 +100,7 @@ test({ const event = { body: "{}" }; const result = await submitCandidate( event as APIGatewayProxyEvent, - {} as Context + {} as Context, ); assertEquals(result.statusCode, 422); const body = JSON.parse(result.body); diff --git a/example-serverless/test_util.ts b/example-serverless/test_util.ts index 2e62465e..26c87f14 100644 --- a/example-serverless/test_util.ts +++ b/example-serverless/test_util.ts @@ -24,31 +24,31 @@ async function setUp() { TableName, KeySchema: [{ KeyType: "HASH", AttributeName: "id" }], AttributeDefinitions: [{ AttributeName: "id", AttributeType: "S" }], - ProvisionedThroughput: { ReadCapacityUnits: 1, WriteCapacityUnits: 1 } + ProvisionedThroughput: { ReadCapacityUnits: 1, WriteCapacityUnits: 1 }, }, - { translateJSON: false } + { translateJSON: false }, ); await client.putItem( { TableName, - Item: { id: { S: "abc" }, role: { S: "admin" } } + Item: { id: { S: "abc" }, role: { S: "admin" } }, }, - { translateJSON: false } + { translateJSON: false }, ); await client.putItem( { TableName, - Item: { id: { S: "def" } } + Item: { id: { S: "def" } }, }, - { translateJSON: false } + { translateJSON: false }, ); } async function tearDown() { await client.deleteTable( { - TableName: TableName + TableName: TableName, }, - { translateJSON: false } + { translateJSON: false }, ); } diff --git a/hello.ts b/hello.ts index 8ec9ee54..942d7584 100644 --- a/hello.ts +++ b/hello.ts @@ -6,11 +6,11 @@ import { export async function handler( event: APIGatewayProxyEvent, - context: Context + context: Context, ): Promise { return { statusCode: 200, headers: { "content-type": "text/html;charset=utf8" }, - body: `Welcome to deno ${Deno.version.deno} 🦕` + body: `Welcome to deno ${Deno.version.deno} 🦕`, }; } diff --git a/tests/decorate.ts b/tests/decorate.ts index bd6769d6..f9affcd6 100644 --- a/tests/decorate.ts +++ b/tests/decorate.ts @@ -12,6 +12,6 @@ class Foo { export async function handler(event: APIGatewayProxyEvent, context: Context) { return { statusCode: 200, - body: `decorated 🦕` + body: `decorated 🦕`, }; } diff --git a/tests/deps.ts b/tests/deps.ts index 9dfde51c..c410572b 100644 --- a/tests/deps.ts +++ b/tests/deps.ts @@ -1,5 +1,5 @@ export { assert, - assertEquals, + assertEquals } from "https://deno.land/std@v0.39.0/testing/asserts.ts"; export { serve } from "https://deno.land/std@v0.39.0/http/server.ts"; diff --git a/tests/handlers.ts b/tests/handlers.ts index 8d0978ab..77a3b569 100644 --- a/tests/handlers.ts +++ b/tests/handlers.ts @@ -21,13 +21,13 @@ export async function foo(event: any, context: Context) { export async function withContext( event: APIGatewayProxyEvent, - context: Context + context: Context, ) { return { name: context.functionName, awsRequestId: context.awsRequestId, clientContext: context.clientContext, - identity: context.identity + identity: context.identity, }; } @@ -47,19 +47,19 @@ export async function log(event: any, context: Context) { console.warn("i warned you"); console.error("uh oh"); return { - log: LOGGED.map(v => { + log: LOGGED.map((v) => { if (v.length !== 1) { throw new Error("expected only one string passed to console.log"); } return v[0].replace(/[0-9]/g, "0"); - }) + }), }; } export async function badPrefix(event: any, context: Context) { // assert warning message on init: console.log(event.hello); - const log = LOGGED.map(args => { + const log = LOGGED.map((args) => { // @ts-ignore return Deno[Deno.symbols.internal].stringifyArgs(args); }); diff --git a/tests/hello.js b/tests/hello.js index bcf2c751..4caf4cc8 100644 --- a/tests/hello.js +++ b/tests/hello.js @@ -1,6 +1,6 @@ export async function handler(event, context) { return { statusCode: 200, - body: `Welcome to deno ${Deno.version.deno} 🦕` + body: `Welcome to deno ${Deno.version.deno} 🦕`, }; } diff --git a/tests/server.ts b/tests/server.ts index f4c1f2ef..37d8dceb 100644 --- a/tests/server.ts +++ b/tests/server.ts @@ -16,7 +16,7 @@ export interface TestJson { function bootstrap(testJson: TestJson) { const bootstrapScript = Deno.readdirSync("/var/task/") - .map(x => x.name) + .map((x) => x.name) .includes("bootstrap") ? "/var/task/bootstrap" : "/opt/bootstrap"; @@ -29,7 +29,7 @@ function bootstrap(testJson: TestJson) { stdout: "piped", stderr: "piped", // comment this out to debug env: testJson.env, - cwd: "/var/task" + cwd: "/var/task", }); } @@ -75,7 +75,7 @@ export async function serveEvents(testJson: TestJson) { "arn:aws:lambda:us-east-1:776893852117:function:test", // start at a. "lambda-runtime-aws-request-id": String.fromCharCode(96 + reqId), - "lambda-runtime-deadline-ms": (Date.now() + 300000).toString() + "lambda-runtime-deadline-ms": (Date.now() + 300000).toString(), }); if (testJson.headers) { for (let [k, v] of Object.entries(testJson.headers)) { @@ -86,7 +86,7 @@ export async function serveEvents(testJson: TestJson) { } await req.respond({ body: enc.encode(JSON.stringify(e.value)), - headers + headers, }); } } @@ -99,6 +99,6 @@ export async function serveEvents(testJson: TestJson) { await p.status(); p.close(); return { - responses: responses + responses: responses, }; } diff --git a/tests/test.ts b/tests/test.ts index 237dfa69..0af3668a 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -4,10 +4,10 @@ import { TestJson, serveEvents } from "./server.ts"; const dec = new TextDecoder(); const testFiles = Deno.readdirSync("/src/tests") - .map(f => f.name || "ignore") - .filter(x => x.startsWith("test_")) - .filter(x => x.endsWith(".json")) - .map(x => x.split("/").slice(-1)[0]) + .map((f) => f.name || "ignore") + .filter((x) => x.startsWith("test_")) + .filter((x) => x.endsWith(".json")) + .map((x) => x.split("/").slice(-1)[0]) .sort(); if (!Deno.env("_IN_DOCKER")) { @@ -17,7 +17,7 @@ if (!Deno.env("_IN_DOCKER")) { async function addFiles( zipOrFiles: string | Array | undefined, - toDir: string + toDir: string, ): Promise { if (!zipOrFiles) { return; @@ -26,7 +26,7 @@ async function addFiles( const zipFile = zipOrFiles; // TODO check it raises on errors? const p = Deno.run({ - cmd: ["unzip", "-qq", `/src/runtime/${zipFile}`, "-d", toDir] + cmd: ["unzip", "-qq", `/src/runtime/${zipFile}`, "-d", toDir], }); await p.status(); p.close(); @@ -52,7 +52,7 @@ for (const t of testFiles) { fn: async () => { const testPath = `/src/tests/${t}`; const testJson: TestJson = JSON.parse( - dec.decode(await Deno.readFile(testPath)) + dec.decode(await Deno.readFile(testPath)), ); // This is the layer @@ -64,11 +64,11 @@ for (const t of testFiles) { await addFiles(testJson["files"], "/var/task"); const out = await serveEvents(testJson); - const responses = out.responses.map(x => JSON.parse(x)); + const responses = out.responses.map((x) => JSON.parse(x)); const expected = testJson["expected"]; assertEquals(expected, responses); // console.log(out.out) // FIXME this is always empty - } + }, }); }