Skip to content

Commit

Permalink
chore(release): 1.22.0 (#2590)
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-cdk-automation authored Feb 23, 2021
1 parent 4262b22 commit 21cfa24
Show file tree
Hide file tree
Showing 56 changed files with 2,703 additions and 1,505 deletions.
25 changes: 6 additions & 19 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,34 @@
version: 2

updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: daily
labels:
- dependencies
versioning-strategy: increase
ignore:
- dependency-name: typescript
versions:
- '>= 3.10.a'
- dependency-name: '@types/node'
versions:
- '>= 11.a'

- package-ecosystem: nuget
directory: '/packages/@jsii/dotnet-runtime/src'
schedule:
interval: daily
interval: weekly
labels:
- dependencies
- language/dotnet

- package-ecosystem: nuget
directory: '/packages/@jsii/dotnet-runtime-test/test'
schedule:
interval: daily
interval: weekly
labels:
- dependencies
- language/dotnet

- package-ecosystem: pip
directory: '/packages/@jsii/python-runtime'
schedule:
interval: daily
interval: weekly
labels:
- dependencies
- language/python

- package-ecosystem: pip
directory: '/gh-pages'
schedule:
interval: daily
interval: weekly
labels:
- dependencies
- language/python
Expand All @@ -68,3 +53,5 @@ updates:
directory: '/'
schedule:
interval: daily
labels:
- dependencies
13 changes: 13 additions & 0 deletions .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Approve PRs with "pr/auto-approve". mergify takes care of the actual merge.

name: auto-approve
on: pull_request

jobs:
auto-approve:
if: contains(github.event.pull_request.labels.*.name, 'pr/auto-approve')
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v2.0.0
with:
github-token: "${{ secrets.AUTO_APPROVE_GITHUB_TOKEN }}"
28 changes: 0 additions & 28 deletions .github/workflows/dependabot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ jobs:
- name: Integration Test (build)
run: |-
npx lerna run build --concurrency=2 --stream 2>&1 > ${{ runner.temp }}/build.log
npx lerna run build --concurrency=1 --stream 2>&1 > ${{ runner.temp }}/build.log
working-directory: aws-cdk
env:
# Make lots of memory available, aws-cdk-lib is __large__
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.22.0](https://github.com/aws/jsii/compare/v1.21.0...v1.22.0) (2021-02-18)


### Bug Fixes

* **go:** map values incorrectly handled though de/serialization ([#2587](https://github.com/aws/jsii/issues/2587)) ([0359928](https://github.com/aws/jsii/commit/035992887b3346e6cb1e66d0bb66c3029de2917f))
* **go-runtime:** enums are not encoded/decoded correctly ([#2585](https://github.com/aws/jsii/issues/2585)) ([4731aeb](https://github.com/aws/jsii/commit/4731aeb6ad85c04160b30232e85e3f8a43c712a6)), closes [#2534](https://github.com/aws/jsii/issues/2534)
* **jsii:** excessive "exclude" in "tsconfig.json" ([#1736](https://github.com/aws/jsii/issues/1736)) ([ecffb9f](https://github.com/aws/jsii/commit/ecffb9f9dd7f02643fb2af30d9c0052f7465691d))
* **pacmak:** go local replace do not respect `--outdir` in some cases ([#2584](https://github.com/aws/jsii/issues/2584)) ([b9b9b4c](https://github.com/aws/jsii/commit/b9b9b4ca9dbb535b714df4ba506a31a5fc56c773))

## [1.21.0](https://github.com/aws/jsii/compare/v1.20.1...v1.21.0) (2021-02-15)


Expand Down
4 changes: 2 additions & 2 deletions gh-pages/content/specification/2-type-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ value:

In **JavaScript**, `enum` entries are represented by their value equivalent. In order to support statically typed
representations in other languages, these are serialized using a dedicated wrapper object, using a single key
(`$jsii.enum`) with the fully qualified name of the `enum` entry:
(`$jsii.enum`) with the fully qualified name of the `enum` entry (formatted as `<enum type fqn>/<entry name>`):

```json
{ "$jsii.enum": "@scope/module.EnumType.ENTRY_NAME" }
{ "$jsii.enum": "@scope/module.EnumType/ENTRY_NAME" }
```

### Identity Serialization
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"rejectCycles": true
}
},
"version": "1.21.0"
"version": "1.22.0"
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
},
"devDependencies": {
"@jest/types": "^26.6.2",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"all-contributors-cli": "^6.20.0",
"eslint": "^7.19.0",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint-import-resolver-node": "^0.3.4",
"eslint-import-resolver-typescript": "^2.3.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1",
"jest-circus": "^26.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/dotnet-runtime-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@jsii/dotnet-runtime": "^0.0.0",
"@types/node": "^10.17.51",
"@types/node": "^10.17.52",
"jsii-calc": "^3.20.120",
"jsii-pacmak": "^0.0.0",
"typescript": "~3.9.9"
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/dotnet-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"devDependencies": {
"@jsii/runtime": "^0.0.0",
"@types/node": "^10.17.51",
"@types/node": "^10.17.52",
"@types/semver": "^7.3.4",
"jsii-build-tools": "^0.0.0",
"semver": "^7.3.4",
Expand Down
1 change: 1 addition & 0 deletions packages/@jsii/go-runtime/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/jsii-calc/
*.generated.go
*.generated_test.go

*.js
*.d.ts
1 change: 1 addition & 0 deletions packages/@jsii/go-runtime/build-tools/gen-calc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ runCommand(
'-t',
'go',
'-v',
'-c',
'-o',
genRoot,
'--recurse',
Expand Down
145 changes: 121 additions & 24 deletions packages/@jsii/go-runtime/build-tools/gen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env npx ts-node

import { CodeMaker } from 'codemaker';
import { createHash } from 'crypto';
import { readdirSync, readFileSync, statSync } from 'fs';
import { resolve } from 'path';

Expand All @@ -15,6 +16,7 @@ const EMBEDDED_RUNTIME_ROOT = resolve(
const OUTPUT_DIR = resolve(__dirname, '..', 'jsii-runtime-go');

const RUNTIME_FILE = 'embeddedruntime.generated.go';
const RUNTIME_TEST_FILE = 'embeddedruntime.generated_test.go';
const VERSION_FILE = 'version.generated.go';

const code = new CodeMaker({ indentationLevel: 1, indentCharacter: '\t' });
Expand All @@ -23,8 +25,10 @@ code.openFile(RUNTIME_FILE);
code.line('package jsii');
code.line();
code.open('var embeddedruntime = map[string][]byte{');
const bytesPerLine = 16;
const fileSize: Record<string, number> = {};
const fileInfo: Record<
string,
{ readonly size: number; readonly hash: readonly string[] }
> = {};

(function emitFiles(directory: string, prefix?: string) {
for (const file of readdirSync(directory)) {
Expand All @@ -42,35 +46,83 @@ const fileSize: Record<string, number> = {};

const key = prefix ? `${prefix}/${file}` : file;

const byteSlice = getByteSlice(fullPath);
fileSize[key] = byteSlice.length;
const { byteSlice, hash } = getByteSlice(fullPath);
fileInfo[key] = {
size: byteSlice.length,
hash,
};
code.open(`${JSON.stringify(key)}: []byte{`);
for (let i = 0; i < byteSlice.length; i += bytesPerLine) {
const line = byteSlice.slice(i, i + bytesPerLine);
code.line(`${line.join(', ')},`);
}
formatBytes(code, byteSlice);
code.close('},');
}
})(EMBEDDED_RUNTIME_ROOT);

code.close('}');
code.line();
const mainKey = JSON.stringify(
Object.keys(fileSize).find((f) => f.endsWith('jsii-runtime.js')),
Object.keys(fileInfo).find((f) => f.endsWith('jsii-runtime.js')),
)!;
code.line(`const embeddedruntimeMain = ${mainKey}`);
code.closeFile(RUNTIME_FILE);

// This allows us to sanity-check we've generated correct data
code.openFile(RUNTIME_TEST_FILE);
code.line('package jsii');
code.line();
// This performs sanity tests upon initialization
code.open('func init() {');
for (const [file, size] of Object.entries(fileSize)) {
code.open(`if len(embeddedruntime[${JSON.stringify(file)}]) != ${size} {`);
code.line(
`panic("Embedded runtime file ${file} does not have expected size of ${size} bytes!")`,
);
code.close('}');
code.open('import (');
code.line('"crypto/sha512"');
code.line('"testing"');
code.close(')');
code.line();
code.openBlock('func TestEmbeddedruntime(t *testing.T)');

code.open(
't.Run("embeddedruntime[embeddedruntimeMain] exists", func(t *testing.T) {',
);
code.openBlock('if _, exists := embeddedruntime[embeddedruntimeMain]; !exists');
code.line(
't.Errorf("embeddedruntimeMain refers to non-existent file %s", embeddedruntimeMain)',
);
code.closeBlock();
code.close('})');

for (const [file, { size, hash }] of Object.entries(fileInfo)) {
code.line();
code.open(`t.Run("embeddedruntime[\\"${file}\\"]", func(t *testing.T) {`);

code.open('checkEmbeddedFile(');
code.line('t,');
code.line(`"${file}",`);
code.line(`${readableNumber(size)},`);
code.open('[sha512.Size]byte{');
formatBytes(code, hash);
code.close('},');
code.close(')');

code.close('})');
}
code.close('}');
code.closeFile(RUNTIME_FILE);
code.closeBlock();
code.line();
code.openBlock(
'func checkEmbeddedFile(t *testing.T, name string, expectedSize int, expectedHash [sha512.Size]byte)',
);
code.line('data := embeddedruntime[name]');
code.line();
code.line('size := len(data)');
code.openBlock('if size != expectedSize');
code.line(
't.Errorf("Size mismatch: expected %d bytes, got %d", expectedSize, size)',
);
code.closeBlock();
code.line();
code.line('hash := sha512.Sum512(data)');
code.openBlock('if hash != expectedHash');
code.line(
't.Errorf("SHA512 do not match:\\nExpected: %x\\nActual: %x", expectedHash, hash)',
);
code.closeBlock();
code.closeBlock();
code.closeFile(RUNTIME_TEST_FILE);

code.openFile(VERSION_FILE);
code.line('package jsii');
Expand All @@ -83,12 +135,57 @@ code.closeFile(VERSION_FILE);

code.save(OUTPUT_DIR).catch(console.error);

function getByteSlice(path: string) {
const fileData = readFileSync(path).toString('hex');
function getByteSlice(path: string): { byteSlice: string[]; hash: string[] } {
const rawData = readFileSync(path);
return {
byteSlice: toHexBytes(rawData),
hash: toHexBytes(createHash('SHA512').update(rawData).digest()),
};
}

function toHexBytes(rawData: Buffer): string[] {
const hexString = rawData.toString('hex');
const result = [];
for (let i = 0; i < fileData.length; i += 2) {
result.push(`0x${fileData[i]}${fileData[i + 1]}`);
for (let i = 0; i < hexString.length; i += 2) {
result.push(`0x${hexString[i]}${hexString[i + 1]}`);
}

return result;
}

function formatBytes(
code: CodeMaker,
byteSlice: readonly string[],
bytesPerLine = 16,
) {
for (let i = 0; i < byteSlice.length; i += bytesPerLine) {
const line = byteSlice.slice(i, i + bytesPerLine);
code.line(`${line.join(', ')},`);
}
}

/**
* Turns a integer into a "human-readable" format, adding an `_` thousand
* separator.
*
* @param val an integer to be formatted.
*
* @returns the formatted number with thousand separators.
*/
function readableNumber(val: number): string {
return val.toFixed(0).replace(
// This regex can be a little jarring, so it is annotated below with the
// corresponding explanation. It can also be explained in plain english:
// matches the position before any sequence of N consecutive digits (0-9)
// where N is a multiple of 3.
/**/ /\B(?=(\d{3})+(?!\d))/g,
// \B -- not a word boundary (i.e: not start of input)
// (?= ) -- positive lookahead (does not consume input)
// ( )+ -- repeated one or more times
// \d -- any digit (0-9)
// {3} -- repeated exactly 3 times
// (?! ) -- negative lookahead (does not consume input)
// \d -- any digit (0-9), negated by surrounding group
//
'_',
);
}
Loading

0 comments on commit 21cfa24

Please sign in to comment.