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
65 changes: 22 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,42 @@ on:
- main
pull_request:
jobs:
lint_test:
build-package:
name: Build Package
runs-on: ubuntu-latest
outputs:
package: ${{ steps.publish-local-package.outputs.package }}
steps:
- uses: tatethurston/github-actions/publish-local-package@main
id: publish-local-package
with:
path: packages/protoscript
ci:
name: Lint and Test
runs-on: ubuntu-latest
steps:
# Install protoc for e2e:setup
- uses: arduino/setup-protoc@v2
with:
version: "23.4"
- uses: bufbuild/buf-setup-action@v1.25.0
version: "29.2"
- uses: tatethurston/github-actions/test@main
with:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
- name: Check for uncommited changes to generated files
run: |
pnpm regen
if git diff --quiet; then
echo "No changes detected."
else
echo "Changes detected:"
git diff --name-only
git diff
echo "Failing build."
exit 1
fi
build_package:
name: Build Package
runs-on: ubuntu-latest
outputs:
package-name: package-${{ github.event.pull_request.number }}
steps:
- uses: tatethurston/github-actions/build@main
- name: NPM Pack
run: |
cd packages/protoscript
pnpm pack
mv *.tgz protoscript.tgz
- uses: actions/upload-artifact@v4
- uses: bufbuild/buf-setup-action@v1.25.0
- uses: tatethurston/github-actions/check-generated-files@main
with:
name: package-${{ github.event.pull_request.number }}
path: packages/protoscript/*.tgz
if-no-files-found: error
retention-days: 1
overwrite: true
check_windows:
name: Windows CI Check
cmd: pnpm regen
ci-windows:
name: Windows CI
runs-on: windows-latest
needs: build_package
needs: build-package
steps:
- uses: arduino/setup-protoc@v2
- uses: tatethurston/github-actions/install-local-package@main
with:
version: "23.4"
- uses: actions/download-artifact@v4
name: ${{ needs.build-package.outputs.package }}
- uses: arduino/setup-protoc@v2
with:
name: ${{ needs.build_package.outputs.package-name }}
- uses: actions/setup-node@v3
version: "29.2"
- name: Bin Check
run: |
npm install protoscript.tgz
touch dummy.proto
npx --no protoscript
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
types: [published]
workflow_dispatch:
jobs:
build:
publish:
runs-on: ubuntu-latest
steps:
- uses: tatethurston/github-actions/publish@main
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ coverage
node_modules
todo.txt
packages/well-known-types/**/*.pb.ts
packages/protoscript/LICENSE
packages/protoscript/README.md
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

(cd packages/protoscript && pnpm run package:build)
pnpm run regen
pnpm run lint:fix
pnpm run typecheck
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.0.22

- Fix Timestamp and Duration JSON serialization. Previously, when either seconds or nanos were 0, the Timestamp / Duration was omitted from the serialized json. Thanks @martynchamberlin!

## v0.0.21

- Fix compiler path on Windows.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4573,17 +4573,15 @@ export const TestAllTypesProto3JSON = {
}
if (
msg.optionalDuration &&
msg.optionalDuration.seconds &&
msg.optionalDuration.nanos
(msg.optionalDuration.seconds || msg.optionalDuration.nanos)
) {
json["optionalDuration"] = protoscript.serializeDuration(
msg.optionalDuration,
);
}
if (
msg.optionalTimestamp &&
msg.optionalTimestamp.seconds &&
msg.optionalTimestamp.nanos
(msg.optionalTimestamp.seconds || msg.optionalTimestamp.nanos)
) {
json["optionalTimestamp"] = protoscript.serializeTimestamp(
msg.optionalTimestamp,
Expand Down
6 changes: 2 additions & 4 deletions e2e/serialization/json.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,17 +1042,15 @@ export const SampleMessageJSON = {
}
if (
msg.sampleTimestamp &&
msg.sampleTimestamp.seconds &&
msg.sampleTimestamp.nanos
(msg.sampleTimestamp.seconds || msg.sampleTimestamp.nanos)
) {
json["sampleTimestamp"] = protoscript.serializeTimestamp(
msg.sampleTimestamp,
);
}
if (
msg.sampleDuration &&
msg.sampleDuration.seconds &&
msg.sampleDuration.nanos
(msg.sampleDuration.seconds || msg.sampleDuration.nanos)
) {
json["sampleDuration"] = protoscript.serializeDuration(
msg.sampleDuration,
Expand Down
3 changes: 1 addition & 2 deletions e2e/treeshaking/treeshaking.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ export const TreeshakingTestJSON = {
}
if (
msg.timestampField &&
msg.timestampField.seconds &&
msg.timestampField.nanos
(msg.timestampField.seconds || msg.timestampField.nanos)
) {
json["timestampField"] = protoscript.serializeTimestamp(
msg.timestampField,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"lint:fix": "prettier --write . && prettier-package-json --write '{,e2e/*,examples/*,packages/*}package.json' && eslint --fix .",
"package:copy:files": "cp ./LICENSE ./README.md packages/protoscript",
"prepare": "husky install",
"regen": "pnpm build:wellknowntypes && pnpm examples:regen && pnpm e2e:protoscript",
"regen": "pnpm examples:regen && pnpm e2e:protoscript && pnpm build:wellknowntypes",
"test": "jest",
"test:ci": "pnpm install --frozen-lockfile && pnpm run e2e:setup && pnpm run test --coverage",
"typecheck": "pnpm --recursive run typecheck"
Expand Down
2 changes: 1 addition & 1 deletion packages/protoscript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "protoscript",
"version": "0.0.21",
"version": "0.0.22",
"description": "A Protobuf runtime and code generation tool for JavaScript and TypeScript",
"license": "MIT",
"author": "Tate <tatethurston@gmail.com>",
Expand Down
2 changes: 1 addition & 1 deletion packages/protoscript/src/codegen/autogenerate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ function writeJSONSerializers(types: ProtoTypes[], parents: string[]): string {
} else if (field.read === "readEnum") {
res += `if (msg.${field.name} && ${field.tsTypeJSON}._toInt(msg.${field.name})) {`;
} else if ([DURATION, TIMESTAMP].includes(field.tsType)) {
res += `if (msg.${field.name} && msg.${field.name}.seconds && msg.${field.name}.nanos) {`;
res += `if (msg.${field.name} && (msg.${field.name}.seconds || msg.${field.name}.nanos)) {`;
} else {
res += `if (msg.${field.name}) {`;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/protoscript/src/runtime/well-known-types/any.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ export interface Any {
*
* Note: this functionality is not currently available in the official
* protobuf release, and it is not used for type URLs beginning with
* type.googleapis.com.
* type.googleapis.com. As of May 2023, there are no widely used type server
* implementations and no plans to implement one.
*
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export interface Method {
* The mixin construct implies that all methods in `AccessControl` are
* also declared with same name and request/response types in
* `Storage`. A documentation generator or annotation processor will
* see the effective `Storage.GetAcl` method after inherting
* see the effective `Storage.GetAcl` method after inheriting
* documentation and annotations as follows:
*
* service Storage {
Expand Down
Loading