Skip to content

Commit

Permalink
Merge branch 'main' into deno
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 authored Dec 13, 2024
2 parents f45622f + 02ffc15 commit 2526a13
Show file tree
Hide file tree
Showing 39 changed files with 11,562 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .builder/actions/crt_size_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def run(self, env):
# Maximum package size (for current platform) in bytes
# NOTE: if you increase this, you might also need to increase the
# limit in continuous-delivery/pack.sh
max_size = 8_000_000
max_size = 8_250_000
# size of current folder
folder_size = 0
# total size in bytes
Expand Down
155 changes: 99 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ on:
- 'docs'

env:
BUILDER_VERSION: v0.9.62
BUILDER_VERSION: v0.9.73
BUILDER_SOURCE: releases
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
PACKAGE_NAME: aws-crt-nodejs
LINUX_BASE_IMAGE: ubuntu-18-x64
RUN: ${{ github.run_id }}-${{ github.run_number }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
CRT_CI_ROLE: ${{ secrets.CRT_CI_ROLE_ARN }}
AWS_DEFAULT_REGION: us-east-1

jobs:
permissions:
id-token: write # This is required for requesting the JWT

jobs:
linux-compat:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-24.04 # latest
strategy:
fail-fast: false
matrix:
Expand All @@ -35,54 +35,63 @@ jobs:
- rhel8-x64
- raspbian-bullseye
steps:
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- name: Build ${{ env.PACKAGE_NAME }}
run: |
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }}
musl-linux:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-24.04 # latest
strategy:
fail-fast: false
matrix:
image:
- alpine-3.16-x64
steps:
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- name: Build ${{ env.PACKAGE_NAME }}
run: |
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }}
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- name: Build ${{ env.PACKAGE_NAME }}
run: |
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }}
linux-musl-armv7:
runs-on: ubuntu-20.04 # latest
strategy:
fail-fast: false
matrix:
image:
- alpine-3.16-x64
steps:
- name: Install qemu/docker
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Checkout Sources
uses: actions/checkout@v2
with:
submodules: true
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- name: Build ${{ env.PACKAGE_NAME }}
run: |
export AWS_CRT_ARCH=armv7
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-alpine-3.16-armv7 build -p ${{ env.PACKAGE_NAME }}
runs-on: ubuntu-24.04 # latest
strategy:
fail-fast: false
matrix:
image:
- alpine-3.16-x64
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Install qemu/docker
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Checkout Sources
uses: actions/checkout@v2
with:
submodules: true
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- name: Build ${{ env.PACKAGE_NAME }}
run: |
export AWS_CRT_ARCH=armv7
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-alpine-3.16-armv7 build -p ${{ env.PACKAGE_NAME }}
linux-compiler-compat:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-24.04 # latest
strategy:
fail-fast: false
matrix:
Expand All @@ -93,14 +102,20 @@ jobs:
clang-9,
clang-10,
clang-11,
clang-15,
gcc-4.8,
gcc-5,
gcc-6,
gcc-7,
gcc-8
gcc-8,
gcc-11
]
steps:
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- name: Build ${{ env.PACKAGE_NAME }}
run: |
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
Expand All @@ -109,6 +124,10 @@ jobs:
windows:
runs-on: windows-2022 # latest
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
Expand All @@ -117,6 +136,10 @@ jobs:
windows-vc14-x86:
runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0)
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
env:
AWS_CMAKE_TOOLSET: v140
Expand All @@ -132,6 +155,10 @@ jobs:
macos:
runs-on: macos-14 # latest
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
Expand All @@ -145,6 +172,10 @@ jobs:
macos-x64:
runs-on: macos-14-large # latest
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
Expand All @@ -165,19 +196,27 @@ jobs:
# check that docs can still build
check-docs:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-24.04 # latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Check docs
run: |
npm ci
./make-docs.sh
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- uses: actions/checkout@v4
with:
submodules: true
- name: Check docs
run: |
npm ci
./make-docs.sh
check-submodules:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-24.04 # latest
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Checkout Source
uses: actions/checkout@v4
with:
Expand All @@ -189,11 +228,15 @@ jobs:
uses: awslabs/aws-crt-builder/.github/actions/check-submodules@main

check-lockfile-version:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-24.04 # latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for edits to package-lock.json
run: |
test `jq -r '.lockfileVersion' package-lock.json` = 1
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for edits to package-lock.json
run: |
test `jq -r '.lockfileVersion' package-lock.json` = 1
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ on:

jobs:
update-docs-branch:
runs-on: ubuntu-20.04 # latest
runs-on: ubuntu-24.04 # latest
permissions:
contents: write # allow push
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

Expand Down
2 changes: 2 additions & 0 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as http from './browser/http';
import * as crypto from './browser/crypto';
import * as iot from './browser/iot';
import * as auth from './browser/auth';
import * as mqtt_request_response from './browser/mqtt_request_response';
import { ICrtError, CrtError } from './browser/error';

export {
Expand All @@ -31,6 +32,7 @@ export {
io,
iot,
mqtt,
mqtt_request_response,
mqtt5,
platform,
promise,
Expand Down
10 changes: 8 additions & 2 deletions lib/browser/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
* @mergeTarget
*/

export { TlsVersion, SocketType, SocketDomain } from "../common/io";
import { SocketType, SocketDomain } from "../common/io";
import { setLogLevel, LogLevel, SocketType, SocketDomain } from "../common/io";
// Do not re-export the logging functions in common; they are package-private
export { setLogLevel, LogLevel, TlsVersion, SocketType, SocketDomain } from "../common/io";


/**
* @return false, as ALPN is not configurable from the browser
Expand Down Expand Up @@ -112,3 +114,7 @@ export class SocketOptions {
public keep_alive_max_failed_probes = 0) {
}
}

export function enable_logging(level: LogLevel) {
setLogLevel(level);
}
9 changes: 9 additions & 0 deletions lib/browser/mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,15 @@ export class MqttClientConnection extends BufferedEventEmitter {
});
}

/**
* Queries whether the client is currently connected
*
* @returns whether the client is currently connected
*/
is_connected() : boolean {
return this.currentState == MqttBrowserClientState.Connected;
}

private on_connect = (connack: mqtt.IConnackPacket) => {
this.on_online(connack.sessionPresent);
}
Expand Down
9 changes: 9 additions & 0 deletions lib/browser/mqtt5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,15 @@ export class Mqtt5Client extends BufferedEventEmitter implements mqtt5.IMqtt5Cli
});
}

/**
* Queries whether the client is currently connected
*
* @returns whether the client is currently connected
*/
isConnected() : boolean {
return this.lifecycleEventState == Mqtt5ClientLifecycleEventState.Connected;
}

/**
* Event emitted when the client encounters a disruptive error condition. Not currently used.
*
Expand Down
Loading

0 comments on commit 2526a13

Please sign in to comment.