Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #64 from hayd/pr63
Browse files Browse the repository at this point in the history
Bump to 0.39.0
  • Loading branch information
hayd authored Apr 4, 2020
2 parents 0885d86 + 71607dc commit cc3f525
Show file tree
Hide file tree
Showing 27 changed files with 169 additions and 144 deletions.
84 changes: 18 additions & 66 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,32 @@
name: Test
on: push
on: [push, pull_request]
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
test_example:
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.38.0
deno-version: 0.39.0
- name: start a local dynamodb
run: |
mkdir dyno
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 ---
4 changes: 2 additions & 2 deletions example-sam/hello.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {

export async function handler(
event: APIGatewayProxyEvent,
context: Context
context: Context,
): Promise<APIGatewayProxyResult> {
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} 🦕`,
};
}
6 changes: 3 additions & 3 deletions example-sam/template.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AWSTemplateFormatVersion: '2010-09-09'
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
sam-hello
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions example-serverless/api/candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -27,8 +27,8 @@ export async function get(event: APIGatewayProxyEvent, context: Context) {
const params = {
TableName,
Key: {
id: id
}
id: id,
},
};
let result: Doc;
try {
Expand All @@ -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 {
Expand Down Expand Up @@ -94,7 +94,7 @@ export async function submit(event: APIGatewayProxyEvent, context: Context) {
email,
experience,
submittedAt: now,
updatedAt: now
updatedAt: now,
};

try {
Expand All @@ -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,
});
}
2 changes: 1 addition & 1 deletion example-serverless/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export {
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;
2 changes: 1 addition & 1 deletion example-serverless/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions example-serverless/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import {
assert,
assertEquals
} from "https://deno.land/std@v0.38.0/testing/asserts.ts";
} from "https://deno.land/std@v0.39.0/testing/asserts.ts";
import {
APIGatewayProxyEvent,
Context
Expand All @@ -27,71 +27,71 @@ test({
fn: async () => {
const result = await client.getItem({
TableName,
Key: { id: "abc" }
Key: { id: "abc" },
});
const user = result.Item;
assertEquals(user.role, "admin");
}
},
});

test({
name: "test list",
fn: async () => {
const result = await listCandidate(
{} as APIGatewayProxyEvent,
{} as Context
{} as Context,
);
assertEquals(result.statusCode, 200);
const body = JSON.parse(result.body);
assertEquals(body.candidates.length, 2);
}
},
});

test({
name: "test get",
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);
assertEquals(body.id, "abc");
assertEquals(body.role, "admin");
}
},
});

test({
name: "test get missing",
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);
assertEquals(body.message, "Not Found: bad");
}
},
});

test({
name: "test submit",
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,
{} 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",
);
}
},
});

test({
Expand All @@ -100,10 +100,10 @@ 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);
assertEquals(body.message, "invalid input");
}
},
});
Loading

0 comments on commit cc3f525

Please sign in to comment.