Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the NUClear codebase to the latest version #21

Merged
merged 26 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9de84ab
Squashed 'src/nuclear/' changes from 269f903..f6704a1
TrentHouliston Jan 8, 2024
0fc25c8
Sync NUClear to latest main
TrentHouliston Jan 8, 2024
a7bf09a
Match new NUClear API
TrentHouliston Jan 8, 2024
fc2955e
Perhaps this should be split into multiple PRs
TrentHouliston Jan 9, 2024
acc40c1
actions
TrentHouliston Jan 9, 2024
57336a1
more versions
TrentHouliston Jan 9, 2024
de42e59
concurrency
TrentHouliston Jan 9, 2024
350d062
Don't stop just because one failed
TrentHouliston Jan 9, 2024
3bafcd8
.
TrentHouliston Jan 9, 2024
44a956c
missing symbol on windows
TrentHouliston Jan 9, 2024
b5b20e5
500 extra ms ensures that a leave/drop will happen
TrentHouliston Jan 9, 2024
8169fda
2000ms?
TrentHouliston Jan 9, 2024
5b0efb5
Update .gitignore
TrentHouliston Jan 15, 2024
0e2e2f8
Merge branch 'main' into houliston/update_nuclear
TrentHouliston Apr 8, 2024
5f20037
Give CI something to log
TrentHouliston Apr 24, 2024
74ad68c
Merge branch 'main' into houliston/update_nuclear
TrentHouliston Apr 24, 2024
b46436e
.
TrentHouliston Apr 29, 2024
5231d80
.
TrentHouliston Apr 29, 2024
9960cbd
rearrange where memory is used
TrentHouliston Apr 29, 2024
72e1d41
.
TrentHouliston Apr 29, 2024
6525250
remove logs
TrentHouliston Apr 29, 2024
0adcc1e
Bump version to 1.7.0
TrentHouliston Apr 29, 2024
dea624c
fix settings.json
TrentHouliston Apr 29, 2024
39cb60f
.
TrentHouliston Apr 29, 2024
4bd1faa
Update .github/workflows/publish-to-npm.yml
TrentHouliston Apr 29, 2024
d16685b
undo changes
TrentHouliston Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# C++ files
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: true
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
FixNamespaceComments: true
IncludeBlocks: Regroup
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWrappedFunctionNames: true
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: Inner
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
50 changes: 31 additions & 19 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ name: Node.js CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

# Ensure that only one instance of the workflow is run at a time for each branch/tag.
# Jobs currently running on the branch/tag will be cancelled when new commits are pushed.
# See https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency.
concurrency:
# `github.workflow` is the workflow name, `github.ref` is the current branch/tag identifier
group: ${{ format('{0}:{1}', github.workflow, github.ref) }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
build:

runs-on: ${{ matrix.os }}
continue-on-error: true

strategy:
matrix:
Expand All @@ -21,19 +29,23 @@ jobs:
node-version: [18.x, 20.x]

steps:
# Install node-gyp
- name: Install node-gyp
run: npm install -g node-gyp
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
# Run the tests up to 5 times if it fails (to avoid the error "Network error when sending
# the announce packet: Bad file descriptor" that occurs sometimes on startup)
# TODO: investigate and fix the actual issue.
- shell: bash
run: ./tests/run-with-retries.sh
- name: Checkout Code
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Install node-gyp
run: npm install -g node-gyp

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build --if-present

- name: Run tests
run: npm test
26 changes: 15 additions & 11 deletions .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@ jobs:
publish_to_npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: main

# Installs Node and sets up up the .npmrc file to publish to npm
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
# Run the tests up to 5 times if it fails (to avoid the error "Network error when sending
# the announce packet: Bad file descriptor" that occurs sometimes on startup)
# TODO: investigate and fix the actual issue.
- shell: bash
run: ./tests/run-with-retries.sh
- run: node .github/auto-publish-action.js
node-version: "18.x"
registry-url: "https://registry.npmjs.org"

- name: "Install Dependencies"
run: npm ci

- name: "Test Code"
run: npm test

- name: "Publish to npm"
run: node .github/auto-publish-action.js
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ build/Release
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
build

# # Mac OS X clutter
.DS_Store
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.eol": "\n",
"editor.rulers": [120],
"files.associations": {
"*.ipp": "cpp"
}
}
7 changes: 4 additions & 3 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
'src/NetworkListener.cpp',
'src/nuclear/src/extension/network/NUClearNetwork.cpp',
'src/nuclear/src/util/platform.cpp',
'src/nuclear/src/util/serialise/xxhash.c',
'src/nuclear/src/util/network/get_interfaces.cpp'
'src/nuclear/src/util/network/get_interfaces.cpp',
'src/nuclear/src/util/network/if_number_from_address.cpp',
'src/nuclear/src/util/network/resolve.cpp',
'src/nuclear/src/util/serialise/xxhash.cpp'
],
'cflags': [],
'include_dirs': [
'<!@(node -p "require(\'node-addon-api\').include")',
"<!@(node -p \"require('napi-thread-safe-callback').include\")",
'src/nuclear/src/include'
],
"defines": [
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class NUClearNet extends EventEmitter {
}
});

// Bind our callback functions
this._net.on('packet', this._onPacket.bind(this));
this._net.on('join', this._onJoin.bind(this));
this._net.on('leave', this._onLeave.bind(this));
this._net.on('wait', this._onWait.bind(this));
// Pass our javascript callbacks to the C++ side
this._net.onPacket(this._onPacket.bind(this));
this._net.onJoin(this._onJoin.bind(this));
this._net.onLeave(this._onLeave.bind(this));
this._net.onWait(this._onWait.bind(this));
}

_onPacket(name, address, port, reliable, hash, payload) {
Expand Down
92 changes: 63 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading