Skip to content

Commit

Permalink
feat(metagen): client_py (#802)
Browse files Browse the repository at this point in the history
- Implements `client_py` as described in #777

This is a stacked PR on top of #790.

#### Migration notes

...

- [ ] The change comes with new or modified tests
- [ ] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change

---------

Co-authored-by: Teo Stocco <[email protected]>
Co-authored-by: Estifanos Bireda <[email protected]>
Co-authored-by: FITAHIANA Nomeniavo joe <[email protected]>
  • Loading branch information
4 people authored Aug 7, 2024
1 parent 13e972c commit 9cfa939
Show file tree
Hide file tree
Showing 148 changed files with 7,894 additions and 5,284 deletions.
158 changes: 156 additions & 2 deletions .ghjk/deno.lock

Large diffs are not rendered by default.

1,008 changes: 650 additions & 358 deletions .ghjk/lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/dev
DOCKER_BUILD_NO_SUMMARY: true

jobs:
builder:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
- main

env:
GHJK_VERSION: "0.2.0"
GHJK_VERSION: "b702292"

jobs:
changes:
Expand Down
54 changes: 30 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ on:
- v*

env:
GHJK_VERSION: "0.2.0"
GHJK_VERSION: "b702292"
GHJK_ENV: "ci"
REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/typegate
DOCKER_BUILD_NO_SUMMARY: true

jobs:
check-bump:
Expand Down Expand Up @@ -71,36 +72,41 @@ jobs:
- os: macos-13
target: x86_64-apple-darwin
suffix: ""
cross: false
- os: macos-14
target: aarch64-apple-darwin
suffix: ""
cross: false
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ""
cross: false
# FIXME: deno doesn't support musl today https://github.com/denoland/deno/issues/3711
# - os: ubuntu-latest
# target: x86_64-unknown-linux-musl
# suffix: ""
# cross: false
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
suffix: ""
cross: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# some targets don't use cross so will require the deps in the host
- uses: metatypedev/setup-ghjk@318209a9d215f70716a4ac89dbeb9653a2deb8bc
- uses: WyriHaximus/[email protected]
id: latest-tag
- uses: dsherret/rust-toolchain-file@v1
with:
targets: ${{ matrix.target }}
# some targets don't use cross so will require the deps in the host
- uses: metatypedev/setup-ghjk@318209a9d215f70716a4ac89dbeb9653a2deb8bc
- uses: mozilla-actions/[email protected]
- run: |
# sometimes, dtolnay/rust-toolchain does not select the correct default target
rustup target add ${{ matrix.target }}
# we use cross for building on this platform
- if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
- if: ${{ matrix.cross }}
shell: bash
env:
# arguments for our custom cross.Dockerfile
Expand All @@ -110,16 +116,16 @@ jobs:
cargo install cross
# NOTE: we only build the thin cli
cross build --release --locked --package meta-cli --target ${{ matrix.target }}
cross build --release --locked --package meta-cli --target ${{ matrix.target }} --verbose
# we cd next to the file so that the its parent dirs
# aren't present in the tar
cd target/${{ matrix.target }}/release/
tar czvf ../../../meta-cli-thin-${{ steps.latest-tag.outputs.tag }}-${{ matrix.target }}.tar.gz "meta${{ matrix.suffix }}"
cd ../../../
- if: ${{ matrix.target != 'aarch64-unknown-linux-gnu' }}
- if: ${{ matrix.cross != true }}
shell: bash
run: |
cargo build --release --locked --package meta-cli --target ${{ matrix.target }} --features typegate -v
cargo build --release --locked --package meta-cli --target ${{ matrix.target }} --features typegate --verbose
cd target/${{ matrix.target }}/release/
tar czvf ../../../meta-cli-${{ steps.latest-tag.outputs.tag }}-${{ matrix.target }}.tar.gz "meta${{ matrix.suffix }}"
cd ../../../
Expand All @@ -129,7 +135,7 @@ jobs:
tar czvf ../../../meta-cli-thin-${{ steps.latest-tag.outputs.tag }}-${{ matrix.target }}.tar.gz "meta${{ matrix.suffix }}"
cd ../../../
# fat meta-cli is not avail for arm64 linux (waiting on arm64 linux machines for Gh CI)
- if: ${{ matrix.target != 'aarch64-unknown-linux-gnu' }}
- if: ${{ matrix.cross != true }}
uses: svenstaro/upload-release-action@v2
with:
tag: ${{ steps.latest-tag.outputs.tag }}
Expand All @@ -153,6 +159,9 @@ jobs:
|| github.event_name == 'workflow_dispatch'
)
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # The OIDC ID token is used for authentication with JSR.
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -167,37 +176,34 @@ jobs:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
WASM_FILE: target/release/typegraph_core.wasm
OVERWRITE: ${{ github.event_name == 'workflow_dispatch' && inputs.ovewriteArtifacts }}
run: |
ghjk x install-py
ghjk x install-ts
ghjk x install-py
source .venv/bin/activate
WASM_OPT=1 ghjk x build-tgraph
cd typegraph/python
poetry build
[ ${{ github.event_name == 'workflow_dispatch' && inputs.ovewriteArtifacts }} == 'true' ] \
[ "$OVERWRITE" == 'true' ] \
&& poetry publish --skip-existing \
|| poetry publish
cd ../..
cd -
cd typegraph/node
pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
[ ${{ github.event_name == 'workflow_dispatch' && inputs.ovewriteArtifacts }} == 'true' ] \
&& (pnpm publish --no-git-checks || true) \
[ "$OVERWRITE" == 'true' ] \
&& (pnpm publish --no-git-checks --force || true) \
|| pnpm publish --no-git-checks
cd ../..
cd -
cd typegraph/deno/sdk
ghjk x build-jsr-pub
# Requires auth
# jsr requires explicit type hints everytime (almost no inferences)
# - https://jsr.io/docs/about-slow-types#explicit-types
# - https://jsr.io/docs/about-slow-types#simple-inference
# deno publish --dry-run --allow-slow-types --allow-dirty
ghjk x build-tgraph-ts-jsr
[ "$OVERWRITE" == 'true' ] \
&& (deno publish --allow-slow-types --allow-dirty || true) \
|| deno publish --allow-slow-types --allow-dirty
cd -
- uses: svenstaro/upload-release-action@v2
with:
Expand Down Expand Up @@ -336,7 +342,7 @@ jobs:
- uses: kenji-miyake/setup-git-cliff@v2
- id: bump
run: |
ghjk x verison-bump prerelease
ghjk x version-bump prerelease
echo "version=$(ghjk x version-print)" >> $GITHUB_OUTPUT
git cliff --output CHANGELOG.md
- uses: peter-evans/create-pull-request@v6
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- ready_for_review

env:
GHJK_VERSION: "0.2.0"
GHJK_VERSION: "b702292"
GHJK_ENV: "ci"
RUST_BACKTRACE: "full"
DENO_DIR: deno-dir
Expand All @@ -31,6 +31,7 @@ env:
# used by ghjk
# TODO: add logic to setup-ghjk
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_BUILD_NO_SUMMARY: true

jobs:
changes:
Expand Down Expand Up @@ -291,8 +292,7 @@ jobs:
typegate/tests/e2e/self_deploy/self_deploy.ts \
typegate/tests/metagen/typegraphs/metagen.ts \
typegraph/deno/sdk/src/*.ts \
dev/deps.ts \
dev/utils.ts
dev/*.ts
deno --unstable-worker-options --unstable-net coverage ./coverage --lcov > coverage.lcov
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ repos:
- id: deno-fmt
name: Deno format
language: system
entry: bash -c 'cd typegate && deno fmt --ignore=native,src/typegraphs,tmp,tests/e2e/nextjs && cd ../dev && deno fmt && cd ../typegraph/deno && deno fmt --ignore=node_modules,dist'
entry: bash -c 'cd typegate && deno fmt --ignore=native,src/typegraphs,tmp,tests/e2e/nextjs && cd ../dev && deno fmt && cd ../typegraph/deno && deno fmt --ignore=node_modules,dist && cd ../../libs/metagen/src && deno fmt'
pass_filenames: false
types:
- ts
files: ^(typegate|dev|typegraph/deno)/
- id: deno-lint
name: Deno lint
language: system
entry: bash -c 'cd typegate && deno lint --rules-exclude=no-explicit-any --ignore=native,tmp,tests/e2e/nextjs && cd ../dev && deno lint'
entry: bash -c 'cd typegate && deno lint --rules-exclude=no-explicit-any --ignore=native,tmp,tests/e2e/nextjs && cd ../dev && deno lint && cd ../libs/metagen/src/ && deno lint'
pass_filenames: false
types:
- ts
Expand Down
28 changes: 17 additions & 11 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
"website/.docusaurus": true,
"website/node_modules": true
},
"deno.enablePaths": [
"typegate",
"dev",
"examples/templates/deno",
"examples/typegraphs",
"typegraph/deno/dev",
"typegraph/deno/sdk",
"libs/metagen",
"ghjk.ts",
".ghjk"
"deno.disablePaths": [
"meta-lsp",
"typegraph/node",
"examples/templates/node",
"website"
],
"deno.importMap": "typegate/import_map.json",
// "deno.enablePaths": [
// "typegate",
// "dev",
// "examples/templates/deno",
// "examples/typegraphs",
// "typegraph/deno/dev",
// "typegraph/deno/sdk",
// "libs/metagen",
// "ghjk.ts",
// ".ghjk"
// ],
// "deno.config": "typegate/deno.jsonc",
"deno.unstable": true,
"typescript.suggest.completeFunctionCalls": true,
"typescript.inlayHints.variableTypes.enabled": true,
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ You can install it using the following instructions.

```bash
# install ghjk
GHJK_VERSION="0.2.0"
GHJK_VERSION="b702292"
GHJK_INSTALL_HOOK_SHELLS=bash # add more shells if needed
curl -fsSL https://raw.githubusercontent.com/metatypedev/ghjk/$GHJK_VERSION/install.sh | sh
bash # re-open your shells to have the hooks register
Expand Down
Loading

0 comments on commit 9cfa939

Please sign in to comment.