Skip to content

feat(meta-test): update t.engine() impl (#716) #3259

feat(meta-test): update t.engine() impl (#716)

feat(meta-test): update t.engine() impl (#716) #3259

Workflow file for this run

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- ready_for_review
env:
GHJK_VERSION: "2725af8"
DENO_VERSION: "1.41.0"
RUST_BACKTRACE: "full"
RUST_LOG: "info,swc_ecma_codegen=off,tracing::span=off"
DENO_DIR: deno-dir
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
website:
- '.github/workflows/tests.yml'
- 'website/**'
meta-cli:
- '.github/workflows/tests.yml'
- 'libs/**'
- 'meta-cli/**'
- 'Cargo.lock'
typegate: # for the standalone/image (not typegate tests which rely on everything)
- '.github/workflows/tests.yml'
- 'libs/**'
- 'typegate/**' # consider moving tests to other dir to improve test detection
- 'Cargo.lock'
full:
- '.github/workflows/tests.yml'
- 'libs/**'
- 'typegate/**'
- 'typegraph/**'
- 'meta-cli/**'
- 'Cargo.lock'
- 'examples/**'
rust:
- '.github/workflows/tests.yml'
- 'libs/**'
- 'Cargo.lock'
outputs:
website: ${{ steps.filter.outputs.website }}
meta-cli: ${{ steps.filter.outputs.meta-cli }}
typegate: ${{ steps.filter.outputs.typegate }}
full: ${{ steps.filter.outputs.full }}
rust: ${{ steps.filter.outputs.rust }}
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
# use custom shared key to share cache across jobs
# default prefix includes job-id otherwise
shared-key: ${{ runner.os }}-rust-${{ hashFiles('**/rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- uses: metatypedev/setup-ghjk@2e8bbf084060a18828338a7cdd43fde6feb2a3cc
- shell: bash
run: |
sudo apt update
sudo apt install -y --no-install-recommends libclang-dev clang
pnpm -C website install --frozen-lockfile
pnpm -C meta-lsp install --frozen-lockfile --recursive
pnpm -C typegraph/node install --frozen-lockfile --recursive
deno cache --import-map typegate/import_map.json typegate/src/main.ts typegate/tests/utils/mod.ts
pre-commit run --show-diff-on-failure --color=always --all-files
lint-compat:
needs: changes
if: ${{ needs.changes.outputs.full == 'true' }}
runs-on: "${{ matrix.os }}"
strategy:
matrix:
include:
- os: macos-13
target: x86_64-apple-darwin
cross: false
- os: macos-14
target: aarch64-apple-darwin
cross: false
# FIXME: linux/arm64 needs arm runners
# this target doesn't have a meta-cli build anyways
# the typegate is covered by the docker build down below
# - os: custom-macos
# target: aarch64-unknown-linux-gnu
# cross: true
#- os: windows-latest
# activate: '.venv\Scripts\activate.bat'
steps:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- uses: metatypedev/setup-ghjk@2e8bbf084060a18828338a7cdd43fde6feb2a3cc
with:
# temporary fix
cache-key-prefix: ${{ matrix.os }}
- if: ${{ matrix.cross }}
shell: bash
env:
# arguments for our custom cross.Dockerfile
CROSS_BUILD_OPTS: "--build-arg 'CROSS_TARGET=${{ matrix.target }}'"
run: |
cross check --locked --all-features --all-targets --target ${{ matrix.target }}
- if: ${{ matrix.cross != true }}
shell: bash
env:
WASM_FILE: target/debug/typegraph_core.wasm
run: |
cargo check --locked --all-features --all-targets --target ${{ matrix.target }}
test-website:
needs: changes
if: ${{ needs.changes.outputs.website == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
# - name: Cache deno dir
# uses: actions/cache@v4
# with:
# path: ${{ env.DENO_DIR }}
# key: deno-mac-${{ hashFiles('**/deno.lock') }}
- uses: metatypedev/setup-ghjk@2e8bbf084060a18828338a7cdd43fde6feb2a3cc
- name: Cache .venv dir
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock', '.ghjk/lock.json') }}
- shell: bash
run: |
python3 -m venv .venv
source .venv/bin/activate
poetry install --no-root
cd website
pnpm install --frozen-lockfile
pnpm lint
pnpm build
bulid-docker:
needs: changes
if: ${{ needs.changes.outputs.typegate == 'true' }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: custom-ubuntu-large
- platform: linux/arm64
# FIXME: official darwin images don't have docker
# and nested virtualizaiton
runner: custom-macos
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: scherermichael-oss/action-has-permission@master
id: check
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
if: steps.check.outputs.has-permission
with:
registry: docker.io
username: zifeo
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build with cache (internal)
uses: docker/build-push-action@v5
if: steps.check.outputs.has-permission
with:
file: dev/Dockerfile
platforms: ${{ matrix.platform }}
push: false
cache-from: type=registry,ref=docker.io/zifeo/metatype-cache:ci
cache-to: type=registry,ref=docker.io/zifeo/metatype-cache:ci,mode=max
# check target runs extra validation steps in the Dockerfile
target: check
build-args: 'CARGO_PROFILE=dev'
- name: Build without cache (external)
uses: docker/build-push-action@v5
if: "! steps.check.outputs.has-permission"
with:
file: dev/Dockerfile
platforms: ${{ matrix.platform }}
push: false
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/typegate:latest
build-args: 'CARGO_PROFILE=dev'
target: check
test-full:
needs: changes
if: ${{ needs.changes.outputs.full == 'true' }}
runs-on:
- self-hosted # https://check-jsonschema.readthedocs.io/en/latest/faq.html#using-self-hosted-runners
- custom-ubuntu-large
timeout-minutes: 80
steps:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-rust-${{ hashFiles('**/rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
# - name: Cache deno dir
# uses: actions/cache@v4
# with:
# path: ${{ env.DENO_DIR }}
# key: deno-${{ hashFiles('**/deno.lock') }}
- name: Cache .venv dir
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock', '.ghjk/lock.json') }}
# FIXME: the custom runner is missing some ambient items found in
# github runner images by default. remove this hack when ghjk handles
# zstd/bsdtar on it's own
- run: |
sudo apt update
sudo apt install -y --no-install-recommends zstd
- uses: metatypedev/setup-ghjk@2e8bbf084060a18828338a7cdd43fde6feb2a3cc
- shell: bash
env:
WASM_FILE: target/release/typegraph_core.wasm
run: |
echo pwd in $(pwd)
sudo apt update
sudo apt install -y --no-install-recommends gcc-multilib pkg-config libssl-dev libclang-dev perl make
python3 -m venv .venv
source .venv/bin/activate
poetry install --no-root
# build typegraph_core wasm
cargo build -p typegraph_core --target wasm32-unknown-unknown --release --target-dir target/wasm
mkdir -p $(dirname $WASM_FILE)
wasm-opt -Oz target/wasm/wasm32-unknown-unknown/release/typegraph_core.wasm -o $WASM_FILE.opt
wasm-tools component new $WASM_FILE.opt -o $WASM_FILE
# build python sdk package
poetry run python -m wasmtime.bindgen $WASM_FILE --out-dir typegraph/python/typegraph/gen
# build node typegrap/sdk package
jco transpile $WASM_FILE -o typegraph/node/sdk/src/gen --map metatype:typegraph/host=../host/host.js
cd typegraph/node
pnpm install
pnpm run sdk-build
cp ./sdk/{package.json,package-lock.json,LICENSE.md} ./sdk/dist
cd -
# start the docker containers
ghjk x dev env base prisma
export NPM_CONFIG_REGISTRY=http://localhost:4873
# publish the sdk to the local registry
cd typegraph/node/sdk/dist
npm config set "//localhost:4873/:_authToken" fooBar
npm publish --registry $NPM_CONFIG_REGISTRY
cd -
ghjk x clean-deno-lock
# install packages inside metatype examples
pnpm install -C examples/typegraphs
deno cache --import-map typegate/import_map.json typegate/src/main.ts typegate/tests/utils/mod.ts
deno run -A dev/update.ts --cache-only
cargo build -p xtask # xtask and meta-cli are used by the test suite
cargo build -p meta-cli
# from old test-meta-cli
cargo test --locked --package meta-cli
# from old test-libs
cargo test --locked --exclude meta-cli --exclude typegate --exclude typegate_engine --exclude typegraph_core --exclude metagen_mdk_rust_static --workspace
# from old test-typegraph-core
# test in native rust, not in wasm for a future rust SDK
# without --tests, the --doc is causing a link error "syntax error in VERSION script"
cargo test --locked --package typegraph_core --tests
ghjk x clean-deno-lock
deno run -A dev/test.ts --threads 1 -- --coverage=coverage
# FIXME: required due to https://github.com/denoland/deno/issues/21621#issuecomment-1887870712
deno cache --import-map typegate/import_map.json \
typegate/src/main.ts \
typegate/tests/utils/*.ts \
typegate/tests/runtimes/wasm_wire/*.ts \
typegate/tests/runtimes/wasm_reflected/*.ts \
typegate/tests/runtimes/python/*.ts \
dev/deps.ts \
dev/utils.ts
deno --unstable-worker-options --unstable-net coverage ./coverage --lcov > coverage.lcov
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.lcov
fail_ci_if_error: true
test-lsp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- uses: metatypedev/setup-ghjk@2e8bbf084060a18828338a7cdd43fde6feb2a3cc
- shell: bash
run: |
cd meta-lsp
pnpm install --frozen-lockfile --recursive
cd ts-language-server
# node --test --import=tsx --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage.lcov tests/*.test.ts
node --test --import=tsx tests/*.test.ts
# - uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: ./meta-lsp/ts-language-server/coverage.lcov
# fail_ci_if_error: true