Skip to content

Commit

Permalink
feat: bundle mesh as a binary (#7339)
Browse files Browse the repository at this point in the history
* fix

* fix

* fix

* chore(dependencies): updated changesets for modified dependencies

* fix

* fix

* fix

* chore(dependencies): updated changesets for modified dependencies

* ignore parcel in bundle

* refactor bundling

* chore(dependencies): updated changesets for modified dependencies

* isomorphic graphql

* no bundle-binary

* package binary ci

* e2e test bin

* package bin only when bin

* better packaage-binary script

* build instructions

* lowercase platform

* no for

* dedupe

* chore(dependencies): updated changesets for modified dependencies

* no test binary

* no more package sh

* win for windows

* artifact names and path switch

* put back inject-version

* win build to dest

* build for bin e2e

* no win shortcut

* npm i g tsx zx

* improve uws injection

* use sea-config instead of writing

* chore(dependencies): updated changesets for modified dependencies

* default version and clarify bin name

* install sea packed deps

* hooks for resolution of packed deps

* chore(dependencies): updated changesets for modified dependencies

* from*

* zero dep

* uws in packed modules

* micro fixes

* use default export of uWS for consistency

* chore(dependencies): updated changesets for modified dependencies

* bundle node-libcurl

* ..

* Skip zx

* optional args

* no zx

* Fix comment

* chore(dependencies): updated changesets for modified dependencies

* Better comments for Images

* Remove verbose logs for Docker build

* Try Windows

* Setup NASM for Windows

* Fix

* Do not throw

* Fix

* Faster build for Windows

* Fix broken packaging

* Fix releases

* Fix build for Windows

* Windows is win32 not windows

* Fix Windows build

* It is optional on Windows

* Export correct artifacts for Windows

* It has to be 22 unfortunately

* Go

* No more build needed

* node-libcurl is first class citizen

* chore(dependencies): updated changesets for modified dependencies

* Fix lockfile

* Hmm

* chore(dependencies): updated changesets for modified dependencies

* Simplify workflows

* This is shell bas

* Fix docker runner e2e

* Fix e2e

* Enable Docker for Mac

* Go

* Try again

* Fix Windows build

* Start Docker on macOS

* Start using colima

* Skip symlinking if fails

* Fix Docker for MacOS

* Remove rover

* Fix signtool path

* Fix Windows

* Try again

* Chill Windows

* version + docs + install.sj

* Windows?

* Signtool

* See err

* More verbose error

* New signtool location

* Better error handling

* More error

* Fix Windows

* Fix Windows again???

* Better abort error

* Timeout for Serve CLI too

* Try again

* Fix URLs

* Setup Docker and WSL

* Go

* macOS

* Remove unnecessary timeouts

* Go

* Go

* Peki

* Try

* Try again?

* Try ??

* Try sth else

* Faster Docker setup

* Again?

* Try again

* Hello??

* Hellooo

* Try sth

* Try sth

* Try sth

* Hello

* Go

* More

* Try again

* Use Official action

* Winget again??

* ..

* Install Ubuntu

* Try

* Try another windows

* Winget

* Try simpler

* Try again?

* Try again?

* Try this

* Try

* Try

* Test

* Hmm

* Windows

* Try this

* Go

* Test again

* Go

* Go

* Again?

* ...

* Try 127.0.0.1

* Test 2

* Test

* Sign using digicert

* Last try

* Let's goo

* go

* lets go

* Go

* Lets go

* Try this

* Test

* Fix wsl integration

* Try sth else

* Yes

* mayybeee

* Fix uWS and node-libcurl imports on Windows

* ..

* Fix

* Force exit on e2e tests

* No need to import it

* Correct defaults

* Bump node-libcurl

* Bump node-libcurl and align whatwg-node

* chore(dependencies): updated changesets for modified dependencies

* Fix Docker

* ..

* Go

* Try this

* Go

* Fix

* Fix windows things

* Increase timeout

* Go

* Leave Windows work

* Be more patient

* Use whatwg-node

* Fix Windows docker

* Fix Windows path

* Continue

* Ok

* Remove extra timeout

* Trim printed errors

* Trim printed errors in E2E tests

* Trim in exit code error as well

* Test boot2docker on Windows

* wtf

* curl ftw

* ..

* Try

* Go

* Go

* ??

* port

* Try again

* Try this

* Try localhost

* This is the only way

* Run qemu

* Go

* Make sure it is running

* Try again

* Go

* Choco

* Put it in the background

* Wait port

* wait

* Of

* Try better `resource`

* Try

* Leave note and logoff

* ..

* Trim in the thrown error too

* Maybe works on Windows?

* Try this

* Hmm...

* FFF

* ..

* ..

* Fix again

* Fix..

* Release

* Try again

* Better docker build action

* Avoid extra work

* Hive Gateway binaryu

* Install.sh for hive-gateway

* Disable uWS in Windows to try

* Less work for Windows

* Windows

* Add jaeger windows

* Try again

* ..

* Fix

* Windows 2019

* Disable windows e2e for now

* Smaller package for soap

* More

* ..

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: enisdenjo <[email protected]>
Co-authored-by: Arda TANRIKULU <[email protected]>
  • Loading branch information
4 people authored Sep 2, 2024
1 parent 379c9cf commit b50ad41
Show file tree
Hide file tree
Showing 85 changed files with 2,389 additions and 867 deletions.
5 changes: 5 additions & 0 deletions .changeset/@graphql-mesh_cli-7339-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-mesh/cli": patch
---
dependencies updates:
- Added dependency [`node-libcurl@npm:@ardatan/node-libcurl@^4.0.2` ↗︎](https://www.npmjs.com/package/node-libcurl/v/4.0.2) (to `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/@graphql-mesh_serve-cli-7339-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-mesh/serve-cli": patch
---
dependencies updates:
- Added dependency [`node-libcurl@npm:@ardatan/node-libcurl@^4.0.2` ↗︎](https://www.npmjs.com/package/node-libcurl/v/4.0.2) (to `dependencies`)
6 changes: 2 additions & 4 deletions .github/workflows/loadtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- master

jobs:
e2e:
name: e2e / node ${{matrix.node-version}}
loadtest-e2e:
name: node ${{matrix.node-version}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -20,8 +20,6 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Required Libraries
run: sudo apt update && sudo apt install -y libcurl4-openssl-dev libssl-dev
- uses: the-guild-org/shared-config/setup@v1
name: setup env
with:
Expand Down
88 changes: 75 additions & 13 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,32 @@ jobs:
runs-on: ubuntu-latest
needs: [release]
strategy:
fail-fast: false
matrix:
include:
- productname: mesh-serve
packagename: '@graphql-mesh/serve-cli'
- productname: hive-gateway
packagename: '@graphql-hive/gateway'
productname: [mesh-serve, hive-gateway]
if: contains(needs.release.outputs.publishedPackages, '@graphql-mesh/serve-cli')
steps:
- name: Choose names
id: names
run: |
echo "::set-output name=productname::${{ matrix.productname == 'mesh-serve' && 'mesh-serve' || 'hive-gateway' }}"
echo "::set-output name=packagename::${{ matrix.productname == 'mesh-serve' && '@graphql-mesh/serve-cli' || '@graphql-hive/gateway' }}"
echo "::set-output name=packagedir::${{ matrix.productname == 'mesh-serve' && 'packages/serve-cli' || 'packages/hive-gateway' }}"
- name: version ${{ matrix.productname }}
uses: actions/github-script@v7
id: ver-mesh-serve
with:
result-encoding: string
script: |
const publishedPackages = ${{ needs.release.outputs.publishedPackages }};
const meshServe = publishedPackages.find((p) => p.name === '${{ matrix.packagename }}');
const meshServe = publishedPackages.find((p) => p.name === '${{ steps.names.outputs.packagename }}');
if (!meshServe) {
return core.setFailed('${{ matrix.packagename }} was not published!');
return core.setFailed('${{ steps.names.outputs.packagename }} was not published!');
}
console.log(meshServe.version);
return meshServe.version;
- name: checkout
uses: actions/checkout@v4
- name: Install Required Libraries
run: sudo apt update && sudo apt install -y libcurl4-openssl-dev libssl-dev
- name: set up docker buildx
uses: docker/setup-buildx-action@v3
- name: log in to ghcr
Expand All @@ -70,10 +71,10 @@ jobs:
- name: prepare
run: yarn prebuild
- name: bundle
run: yarn bundle
run: yarn workspace ${{steps.names.outputs.packagename }} bundle
- name: inject ${{ matrix.productname }} version
run: |
yarn workspace ${{ matrix.packagename }} inject-version ${{ steps.ver-mesh-serve.outputs.result }}
yarn workspace ${{steps.names.outputs.packagename }} inject-version ${{ steps.ver-mesh-serve.outputs.result }}
- name: bake and push
uses: docker/bake-action@v5
env:
Expand All @@ -87,9 +88,70 @@ jobs:
- name: comment on pr
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Docker Image for ${{ matrix.productname }}
header: Docker Image for `${{ matrix.productname }}`
message: |
Published images for this PR are available at:
Published `${{matrix.productname}}` images for this PR are available at:
```
ghcr.io/ardatan/${{ matrix.productname }}:${{ steps.ver-mesh-serve.outputs.result }}
```
bin:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-latest-large, windows-latest]
productname: [mesh-serve, hive-gateway]
steps:
- name: Choose names
id: names
run: |
echo "::set-output name=productname::${{ matrix.productname == 'mesh-serve' && 'mesh-serve' || 'hive-gateway' }}"
echo "::set-output name=packagename::${{ matrix.productname == 'mesh-serve' && '@graphql-mesh/serve-cli' || '@graphql-hive/gateway' }}"
echo "::set-output name=packagedir::${{ matrix.productname == 'mesh-serve' && 'packages/serve-cli' || 'packages/hive-gateway' }}"
- name: checkout
uses: actions/checkout@v2

# Install Windows specific dependencies
- if: runner.os == 'Windows'
name: Disable Windows Defender
run: Set-MpPreference -DisableRealtimeMonitoring $true
shell: powershell
- if: runner.os == 'Windows'
name: Install Windows SDK
uses: fbactions/setup-winsdk@v2
with:
winsdk-build-version: 18362

- uses: the-guild-org/shared-config/setup@v1
name: set up env
with:
node-version-file: .node-version
- name: prepare
run: yarn prebuild
- name: bundle
run: yarn workspace ${{steps.names.outputs.packagename }} bundle
- name: inject ${{ steps.names.outputs.packagename }} version
run: |
yarn workspace ${{steps.names.outputs.packagename }} inject-version ${{ github.sha }}
- name: package binary
run: yarn workspace ${{steps.names.outputs.packagename }} package-binary
- name: upload artifact
id: upload_artifact
uses: actions/upload-artifact@v4
with:
name:
${{ matrix.productname}}-${{runner.os}}-${{runner.arch}}${{ runner.os == 'Windows' &&
'.exe' || ''}}
path: |
${{ steps.names.outputs.packagedir }}/${{ matrix.productname }}${{ runner.os == 'Windows' && '.exe' || '' }}
- name: update PR comment with artifact link
uses: marocchino/sticky-pull-request-comment@v2
with:
header: 'Node Sea Artifacts Status (`${{ runner.os }}-${{ runner.arch }}`)'
message: |
The build artifacts of `${{ matrix.productname }}` as a single executable for `${{ runner.os }}-${{ runner.arch }}` are available at:
[Download](https:/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.upload_artifact.outputs.artifact-id }})
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98 changes: 87 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,27 @@ jobs:
ghcr:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- productname: mesh-serve
packagename: '@graphql-mesh/serve-cli'
- productname: hive-gateway
packagename: '@graphql-hive/gateway'
productname: [mesh-serve, hive-gateway]
needs: [stable]
if: contains(needs.stable.outputs.publishedPackages, '@graphql-mesh/serve-cli')
steps:
- name: Choose names
id: names
run: |
echo "::set-output name=productname::${{ matrix.productname == 'mesh-serve' && 'mesh-serve' || 'hive-gateway' }}"
echo "::set-output name=packagename::${{ matrix.productname == 'mesh-serve' && '@graphql-mesh/serve-cli' || '@graphql-hive/gateway' }}"
echo "::set-output name=packagedir::${{ matrix.productname == 'mesh-serve' && 'packages/serve-cli' || 'packages/hive-gateway' }}"
- name: version ${{ matrix.productname }}
uses: actions/github-script@v7
id: ver-mesh-serve
with:
script: |
const publishedPackages = ${{ needs.stable.outputs.publishedPackages }};
const meshServe = publishedPackages.find((p) => p.name === '${{ matrix.packagename }}');
const meshServe = publishedPackages.find((p) => p.name === '${{ steps.names.outputs.packagename }}');
if (!meshServe) {
return core.setFailed('${{ matrix.packagename }} was not published!');
return core.setFailed('${{ steps.names.outputs.packagename }} was not published!');
}
const { version } = meshServe;
const [major, minor] = version.split('.');
Expand All @@ -54,8 +57,6 @@ jobs:
return r;
- name: checkout
uses: actions/checkout@v4
- name: Install Required Libraries
run: sudo apt update && sudo apt install -y libcurl4-openssl-dev libssl-dev
- name: set up docker buildx
uses: docker/setup-buildx-action@v3
- name: log in to ghcr
Expand All @@ -71,10 +72,10 @@ jobs:
- name: prepare
run: yarn prebuild
- name: bundle
run: yarn bundle
run: yarn workspace ${{ steps.names.outputs.packagename }} bundle
- name: inject ${{ matrix.productname }} version
run: |
yarn workspace ${{ matrix.packagename }} inject-version ${{ fromJSON(steps.ver-mesh-serve.outputs.result).version }}
yarn workspace ${{ steps.names.outputs.packagename }} inject-version ${{ fromJSON(steps.ver-mesh-serve.outputs.result).version }}
- name: bake and push
uses: docker/bake-action@v5
env:
Expand All @@ -85,3 +86,78 @@ jobs:
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
push: true

bin:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-latest-large, windows-latest]
productname: [mesh-serve, hive-gateway]
needs: [stable]
if: contains(needs.stable.outputs.publishedPackages, '@graphql-mesh/serve-cli')
steps:
- name: Choose names
id: names
run: |
echo "::set-output name=productname::${{ matrix.productname == 'mesh-serve' && 'mesh-serve' || 'hive-gateway' }}"
echo "::set-output name=packagename::${{ matrix.productname == 'mesh-serve' && '@graphql-mesh/serve-cli' || '@graphql-hive/gateway' }}"
echo "::set-output name=packagedir::${{ matrix.productname == 'mesh-serve' && 'packages/serve-cli' || 'packages/hive-gateway' }}"
- name: version ${{ matrix.productname }}
uses: actions/github-script@v7
id: ver-mesh-serve
with:
script: |
const publishedPackages = ${{ needs.stable.outputs.publishedPackages }};
const meshServe = publishedPackages.find((p) => p.name === '${{ steps.names.outputs.packagename }}');
if (!meshServe) {
return core.setFailed('${{ steps.names.outputs.packagename }} was not published!');
}
const { version } = meshServe;
const [major, minor] = version.split('.');
if (!major || !minor) {
return core.setFailed(`Unknown major or minor in version "${version}"!`);
}
const r = { version, tags: `latest,${major},${major}.${minor},${version}` };
console.log(r);
return r;
- name: checkout
uses: actions/checkout@v2

# Install Windows specific dependencies
- if: runner.os == 'Windows'
name: Disable Windows Defender
run: Set-MpPreference -DisableRealtimeMonitoring $true
shell: powershell
- if: matrix.os == 'windows-latest'
name: Install Windows SDK
uses: fbactions/setup-winsdk@v2
with:
winsdk-build-version: 18362

- uses: the-guild-org/shared-config/setup@v1
name: set up env
with:
node-version-file: .node-version
- name: prepare
run: yarn prebuild
- name: bundle
run: yarn workspace ${{ steps.names.outputs.packagename }} bundle
- name: inject ${{ matrix.productname }} version
run: |
yarn workspace ${{steps.names.outputs.packagename }} inject-version ${{ steps.ver-mesh-serve.outputs.result }}
- name: package binary
run: yarn workspace ${{ steps.names.outputs.packagename }} package-binary
shell: bash
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file:
${{ steps.names.outputs.packagedir }}/${{ matrix.productname }}${{ runner.os ==
'Windows' && '.exe' || ''}}
asset_name:
${{ matrix.productname }}-${{ runner.os }}-${{ runner.arch }}${{ runner.os == 'Windows'
&& '.exe' || ''}}
tag: ${{fromJSON(steps.ver-mesh-serve.outputs.result).version}}
overwrite: true
Loading

0 comments on commit b50ad41

Please sign in to comment.