8000 Merge remote-tracking branch 'upstream/main' · web3-geek/protobuf-javascript@1851846 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1851846

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 00803dd + 426b2e0 commit 1851846

File tree

112 files changed

+3868
-8511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+3868
-8511
lines changed

.bazelrc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
2+
3+
build:dbg --compilation_mode=dbg
4+
5+
build:opt --compilation_mode=opt
6+
7+
build:san-common --config=dbg --strip=never --copt=-O0 --copt=-fno-omit-frame-pointer
8+
9+
build:asan --config=san-common --copt=-fsanitize=address --linkopt=-fsanitize=address
10+
# ASAN hits ODR violations with shared linkage due to rules_proto.
11+
build:asan --dynamic_mode=off
12+
13+
build:msan --config=san-common --copt=-fsanitize=memory --linkopt=-fsanitize=memory
14+
build:msan --copt=-fsanitize-memory-track-origins
15+
build:msan --copt=-fsanitize-memory-use-after-dtor
16+
build:msan --action_env=MSAN_OPTIONS=poison_in_dtor=1
17+
18+
build:tsan --config=san-common --copt=-fsanitize=thread --linkopt=-fsanitize=thread
19+
20+
build:ubsan --config=san-common --copt=-fsanitize=undefined --linkopt=-fsanitize=undefined
21+
build:ubsan --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1
22+
# Workaround for the fact that Bazel links with $CC, not $CXX
23+
# https://github.com/bazelbuild/bazel/issues/11122#issuecomment-613746748
24+
build:ubsan --copt=-fno-sanitize=function --copt=-fno-sanitize=vptr
25+
26+
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
27+
# https://github.com/protocolbuffers/protobuf/issues/14313
28+
common --noenable_bzlmod
29+
30+
# Important: this flag ensures that we remain compliant with the C++ layering
31+
# check.
32+
build --features=layering_check
33+
34+
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1

.github/workflows/build.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Build, Test and Release
2+
3+
on: push
4+
5+
permissions: read-all
6+
7+
# update in build.yml and codeql.yml at same time
8+
env:
9+
PROTOC_VERSION: 28.1
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
env:
16+
PROTOC: protoc-release/bin/protoc
17+
PROTOC_INC: protoc-release/include
18+
PROTOC_PLATFORM: linux-x86_64
19+
20+
steps:
21+
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
node-version: 20
28+
cache: ${{ !env.ACT && 'npm' || '' }} # cache API not available in ACT
29+
30+
- name: Install Protoc
31+
run: |
32+
1241 echo "Fetching protoc"
33+
curl --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
34+
-L https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_PLATFORM}.zip \
35+
--output protoc-release.zip
36+
unzip protoc-release.zip -d protoc-release
37+
rm protoc-release.zip
38+
39+
- run: npm ci
40+
41+
- run: npm test
42+
43+
- run: npm run build
44+
45+
- uses: actions/upload-artifact@v4
46+
with:
47+
name: js
48+
path: |
49+
google-protobuf.js
50+
google
51+
52+
package:
53+
needs: build
54+
runs-on: ${{ matrix.os }}
55+
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
# for now I'm disabling linux building as we don't have the tooling to support it
60+
# os: [ ubuntu-latest ]
61+
# cpu:
62+
# - k8 # this build 'linux-x86_64', is currently working but not useful without the other architectures
63+
# would need some kind of CROSSTOOL chain to build the other architectures
64+
# or we'd have to use the https://github.com/uraimo/run-on-arch-action (which lacks support for x86_32) to build these
65+
# - x86_32
66+
# - systemz
67+
# - aarch64
68+
# - ppc64
69+
include:
70+
# to ensure backwards compatibility as long as possible, use earliest versions of OSs available on Github Actions
71+
- os: windows-2019
72+
cpu: x64_windows
73+
bazel_target: dist_zip
74+
- os: windows-2019
75+
cpu: x64_x86_windows
76+
bazel_target: dist_zip
77+
# disabling Mac OS releases for now since they are working through existing build process
78+
# - os: macos-11
79+
# cpu: darwin_arm64
80+
# - os: macos-11
81+
# cpu: darwin_x86_64
82+
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- uses: actions/download-artifact@v4
87+
if: ${{ !env.ACT }}
88+
with:
89+
name: js
90+
91+
- uses: bazel-contrib/setup-bazel@0.8.5
92+
with:
93+
token: ${{ secrets.GITHUB_TOKEN }}
94+
95+
- run: mkdir out
96+
97+
# setup-bazelisk fails when running in ACT because the cache is not available so we need to ignore to let the bazel step run
98+
- if: success() || env.ACT && failure()
99+
run: bazel build --cpu=${{ matrix.cpu }} ${{ matrix.bazel_target || 'dist_all' }}
100+
shell: bash
101+
102+
# need to copy to output directory as `bazel-bin` is a symlink and cannot be read by the actions/upload-artifact action
103+
- run: cp bazel-bin/protobuf-javascript-* out/
104+
105+
- uses: actions/upload-artifact@v4
106+
with:
107+
name: release-${{ matrix.os }}-${{ matrix.cpu }}
108+
path: out
109+
110+
release:
111+
needs: package
112+
if: startsWith(github.ref, 'refs/tags/')
113+
114+
runs-on: ubuntu-latest
115+
permissions:
116+
contents: write
117+
118+
steps:
119+
- uses: actions/download-artifact@v4
120+
with:
121+
name: release-${{ matrix.os }}-${{ matrix.cpu }}
122+
123+
- name: Release
124+
uses: svenstaro/upload-release-action@v2
125+
with:
126+
repo_token: ${{ secrets.GITHUB_TOKEN }}
127+
file: protobuf-javascript-*
128+
file_glob: true
129+
tag: ${{ github.ref }}
130+
overwrite: true

.github/workflows/codeql.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ name: "CodeQL"
1313

1414
permissions: read-all
1515

16+
# update in build.yml and codeql.yml at same time
17+
env:
18+
PROTOC_VERSION: 28.1
19+
1620
on:
1721
push:
1822
branches: [ "main" ]
@@ -38,34 +42,43 @@ jobs:
3842
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3943
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
4044

45+
env:
46+
PROTOC: protoc-release/bin/protoc
47+
PROTOC_INC: protoc-release/include
48+
PROTOC_PLATFORM: linux-x86_64
49+
4150
steps:
4251
- name: Checkout repository
43-
uses: actions/checkout@v3
52+
uses: actions/checkout@v4
4453

4554
# Initializes the CodeQL tools for scanning.
4655
- name: Initialize CodeQL
47-
uses: github/codeql-action/init@v2
56+
uses: github/codeql-action/init@v3
4857
with:
4958
languages: ${{ matrix.language }}
5059
# If you wish to specify custom queries, you can do so here or in a config file.
5160
# By default, queries listed here will override any specified in a config file.
5261
# Prefix the list here with "+" to use these queries and those in the config file.
53-
62+
5463
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
5564
# queries: security-extended,security-and-quality
5665

5766

5867
# ℹ️ Command-line programs to run using the OS shell.
5968
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
6069

61-
- run: |
62-
echo "Fetch protoc"
63-
curl -L https://github.com/protocolbuffers/protobuf/releases/download/v21.3/protoc-21.3-linux-x86_64.zip --output $GITHUB_WORKSPACE/protoc-release.zip
64-
unzip $GITHUB_WORKSPACE/protoc-release.zip -d $GITHUB_WORKSPACE/protoc-release
65-
echo "Clean, install, and test protobuf-javascript"
66-
npm ci
67-
npm install
68-
PROTOC=$GITHUB_WORKSPACE/protoc-release/bin/protoc PROTOC_INC=$GITHUB_WORKSPACE/protoc-release/include npm test
70+
- name: Install Protoc
71+
run: |
72+
echo "Fetching protoc"
73+
curl --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
74+
-L https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_PLATFORM}.zip \
75+
--output protoc-release.zip
76+
unzip protoc-release.zip -d protoc-release
77+
rm protoc-release.zip
78+
79+
- run: npm ci
80+
81+
- run: npm test
6982

7083
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v2
84+
uses: github/codeql-action/analyze@v3

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.idea
2-
/node_modules/
2+
node_modules
33
commonjs_out
44
# google/protobuf
55
bazel-*

BUILD.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,29 @@ load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_files", "strip_prefix")
66
load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip")
77
load("//:protobuf_javascript_release.bzl", "package_naming")
88

9+
config_setting(
10+
name = "x64_x86_windows",
11+
values = {"cpu": "x64_x86_windows"},
12+
)
13+
14+
config_setting(
15+
name = "x64_windows",
16+
values = {"cpu": "x64_windows"},
17+
)
18+
19+
config_setting(
20+
name = "k8",
21+
values = {"cpu": "k8"},
22+
)
23+
924
package_naming(
1025
name = "protobuf_javascript_pkg_naming",
26+
platform = select({
27+
":k8": "linux-x86_64", # currently the only supported build type in Github Actions
28+
":x64_x86_windows": "win32",
29+
":x64_windows": "win64",
30+
"//conditions:default": "" # continues with current behavior when no --cpu is specified allowing existing internal builds to function
31+
})
1132
)
1233

1334
pkg_files(

MODULE.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module(name = "protobuf_javascript", version = "3.21.4")
2+
3+
bazel_dep(name = "protobuf", version = "27.1", repo_name = "com_google_protobuf")
4+
bazel_dep(name = "rules_pkg", version = "0.7.0")

0 commit comments

Comments
 (0)
0