Skip to content

Commit

Permalink
Partially improve TypeScript compatibility tests
Browse files Browse the repository at this point in the history
This partially gets us to the goals defined in #581. We do not remove the dependency on `@types/node` yet, but we make sure to use the corresponding version for every version of TypeScript we test with.

To speed up GitHub actions, the compatibility tests are moved to a separate job that runs in parallel.
  • Loading branch information
timostamm committed Oct 25, 2023
1 parent 48dddbd commit 56ead37
Show file tree
Hide file tree
Showing 36 changed files with 593 additions and 293 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ module.exports = {
node: true,
},
ignorePatterns: [
"packages/typescript-compat/*/dist/**",
"packages/*/dist/**",
"packages/*/.tmp/**",
"node_modules/**",
],
plugins: ["@typescript-eslint", "node", "import"],
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: bufbuild/[email protected]
with:
github_token: ${{ github.token }}
- name: Cache
uses: actions/cache@v3
with:
Expand All @@ -25,4 +22,20 @@ jobs:
restore-keys: |
${{ runner.os }}-protobuf-es-ci-
- name: make
run: make all checkdiff
run: make ci
typescript-compat:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.tmp
.tmp
key: ${{ runner.os }}-protobuf-es-typescript-compat-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-protobuf-es-typescript-compat-
- name: make
run: make test-ts-compat
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
/packages/*/dist
/packages/typescript-compat/*/dist
/packages/protobuf-test/descriptorset.bin
/packages/protoplugin-test/descriptorset.bin
/.tmp
Expand Down
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ $(BUILD)/protobuf-conformance: $(GEN)/protobuf-conformance node_modules tsconfig
@touch $(@)

$(BUILD)/protobuf-example: $(BUILD)/protobuf node_modules tsconfig.base.json packages/protobuf-example/tsconfig.json $(shell find packages/protobuf-example/src -name '*.ts')
npm run -w packages/protobuf-example clean
npm run -w packages/protobuf-example build
@mkdir -p $(@D)
@touch $(@)
Expand Down Expand Up @@ -101,6 +100,10 @@ help: ## Describe useful make targets
.PHONY: all
all: build test format lint bench bootstrapwkt ## build, test, format, lint, bench, and bootstrapwkt (default)

.PHONY: ci
ci: build test-protobuf test-protoplugin test-conformance format lint bench bootstrapwkt #
$(MAKE) checkdiff

.PHONY: clean
clean: ## Delete build artifacts and installed dependencies
@# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs
Expand Down Expand Up @@ -129,13 +132,8 @@ test-conformance: $(BUILD)/upstream-protobuf $(BUILD)/protobuf-conformance
npm run -w packages/protobuf-conformance test

.PHONY: test-ts-compat
test-ts-compat: $(GEN)/protobuf-test node_modules
@for number in $(TS_VERSIONS) ; do \
formatted=$$(echo "$${number}" | sed -r 's/[\.]/_/g'); \
dirname=packages/protobuf-test ; \
echo "Testing TypeScript `node_modules/ts$$formatted/bin/tsc --version`" ; \
node_modules/ts$$formatted/bin/tsc -p $$dirname/typescript/tsconfig.$${formatted}.json --outDir $$dirname/dist/typescript/$$formatted || exit ; \
done
test-ts-compat: $(GEN)/protobuf-test $(BUILD)/protobuf node_modules
node packages/typescript-compat/typescript-compat.mjs

.PHONY: lint
lint: node_modules $(BUILD)/protobuf $(BUILD)/protobuf-test $(BUILD)/protobuf-conformance $(BUILD)/protoplugin $(GEN)/protobuf-bench $(GEN)/protobuf-example ## Lint all files
Expand Down
Loading

0 comments on commit 56ead37

Please sign in to comment.