From 89477b662e36d4e451b8794a2895ae5207658ca8 Mon Sep 17 00:00:00 2001 From: Matt Morrissette Date: Wed, 8 Mar 2023 16:31:28 -0800 Subject: [PATCH 1/4] Add windows bazel build github action --- .github/actions/setup-protoc-env/action.yml | 5 + .github/actions/setup-protoc-env/index.js | 22 ++++ .../setup-protoc-env/package-lock.json | 102 ++++++++++++++++++ .github/actions/setup-protoc-env/package.json | 19 ++++ .github/workflows/build-windows.yml | 66 ++++++++++++ .gitignore | 2 +- BUILD.bazel | 15 +++ protobuf_javascript_release.bzl | 5 + 8 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 .github/actions/setup-protoc-env/action.yml create mode 100644 .github/actions/setup-protoc-env/index.js create mode 100644 .github/actions/setup-protoc-env/package-lock.json create mode 100644 .github/actions/setup-protoc-env/package.json create mode 100644 .github/workflows/build-windows.yml diff --git a/.github/actions/setup-protoc-env/action.yml b/.github/actions/setup-protoc-env/action.yml new file mode 100644 index 0000000..04bf1d9 --- /dev/null +++ b/.github/actions/setup-protoc-env/action.yml @@ -0,0 +1,5 @@ +name: 'Setup the protoc environment' +description: 'Setup the protoc environment with the right PROTOC and PROTOC_INC environment variables' +runs: + using: 'node16' + main: 'index.js' diff --git a/.github/actions/setup-protoc-env/index.js b/.github/actions/setup-protoc-env/index.js new file mode 100644 index 0000000..b0e5a49 --- /dev/null +++ b/.github/actions/setup-protoc-env/index.js @@ -0,0 +1,22 @@ +const tc = require('@actions/tool-cache'); +const core = require('@actions/core'); +const os = require('os'); +const path = require('path'); + +const versions = tc.findAllVersions('protoc'); +if (versions.length === 0) + throw new Error('Unable to find protoc tool version'); + +const version = versions[0]; +const toolPath = tc.find('protoc', version).replaceAll(path.win32.sep, path.posix.sep); +const protocExec = os.platform() === 'win32' ? 'protoc.exe' : 'protoc'; + +// need to use posix paths +const protocPath = path.posix.join(toolPath, 'bin', protocExec); +const protocIncPath = path.posix.join(toolPath, 'include'); + +console.log("protoc path:", protocPath); +console.log("protoc include path:", protocIncPath); + +core.exportVariable('PROTOC', protocPath); +core.exportVariable('PROTOC_INC', protocIncPath); diff --git a/.github/actions/setup-protoc-env/package-lock.json b/.github/actions/setup-protoc-env/package-lock.json new file mode 100644 index 0000000..63e713b --- /dev/null +++ b/.github/actions/setup-protoc-env/package-lock.json @@ -0,0 +1,102 @@ +{ + "name": "setup-protoc-env", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "setup-protoc-env", + "version": "1.0.0", + "license": "BSD-3-Clause", + "dependencies": { + "@actions/core": "^1.10.0", + "@actions/tool-cache": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^16.18.14" + } + }, + "node_modules/@actions/core": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", + "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", + "dependencies": { + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" + } + }, + "node_modules/@actions/exec": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", + "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", + "dependencies": { + "@actions/io": "^1.0.1" + } + }, + "node_modules/@actions/http-client": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz", + "integrity": "sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==", + "dependencies": { + "tunnel": "^0.0.6" + } + }, + "node_modules/@actions/io": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.2.tgz", + "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw==" + }, + "node_modules/@actions/tool-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz", + "integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==", + "dependencies": { + "@actions/core": "^1.2.6", + "@actions/exec": "^1.0.0", + "@actions/http-client": "^2.0.1", + "@actions/io": "^1.1.1", + "semver": "^6.1.0", + "uuid": "^3.3.2" + } + }, + "node_modules/@actions/tool-cache/node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, + "node_modules/@types/node": { + "version": "16.18.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.14.tgz", + "integrity": "sha512-wvzClDGQXOCVNU4APPopC2KtMYukaF1MN/W3xAmslx22Z4/IF1/izDMekuyoUlwfnDHYCIZGaj7jMwnJKBTxKw==", + "dev": true + }, + "node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + } + } +} diff --git a/.github/actions/setup-protoc-env/package.json b/.github/actions/setup-protoc-env/package.json new file mode 100644 index 0000000..5e930e4 --- /dev/null +++ b/.github/actions/setup-protoc-env/package.json @@ -0,0 +1,19 @@ +{ + "name": "setup-protoc-env", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "private": true, + "license": "BSD-3-Clause", + "dependencies": { + "@actions/core": "^1.10.0", + "@actions/tool-cache": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^16.18.14" + } +} diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 0000000..a3b3674 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,66 @@ +name: Windows Build + +on: + push: + tags: [ "*" ] + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: npm + cache-dependency-path: | + package-lock.json + .github/actions/setup-protoc-env/package-lock.json + + - name: Setup Bazelisk + uses: bazelbuild/setup-bazelisk@v2 + + - name: Mount bazel cache + uses: actions/cache@v3 + with: + path: "~/.cache/bazel" + key: bazel + + - name: Install protoc + uses: arduino/setup-protoc@v1 + + - run: npm ci --omit=dev + working-directory: .github/actions/setup-protoc-env + + - name: Setup protoc environment + uses: ./.github/actions/setup-protoc-env + + - run: npm ci + + - run: npm run build + shell: bash + + - name: Package (x64) + run: bazel build --cpu=x64_windows dist_zip + shell: bash + + - name: Copy (x64) + run: | + mkdir out + cp bazel-bin/protobuf-javascript-*.zip out/ + + - name: Package (x86) + run: bazel build --cpu=x64_x86_windows dist_zip + shell: bash + + - name: Copy (x86) + run: | + cp bazel-bin/protobuf-javascript-*.zip out/ + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: "out/*.zip" diff --git a/.gitignore b/.gitignore index 99c6e65..a1690e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .idea -/node_modules/ +node_modules commonjs_out google/protobuf bazel-* diff --git a/BUILD.bazel b/BUILD.bazel index 5483303..22963e7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -6,8 +6,23 @@ load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_files", "strip_prefix") load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip") load("//:protobuf_javascript_release.bzl", "package_naming") +config_setting( + name = "x64_x86_windows", + values = {"cpu": "x64_x86_windows"}, +) + +config_setting( + name = "x64_windows", + values = {"cpu": "x64_windows"}, +) + package_naming( name = "protobuf_javascript_pkg_naming", + platform = select({ + ":x64_x86_windows": "win32", + ":x64_windows": "win64", + "//conditions:default": "" + }) ) pkg_files( diff --git a/protobuf_javascript_release.bzl b/protobuf_javascript_release.bzl index 48a0cec..0092a10 100644 --- a/protobuf_javascript_release.bzl +++ b/protobuf_javascript_release.bzl @@ -10,6 +10,10 @@ def _package_naming_impl(ctx): values = {} values["version"] = _PROTOBUF_JAVASCRIPT_VERSION + if ctx.attr.platform != "": + values["platform"] = ctx.attr.platform + return PackageVariablesInfo(values=values) + # infer from the current cpp toolchain. toolchain = find_cpp_toolchain(ctx) cpu = toolchain.cpu @@ -46,6 +50,7 @@ package_naming = rule( "_cc_toolchain": attr.label( default=Label("@bazel_tools//tools/cpp:current_cc_toolchain"),), + "platform": attr.string(), }, toolchains=["@bazel_tools//tools/cpp:toolchain_type"], incompatible_use_toolchain_transition=True, From aac6cdfa45367327f7a8e1655123ed8465575831 Mon Sep 17 00:00:00 2001 From: Matt Vance Date: Thu, 9 Mar 2023 09:02:29 -0800 Subject: [PATCH 2/4] Refactor window-build to support all cpus --- .github/workflows/build-windows.yml | 66 -------------- .github/workflows/build.yml | 128 ++++++++++++++++++++++++++++ BUILD.bazel | 6 ++ 3 files changed, 134 insertions(+), 66 deletions(-) delete mode 100644 .github/workflows/build-windows.yml create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml deleted file mode 100644 index a3b3674..0000000 --- a/.github/workflows/build-windows.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Windows Build - -on: - push: - tags: [ "*" ] - -jobs: - build: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup NodeJS - uses: actions/setup-node@v3 - with: - node-version: 16 - cache: npm - cache-dependency-path: | - package-lock.json - .github/actions/setup-protoc-env/package-lock.json - - - name: Setup Bazelisk - uses: bazelbuild/setup-bazelisk@v2 - - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "~/.cache/bazel" - key: bazel - - - name: Install protoc - uses: arduino/setup-protoc@v1 - - - run: npm ci --omit=dev - working-directory: .github/actions/setup-protoc-env - - - name: Setup protoc environment - uses: ./.github/actions/setup-protoc-env - - - run: npm ci - - - run: npm run build - shell: bash - - - name: Package (x64) - run: bazel build --cpu=x64_windows dist_zip - shell: bash - - - name: Copy (x64) - run: | - mkdir out - cp bazel-bin/protobuf-javascript-*.zip out/ - - - name: Package (x86) - run: bazel build --cpu=x64_x86_windows dist_zip - shell: bash - - - name: Copy (x86) - run: | - cp bazel-bin/protobuf-javascript-*.zip out/ - - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: "out/*.zip" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..15a29d5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,128 @@ +name: Build, Test and Release + +on: push + +permissions: read-all + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + node-version: 16 + cache: ${{ !env.ACT && 'npm' || '' }} # cache API not available in ACT + cache-dependency-path: | + package-lock.json + .github/actions/setup-protoc-env/package-lock.json + + - uses: arduino/setup-protoc@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - run: npm ci --omit=dev + working-directory: .github/actions/setup-protoc-env + + - name: Setup protoc environment + uses: ./.github/actions/setup-protoc-env + + - uses: bazelbuild/setup-bazelisk@v2 + if: ${{ !env.ACT }} # cache API not available in ACT + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - run: npm ci + + - run: npm run test + + - run: npm run build + + - uses: actions/upload-artifact@v3 + with: + name: js + path: | + google-protobuf.js + google + + package: + needs: build + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + cpu: + - k8 + # would need some kind of CROSSTOOL chain to build the other architectures + # or we'd have to use the https://github.com/uraimo/run-on-arch-action (which lacks support for x86_32) to build these +# - x86_32 +# - systemz +# - aarch64 +# - ppc64 + include: + # to ensure backwards compatibility as long as possible, use earliest versions of OS available on Github Actions + - os: windows-2019 + cpu: x64_windows + bazel_target: dist_zip + - os: windows-2019 + cpu: x64_x86_windows + bazel_target: dist_zip + - os: macos-11 + cpu: darwin_arm64 + - os: macos-11 + cpu: darwin_x86_64 + + steps: + - uses: actions/checkout@v3 + + - uses: actions/download-artifact@v3 + if: ${{ !env.ACT }} + with: + name: js + + - uses: bazelbuild/setup-bazelisk@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - run: mkdir out + + # setup-bazelisk fails when running in ACT because the cache is not available so we need to ignore to let the bazel step run + - if: success() || env.ACT && failure() + run: bazel build --cpu=${{ matrix.cpu }} ${{ matrix.bazel_target || 'dist_all' }} + shell: bash + + # need to copy to output directory as `bazel-bin` is a symlink and cannot be read by the actions/upload-artifact action + - run: cp bazel-bin/protobuf-javascript-* out/ + + - uses: actions/upload-artifact@v3 + with: + name: releases + path: out + + release: + needs: package + if: startsWith(github.ref, 'refs/tags/') + + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/download-artifact@v3 + with: + name: releases + + - name: Release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: protobuf-javascript-* + file_glob: true + tag: ${{ github.ref }} + overwrite: true diff --git a/BUILD.bazel b/BUILD.bazel index 22963e7..bd68621 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -16,9 +16,15 @@ config_setting( values = {"cpu": "x64_windows"}, ) +config_setting( + name = "k8", + values = {"cpu": "k8"}, +) + package_naming( name = "protobuf_javascript_pkg_naming", platform = select({ + ":k8": "linux-x86_64", # currently the only supported build type in Github Actions ":x64_x86_windows": "win32", ":x64_windows": "win64", "//conditions:default": "" From 678e441781ffbb7f74645fcf9f02b31a22e54bcf Mon Sep 17 00:00:00 2001 From: Matt Vance Date: Thu, 9 Mar 2023 14:28:56 -0800 Subject: [PATCH 3/4] Disable linux and mac OS builds as they continue to function in existing build system --- .github/workflows/build.yml | 22 ++++++++++++---------- BUILD.bazel | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 15a29d5..c1ddf72 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,27 +56,29 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest ] - cpu: - - k8 - # would need some kind of CROSSTOOL chain to build the other architectures - # or we'd have to use the https://github.com/uraimo/run-on-arch-action (which lacks support for x86_32) to build these +# for now I'm disabling linux building as we don't have the tooling to support it +# os: [ ubuntu-latest ] +# cpu: +# - k8 # this build 'linux-x86_64', is currently working but not useful without the other architectures +# would need some kind of CROSSTOOL chain to build the other architectures +# or we'd have to use the https://github.com/uraimo/run-on-arch-action (which lacks support for x86_32) to build these # - x86_32 # - systemz # - aarch64 # - ppc64 include: - # to ensure backwards compatibility as long as possible, use earliest versions of OS available on Github Actions +# to ensure backwards compatibility as long as possible, use earliest versions of OSs available on Github Actions - os: windows-2019 cpu: x64_windows bazel_target: dist_zip - os: windows-2019 cpu: x64_x86_windows bazel_target: dist_zip - - os: macos-11 - cpu: darwin_arm64 - - os: macos-11 - cpu: darwin_x86_64 +# disabling Mac OS releases for now since they are working through existing build process +# - os: macos-11 +# cpu: darwin_arm64 +# - os: macos-11 +# cpu: darwin_x86_64 steps: - uses: actions/checkout@v3 diff --git a/BUILD.bazel b/BUILD.bazel index bd68621..0a4b73b 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -27,7 +27,7 @@ package_naming( ":k8": "linux-x86_64", # currently the only supported build type in Github Actions ":x64_x86_windows": "win32", ":x64_windows": "win64", - "//conditions:default": "" + "//conditions:default": "" # continues with current behavior when no --cpu is specified allowing existing internal builds to function }) ) From 0b722929601bd5508361a6b1a7f7ed5f307c545e Mon Sep 17 00:00:00 2001 From: Matt Vance Date: Thu, 9 Mar 2023 16:55:23 -0800 Subject: [PATCH 4/4] Updates from code review removing setup-protoc dep --- .github/actions/setup-protoc-env/action.yml | 5 - .github/actions/setup-protoc-env/index.js | 22 ---- .../setup-protoc-env/package-lock.json | 102 ------------------ .github/actions/setup-protoc-env/package.json | 19 ---- .github/workflows/build.yml | 34 +++--- .github/workflows/codeql.yml | 31 ++++-- 6 files changed, 41 insertions(+), 172 deletions(-) delete mode 100644 .github/actions/setup-protoc-env/action.yml delete mode 100644 .github/actions/setup-protoc-env/index.js delete mode 100644 .github/actions/setup-protoc-env/package-lock.json delete mode 100644 .github/actions/setup-protoc-env/package.json diff --git a/.github/actions/setup-protoc-env/action.yml b/.github/actions/setup-protoc-env/action.yml deleted file mode 100644 index 04bf1d9..0000000 --- a/.github/actions/setup-protoc-env/action.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: 'Setup the protoc environment' -description: 'Setup the protoc environment with the right PROTOC and PROTOC_INC environment variables' -runs: - using: 'node16' - main: 'index.js' diff --git a/.github/actions/setup-protoc-env/index.js b/.github/actions/setup-protoc-env/index.js deleted file mode 100644 index b0e5a49..0000000 --- a/.github/actions/setup-protoc-env/index.js +++ /dev/null @@ -1,22 +0,0 @@ -const tc = require('@actions/tool-cache'); -const core = require('@actions/core'); -const os = require('os'); -const path = require('path'); - -const versions = tc.findAllVersions('protoc'); -if (versions.length === 0) - throw new Error('Unable to find protoc tool version'); - -const version = versions[0]; -const toolPath = tc.find('protoc', version).replaceAll(path.win32.sep, path.posix.sep); -const protocExec = os.platform() === 'win32' ? 'protoc.exe' : 'protoc'; - -// need to use posix paths -const protocPath = path.posix.join(toolPath, 'bin', protocExec); -const protocIncPath = path.posix.join(toolPath, 'include'); - -console.log("protoc path:", protocPath); -console.log("protoc include path:", protocIncPath); - -core.exportVariable('PROTOC', protocPath); -core.exportVariable('PROTOC_INC', protocIncPath); diff --git a/.github/actions/setup-protoc-env/package-lock.json b/.github/actions/setup-protoc-env/package-lock.json deleted file mode 100644 index 63e713b..0000000 --- a/.github/actions/setup-protoc-env/package-lock.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "name": "setup-protoc-env", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "setup-protoc-env", - "version": "1.0.0", - "license": "BSD-3-Clause", - "dependencies": { - "@actions/core": "^1.10.0", - "@actions/tool-cache": "^2.0.1" - }, - "devDependencies": { - "@types/node": "^16.18.14" - } - }, - "node_modules/@actions/core": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", - "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", - "dependencies": { - "@actions/http-client": "^2.0.1", - "uuid": "^8.3.2" - } - }, - "node_modules/@actions/exec": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", - "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", - "dependencies": { - "@actions/io": "^1.0.1" - } - }, - "node_modules/@actions/http-client": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz", - "integrity": "sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==", - "dependencies": { - "tunnel": "^0.0.6" - } - }, - "node_modules/@actions/io": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.2.tgz", - "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw==" - }, - "node_modules/@actions/tool-cache": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz", - "integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==", - "dependencies": { - "@actions/core": "^1.2.6", - "@actions/exec": "^1.0.0", - "@actions/http-client": "^2.0.1", - "@actions/io": "^1.1.1", - "semver": "^6.1.0", - "uuid": "^3.3.2" - } - }, - "node_modules/@actions/tool-cache/node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", - "bin": { - "uuid": "bin/uuid" - } - }, - "node_modules/@types/node": { - "version": "16.18.14", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.14.tgz", - "integrity": "sha512-wvzClDGQXOCVNU4APPopC2KtMYukaF1MN/W3xAmslx22Z4/IF1/izDMekuyoUlwfnDHYCIZGaj7jMwnJKBTxKw==", - "dev": true - }, - "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/tunnel": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", - "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", - "engines": { - "node": ">=0.6.11 <=0.7.0 || >=0.7.3" - } - }, - "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - } - } -} diff --git a/.github/actions/setup-protoc-env/package.json b/.github/actions/setup-protoc-env/package.json deleted file mode 100644 index 5e930e4..0000000 --- a/.github/actions/setup-protoc-env/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "setup-protoc-env", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "private": true, - "license": "BSD-3-Clause", - "dependencies": { - "@actions/core": "^1.10.0", - "@actions/tool-cache": "^2.0.1" - }, - "devDependencies": { - "@types/node": "^16.18.14" - } -} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c1ddf72..5bdbbfe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,10 +4,19 @@ on: push permissions: read-all +# update in build.yml and codeql.yml at same time +env: + PROTOC_VERSION: 21.3 + jobs: build: runs-on: ubuntu-latest + env: + PROTOC: protoc-release/bin/protoc + PROTOC_INC: protoc-release/include + PROTOC_PLATFORM: linux-x86_64 + steps: - uses: actions/checkout@v3 @@ -17,28 +26,23 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} node-version: 16 cache: ${{ !env.ACT && 'npm' || '' }} # cache API not available in ACT - cache-dependency-path: | - package-lock.json - .github/actions/setup-protoc-env/package-lock.json - - - uses: arduino/setup-protoc@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - run: npm ci --omit=dev - working-directory: .github/actions/setup-protoc-env - - - name: Setup protoc environment - uses: ./.github/actions/setup-protoc-env - uses: bazelbuild/setup-bazelisk@v2 - if: ${{ !env.ACT }} # cache API not available in ACT with: token: ${{ secrets.GITHUB_TOKEN }} + - name: Install Protoc + run: | + echo "Fetching protoc" + curl --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + -L https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_PLATFORM}.zip \ + --output protoc-release.zip + unzip protoc-release.zip -d protoc-release + rm protoc-release.zip + - run: npm ci - - run: npm run test + - run: npm test - run: npm run build diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index fc44651..4b65e05 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,6 +13,10 @@ name: "CodeQL" permissions: read-all +# update in build.yml and codeql.yml at same time +env: + PROTOC_VERSION: 21.3 + on: push: branches: [ "main" ] @@ -38,6 +42,11 @@ jobs: # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + env: + PROTOC: protoc-release/bin/protoc + PROTOC_INC: protoc-release/include + PROTOC_PLATFORM: linux-x86_64 + steps: - name: Checkout repository uses: actions/checkout@v3 @@ -50,7 +59,7 @@ jobs: # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - + # 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 # queries: security-extended,security-and-quality @@ -58,14 +67,18 @@ jobs: # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - run: | - echo "Fetch protoc" - curl -L https://github.com/protocolbuffers/protobuf/releases/download/v21.3/protoc-21.3-linux-x86_64.zip --output $GITHUB_WORKSPACE/protoc-release.zip - unzip $GITHUB_WORKSPACE/protoc-release.zip -d $GITHUB_WORKSPACE/protoc-release - echo "Clean, install, and test protobuf-javascript" - npm ci - npm install - PROTOC=$GITHUB_WORKSPACE/protoc-release/bin/protoc PROTOC_INC=$GITHUB_WORKSPACE/protoc-release/include npm test + - name: Install Protoc + run: | + echo "Fetching protoc" + curl --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + -L https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_PLATFORM}.zip \ + --output protoc-release.zip + unzip protoc-release.zip -d protoc-release + rm protoc-release.zip + + - run: npm ci + + - run: npm test - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2