Skip to content

Commit 386953b

Browse files
add nodejs/node ncrypto sync workflow (#42)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 88555cc commit 386953b

12 files changed

Lines changed: 513 additions & 51 deletions

.github/sync-node-ncrypto.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"node_commit": "8385efc01343a835e3a0efe05611f44272cbb413"
3+
}

.github/workflows/bazel.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
macos:
2626
runs-on: macos-latest
2727
steps:
28-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29-
- uses: bazel-contrib/setup-bazel@bbf8fe8b219f642c7f8bc673215f28eb1d9dec51 # v0.10.0
28+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
- uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0
3030
with:
3131
bazelisk-cache: true
3232
disk-cache: ${{ github.workflow }}
@@ -45,8 +45,8 @@ jobs:
4545
cxx: clang++-18
4646
runs-on: ubuntu-latest
4747
steps:
48-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
49-
- uses: bazel-contrib/setup-bazel@bbf8fe8b219f642c7f8bc673215f28eb1d9dec51 # v0.10.0
48+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
49+
- uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0
5050
with:
5151
bazelisk-cache: true
5252
disk-cache: ${{ github.workflow }}

.github/workflows/commitlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
commitlint:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
13+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1414
with:
1515
fetch-depth: 100
1616
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1

.github/workflows/linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
lint:
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
27+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2828

2929
- name: Run clang-format
30-
uses: jidicula/clang-format-action@6cd220de46c89139a0365edae93eee8eb30ca8fe # v4.16.0
30+
uses: jidicula/clang-format-action@654a770daa28443dd111d133e4083e21c1075674 # v4.18.0
3131
with:
3232
clang-format-version: '21'
3333
fallback-style: 'Google'

.github/workflows/macos.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828
runs-on: [macos-14, macos-15]
2929
runs-on: ${{matrix.runs-on}}
3030
steps:
31-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
31+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3232
- name: ccache
33-
uses: hendrikmuhs/[email protected]
33+
uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
3434
with:
3535
key: ${{github.job}}-${{matrix.os}}
3636
- name: Prepare
@@ -40,4 +40,4 @@ jobs:
4040
# Ref: https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners
4141
run: cmake --build build -j=3
4242
- name: Test
43-
run: ctest --output-on-failure --test-dir build
43+
run: ctest --output-on-failure --test-dir build

.github/workflows/release-please.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
release-please:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
16+
- uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Sync Node ncrypto
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
node_ref:
7+
description: nodejs/node ref to sync from
8+
required: true
9+
default: main
10+
base_node_ref:
11+
description: Optional previous nodejs/node ref for bootstrap or recovery
12+
required: false
13+
default: ''
14+
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
19+
jobs:
20+
sync:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
with:
25+
ref: main
26+
fetch-depth: 0
27+
28+
- name: Sync from nodejs/node
29+
id: sync
30+
env:
31+
NODE_REF: ${{ inputs.node_ref }}
32+
BASE_NODE_REF: ${{ inputs.base_node_ref }}
33+
run: |
34+
python3 tools/sync-node-ncrypto.py \
35+
--node-ref "$NODE_REF" \
36+
--base-node-ref "$BASE_NODE_REF"
37+
38+
- name: Stop when there are no changes
39+
if: steps.sync.outputs.has_changes != 'true'
40+
run: echo 'No ncrypto changes to sync.'
41+
42+
- name: Commit sync branch
43+
id: commit
44+
if: steps.sync.outputs.has_changes == 'true'
45+
run: |
46+
branch='${{ steps.sync.outputs.branch_name }}'
47+
git switch -c "$branch"
48+
git fetch origin "$branch:refs/remotes/origin/$branch" || true
49+
git config user.name 'github-actions[bot]'
50+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
51+
git add \
52+
.github/sync-node-ncrypto.json \
53+
include/ncrypto.h \
54+
src/engine.cpp \
55+
src/ncrypto.cpp
56+
git commit \
57+
-m 'chore: sync ncrypto from nodejs/node' \
58+
-m 'Node-Base-Commit: ${{ steps.sync.outputs.base_sha }}' \
59+
-m 'Node-Target-Commit: ${{ steps.sync.outputs.target_sha }}'
60+
git push --force-with-lease origin "$branch"
61+
echo "branch=$branch" >> "$GITHUB_OUTPUT"
62+
63+
- name: Prepare PR body
64+
if: steps.sync.outputs.has_changes == 'true'
65+
run: |
66+
{
67+
echo 'Syncs `deps/ncrypto` from `nodejs/node` into this repository.'
68+
echo
69+
echo '- Base node commit: `${{ steps.sync.outputs.base_sha }}`'
70+
echo '- Target node commit: `${{ steps.sync.outputs.target_sha }}`'
71+
echo '- Conflicts: `${{ steps.sync.outputs.has_conflicts }}`'
72+
if [ '${{ steps.sync.outputs.has_conflicts }}' = 'true' ]; then
73+
echo
74+
echo 'This PR was opened as a draft because the 3-way merge produced conflicts:'
75+
echo
76+
printf '%s\n' '${{ steps.sync.outputs.conflicts }}' | sed 's/^/- `/' | sed 's/$/`/'
77+
fi
78+
} > "$RUNNER_TEMP/pr-body.md"
79+
80+
- name: Open or update PR
81+
if: steps.sync.outputs.has_changes == 'true'
82+
env:
83+
GH_TOKEN: ${{ github.token }}
84+
run: |
85+
branch='${{ steps.commit.outputs.branch }}'
86+
title='chore: sync ncrypto from nodejs/node'
87+
existing_url="$(gh pr view "$branch" --json url --jq .url 2>/dev/null || true)"
88+
if [ -n "$existing_url" ]; then
89+
gh pr edit "$branch" --title "$title" --body-file "$RUNNER_TEMP/pr-body.md"
90+
if [ '${{ steps.sync.outputs.has_conflicts }}' = 'true' ]; then
91+
gh pr ready "$branch" --undo || true
92+
else
93+
gh pr ready "$branch" || true
94+
fi
95+
echo "$existing_url"
96+
exit 0
97+
fi
98+
99+
args=(
100+
pr create
101+
--base main
102+
--head "$branch"
103+
--title "$title"
104+
--body-file "$RUNNER_TEMP/pr-body.md"
105+
)
106+
if [ '${{ steps.sync.outputs.has_conflicts }}' = 'true' ]; then
107+
args+=(--draft)
108+
fi
109+
gh "${args[@]}"

.github/workflows/ubuntu.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ jobs:
2929
cxx: [g++-14]
3030
runs-on: ${{matrix.runs-on}}
3131
steps:
32-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3333
- name: ccache
34-
uses: hendrikmuhs/[email protected]
34+
uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
3535
with:
3636
key: ${{github.job}}-${{matrix.os}}-{{matrix.shared}}
3737
- name: Setup Ninja
@@ -52,10 +52,10 @@ jobs:
5252
OPENSSL_VERSION: "3.4.1"
5353
OPENSSL_DIR: "${{ github.workspace }}/openssl-install"
5454
steps:
55-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
55+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5656
- name: Cache OpenSSL
5757
id: cache-openssl
58-
uses: actions/cache@v4
58+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
5959
with:
6060
path: ${{ env.OPENSSL_DIR }}
6161
key: openssl-${{ env.OPENSSL_VERSION }}-${{ runner.os }}
@@ -69,7 +69,7 @@ jobs:
6969
make -j$(nproc)
7070
make install_sw
7171
- name: ccache
72-
uses: hendrikmuhs/[email protected]
72+
uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
7373
with:
7474
key: ${{github.job}}-openssl
7575
- name: Setup dependencies
@@ -93,10 +93,10 @@ jobs:
9393
OPENSSL_VERSION: "3.4.1"
9494
OPENSSL_DIR: "${{ github.workspace }}/openssl-install"
9595
steps:
96-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
96+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
9797
- name: Cache OpenSSL
9898
id: cache-openssl
99-
uses: actions/cache@v4
99+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
100100
with:
101101
path: ${{ env.OPENSSL_DIR }}
102102
key: openssl-${{ env.OPENSSL_VERSION }}-${{ runner.os }}
@@ -110,7 +110,7 @@ jobs:
110110
make -j$(nproc)
111111
make install_sw
112112
- name: ccache
113-
uses: hendrikmuhs/[email protected]
113+
uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
114114
with:
115115
key: ${{github.job}}-openssl-no-argon2
116116
- name: Setup dependencies

.github/workflows/visual-studio.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
- {gen: Visual Studio 17 2022, arch: x64, config: Release}
3131
- {gen: Visual Studio 17 2022, arch: x64, config: Debug}
3232
steps:
33-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
33+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3434
- name: ccache
35-
uses: hendrikmuhs/[email protected]
35+
uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
3636
with:
3737
key: ${{github.job}}-${{matrix.os}}-${{matrix.config}}
3838
- name: Install Dependencies

include/ncrypto.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,9 @@ class EVPKeyPointer final {
899899
DER,
900900
PEM,
901901
JWK,
902+
RAW_PUBLIC,
903+
RAW_PRIVATE,
904+
RAW_SEED,
902905
};
903906

904907
enum class PKParseError { NOT_RECOGNIZED, NEED_PASSPHRASE, FAILED };
@@ -908,6 +911,7 @@ class EVPKeyPointer final {
908911
bool output_key_object = false;
909912
PKFormatType format = PKFormatType::DER;
910913
PKEncodingType type = PKEncodingType::PKCS8;
914+
int ec_point_form = POINT_CONVERSION_UNCOMPRESSED;
911915
AsymmetricKeyEncodingConfig() = default;
912916
AsymmetricKeyEncodingConfig(bool output_key_object,
913917
PKFormatType format,
@@ -1622,8 +1626,9 @@ int NoPasswordCallback(char* buf, int size, int rwflag, void* u);
16221626

16231627
int PasswordCallback(char* buf, int size, int rwflag, void* u);
16241628

1625-
bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext);
1626-
bool SafeX509InfoAccessPrint(const BIOPointer& out, X509_EXTENSION* ext);
1629+
bool SafeX509SubjectAltNamePrint(const BIOPointer& out,
1630+
const X509_EXTENSION* ext);
1631+
bool SafeX509InfoAccessPrint(const BIOPointer& out, const X509_EXTENSION* ext);
16271632

16281633
// ============================================================================
16291634
// SPKAC

0 commit comments

Comments
 (0)