Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions .github/actions/setup-js/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Setup JS
description: Sets up Node.js and install NPM dependencies

inputs:
enable-cache:
description: Determines if actions/setup-node will have cache enabled
required: true
type: boolean

runs:
using: composite
steps:
- name: Setup Node.js (with cache)
if: ${{ inputs.enable-cache }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
cache: yarn
node-version: 24

- name: Setup Node.js (without cache)
if: ${{ !inputs.enable-cache }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24

- name: Install NPM dependencies
run: yarn install --immutable
shell: bash
49 changes: 17 additions & 32 deletions .github/workflows/lint-cpp-objc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,26 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
lint-cpp-objc:
name: Lint cpp and objc
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
matrix:
path:
- 'cpp'
- 'encoding-core'
- 'native-tests'
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
- name: Setup JS
uses: ./.github/actions/setup-js
with:
cache: 'yarn'
node-version: 20
enable-cache: true

- name: Install dependencies
run: yarn install --immutable
shell: bash

# https://dev.to/mayankpareek/introducing-ci-pipeline-for-clang-format-checks-in-faker-cxx-35go
# - name: Cache clang-format dependencies
# uses: actions/cache@v4
# with:
# path: /tmp/apt-cache
# key: clang-format-${{ runner.os }}-${{ hashFiles('**/apt-packages.txt') }}
# restore-keys: |
# clang-format-${{ runner.os }}-

# - name: Install clang-format
# run: |
# if [ ! -f /tmp/apt-cache/clang-format-16 ]; then
# sudo apt-get update
# sudo apt-get install -y clang-format-16
# touch /tmp/apt-cache/clang-format-16
# fi

- name: Run clang-format
run: |
yarn lint:cpp
yarn lint:objc
- name: Run ClangFormat
uses: jidicula/clang-format-action@654a770daa28443dd111d133e4083e21c1075674 #v4.18.0
with:
check-path: ${{ matrix.path }}
exclude-regex: '^encoding-core/base64.hpp$'
19 changes: 8 additions & 11 deletions .github/workflows/lint-js-typecheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,22 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
lint-js-typecheck:
name: JS lint and typecheck
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
- name: Setup JS
uses: ./.github/actions/setup-js
with:
cache: 'yarn'
node-version: 20

- name: Install dependencies
run: yarn install --immutable
shell: bash
enable-cache: true

- name: Run ESLint
run: yarn lint:js
shell: bash

- name: Run TypeScript
run: yarn typecheck
shell: bash
49 changes: 0 additions & 49 deletions .github/workflows/release.yml

This file was deleted.

18 changes: 7 additions & 11 deletions .github/workflows/test-cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
test-cpp:
name: Run GTest suite
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
- name: Setup JS
uses: ./.github/actions/setup-js
with:
cache: 'yarn'
node-version: 20

- name: Install dependencies
run: yarn install --immutable
shell: bash
enable-cache: true

- name: Run GTest
run: yarn test:cpp:prepare
shell: bash
18 changes: 7 additions & 11 deletions .github/workflows/test-js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,18 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
test-js:
name: Run Jest suite
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
- name: Setup JS
uses: ./.github/actions/setup-js
with:
cache: 'yarn'
node-version: 20

- name: Install dependencies
run: yarn install --immutable
shell: bash
enable-cache: true

- name: Run Jest
run: yarn test:js
shell: bash
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ node_modules/

build/
lib/

.DS_Store
5 changes: 5 additions & 0 deletions PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# How to publish release?

**Prerequisites:** authenticate via `npm login`

Run `yarn release` and follow changeset's flow
29 changes: 15 additions & 14 deletions native-tests/ReactNativeEncodingDataset.h

Large diffs are not rendered by default.

44 changes: 24 additions & 20 deletions native-tests/ReactNativeEncodingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,46 @@ TEST_P(Base64DecodeTest, ShouldDecodeBase64BufferToUTF8String) {
EXPECT_EQ(result, this->output);
}

INSTANTIATE_TEST_SUITE_P(
Base64DecodeTestSuite,
Base64DecodeTest,
testing::ValuesIn(dataset),
[](const testing::TestParamInfo<Base64DecodeTest::ParamType> &info) { return std::to_string(info.index); });
INSTANTIATE_TEST_SUITE_P(Base64DecodeTestSuite,
Base64DecodeTest,
testing::ValuesIn(dataset),
[](const testing::TestParamInfo<Base64DecodeTest::ParamType> &info) {
return std::to_string(info.index);
});

TEST_P(Base64EncodeTest, ShouldEncodeUTF8BufferToBase64String) {
auto result =
encodeFromUtf8BufferToBase64String(reinterpret_cast<const uint8_t *>(this->input.data()), this->input.length());
EXPECT_EQ(result, this->output);
}

INSTANTIATE_TEST_SUITE_P(
Base64EncodeTestSuite,
Base64EncodeTest,
testing::ValuesIn(dataset),
[](const testing::TestParamInfo<Base64EncodeTest::ParamType> &info) { return std::to_string(info.index); });
INSTANTIATE_TEST_SUITE_P(Base64EncodeTestSuite,
Base64EncodeTest,
testing::ValuesIn(dataset),
[](const testing::TestParamInfo<Base64EncodeTest::ParamType> &info) {
return std::to_string(info.index);
});

TEST_P(HexDecodeTest, ShouldDecodeHexStringToUTF8String) {
auto result = decodeFromHexStringToUTF8String(this->input);
EXPECT_EQ(result, this->output);
}

INSTANTIATE_TEST_SUITE_P(
HexDecodeTestSuite,
HexDecodeTest,
testing::ValuesIn(dataset),
[](const testing::TestParamInfo<HexDecodeTest::ParamType> &info) { return std::to_string(info.index); });
INSTANTIATE_TEST_SUITE_P(HexDecodeTestSuite,
HexDecodeTest,
testing::ValuesIn(dataset),
[](const testing::TestParamInfo<HexDecodeTest::ParamType> &info) {
return std::to_string(info.index);
});

TEST_P(HexEncodeTest, ShouldEncodeUTF8StringToHexString) {
auto result = encodeFromUTF8StringToHexString(this->input);
EXPECT_EQ(result, this->output);
}

INSTANTIATE_TEST_SUITE_P(
HexEncodeTestSuite,
HexEncodeTest,
testing::ValuesIn(dataset),
[](const testing::TestParamInfo<HexEncodeTest::ParamType> &info) { return std::to_string(info.index); });
INSTANTIATE_TEST_SUITE_P(HexEncodeTestSuite,
HexEncodeTest,
testing::ValuesIn(dataset),
[](const testing::TestParamInfo<HexEncodeTest::ParamType> &info) {
return std::to_string(info.index);
});