Skip to content

Commit

Permalink
Convert E2Es to examples (#379)
Browse files Browse the repository at this point in the history
Co-authored-by: enisdenjo <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: theguild-bot <[email protected]>
  • Loading branch information
4 people authored Dec 31, 2024
1 parent 121751d commit 1fbdf70
Show file tree
Hide file tree
Showing 172 changed files with 119,835 additions and 216 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Examples

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# NOTE: github.event.head_commit.message is not available on pull_request events
head-commit:
name: Inspect head commit
runs-on: ubuntu-latest
outputs:
message: ${{ steps.commit.outputs.message }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
- name: Inspect
id: commit
run: echo "message=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"

convert:
needs: [head-commit]
if: "${{needs.head-commit.outputs.message != 'docs(examples): converted from e2es'}}"
strategy:
matrix:
e2e:
- extra-fields
- federation-example
- federation-mixed
- file-upload
- apq-subgraphs
- federation-subscriptions-passthrough
- hmac-auth-https
- interface-additional-resolvers
- json-schema-subscriptions
- openapi-additional-resolvers
- openapi-arg-rename
- openapi-javascript-wiki
- openapi-subscriptions
- programmatic-batching
- subscriptions-with-transforms
- type-merging-batching
name: Convert ${{matrix.e2e}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up env
uses: the-guild-org/shared-config/setup@v1
- name: Convert
run: yarn workspace @internal/examples run start ${{matrix.e2e}} true
- name: Upload
uses: actions/upload-artifact@v4
with:
name: example-${{matrix.e2e}}
# include all files and folders starting with a dot (.)
include-hidden-files: true
# > If multiple paths are provided as input, the least common ancestor of all the search paths will be used as the root directory of the artifact.
# https://github.com/actions/upload-artifact#upload-using-multiple-paths-and-exclusions
#
# Because of this, we include the root README.md to maintain the paths during artifact downloads
path: |
README.md
examples/${{matrix.e2e}}
!examples/${{matrix.e2e}}/node_modules
commit:
needs: [convert]
name: Commit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{secrets.BOT_GITHUB_TOKEN}}
- name: Download
uses: actions/download-artifact@v4
with:
pattern: example-*
merge-multiple: true
- name: Diff
run: git diff --pretty
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: examples/
commit_message: 'docs(examples): converted from e2es'
commit_user_name: theguild-bot
commit_user_email: [email protected]
commit_author: theguild-bot <[email protected]> # dont use the actor as an author
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ tsconfig.tsbuildinfo
sea-prep.blob
hive-gateway
.cache/
*.pem
/examples/**/*/supergraph.graphql
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ __generated__
!.changeset/config.json
.wrangler/
*.Dockerfile
/examples/
1 change: 0 additions & 1 deletion e2e/hmac-auth-https/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createTenv } from '@internal/e2e';
import { describe, expect, it } from 'vitest';

describe('HMAC Signature', async () => {
execSync('yarn workspace hmac-auth-https generate-users-cert');
execSync('yarn workspace @e2e/hmac-auth-https generate-users-cert');
const { service, gateway, gatewayRunner } = createTenv(__dirname);
const localCertFile = join(__dirname, 'users_cert.pem');
const dockerCertFile = '/gateway/users_cert.pem';
Expand Down
3 changes: 2 additions & 1 deletion e2e/hmac-auth-https/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "hmac-auth-https",
"name": "@e2e/hmac-auth-https",
"version": "0.0.0",
"private": true,
"scripts": {
"generate-users-cert": "openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout ./services/users/key.pem -out ./services/users/cert.pem -subj \"/CN=users_subgraph\" -addext \"subjectAltName=DNS:users_subgraph,DNS:localhost,IP:172.17.0.1,DNS:host.docker.internal\" && cp ./services/users/cert.pem ./users_cert.pem"
},
"dependencies": {
"@apollo/server": "^4.10.3",
"@apollo/subgraph": "^2.9.3",
"@graphql-hive/gateway": "workspace:^",
"@graphql-mesh/compose-cli": "^1.3.3",
Expand Down
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> [!CAUTION]
> These examples are auto-generated using the [e2e](/e2e) tests, do NOT modify them directly!
30 changes: 30 additions & 0 deletions examples/apq-subgraphs/.codesandbox/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"setupTasks": [
{
"name": "Install",
"command": "npm i"
},
{
"name": "Start service greetings",
"command": "npm run service:greetings &"
},
{
"name": "Wait for service greetings",
"command": "curl --retry-connrefused --retry 10 --retry-delay 3 http://0.0.0.0:4001"
},
{
"name": "Compose",
"command": "npm run compose"
}
],
"tasks": {
"gateway": {
"name": "Hive Gateway",
"runAtStart": true,
"command": "npm run gateway",
"preview": {
"port": 4000
}
}
}
}
4 changes: 4 additions & 0 deletions examples/apq-subgraphs/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Node.js",
"image": "mcr.microsoft.com/devcontainers/javascript-node:20"
}
20 changes: 20 additions & 0 deletions examples/apq-subgraphs/gateway.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defineConfig } from '@graphql-hive/gateway';

let fetchCnt = 0;
export const gatewayConfig = defineConfig({
transportEntries: {
greetings: {
options: {
apq: true,
},
},
},
plugins: () => [
{
onFetch({ options }) {
fetchCnt++;
process.stdout.write(`fetch ${fetchCnt} ${options.body}\n`);
},
},
],
});
14 changes: 14 additions & 0 deletions examples/apq-subgraphs/mesh.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
defineConfig,
loadGraphQLHTTPSubgraph,
} from '@graphql-mesh/compose-cli';

export const composeConfig = defineConfig({
subgraphs: [
{
sourceHandler: loadGraphQLHTTPSubgraph('greetings', {
endpoint: `http://localhost:${4001}/graphql`,
}),
},
],
});
Loading

0 comments on commit 1fbdf70

Please sign in to comment.