Skip to content

Commit 1fbdf70

Browse files
enisdenjogithub-actions[bot]theguild-bot
authored
Convert E2Es to examples (#379)
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]>
1 parent 121751d commit 1fbdf70

File tree

172 files changed

+119835
-216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+119835
-216
lines changed

.github/workflows/examples.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Examples
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
# NOTE: github.event.head_commit.message is not available on pull_request events
12+
head-commit:
13+
name: Inspect head commit
14+
runs-on: ubuntu-latest
15+
outputs:
16+
message: ${{ steps.commit.outputs.message }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
ref: ${{github.event.pull_request.head.sha}}
22+
- name: Inspect
23+
id: commit
24+
run: echo "message=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
25+
26+
convert:
27+
needs: [head-commit]
28+
if: "${{needs.head-commit.outputs.message != 'docs(examples): converted from e2es'}}"
29+
strategy:
30+
matrix:
31+
e2e:
32+
- extra-fields
33+
- federation-example
34+
- federation-mixed
35+
- file-upload
36+
- apq-subgraphs
37+
- federation-subscriptions-passthrough
38+
- hmac-auth-https
39+
- interface-additional-resolvers
40+
- json-schema-subscriptions
41+
- openapi-additional-resolvers
42+
- openapi-arg-rename
43+
- openapi-javascript-wiki
44+
- openapi-subscriptions
45+
- programmatic-batching
46+
- subscriptions-with-transforms
47+
- type-merging-batching
48+
name: Convert ${{matrix.e2e}}
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
- name: Set up env
54+
uses: the-guild-org/shared-config/setup@v1
55+
- name: Convert
56+
run: yarn workspace @internal/examples run start ${{matrix.e2e}} true
57+
- name: Upload
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: example-${{matrix.e2e}}
61+
# include all files and folders starting with a dot (.)
62+
include-hidden-files: true
63+
# > 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.
64+
# https://github.com/actions/upload-artifact#upload-using-multiple-paths-and-exclusions
65+
#
66+
# Because of this, we include the root README.md to maintain the paths during artifact downloads
67+
path: |
68+
README.md
69+
examples/${{matrix.e2e}}
70+
!examples/${{matrix.e2e}}/node_modules
71+
72+
commit:
73+
needs: [convert]
74+
name: Commit
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
with:
80+
token: ${{secrets.BOT_GITHUB_TOKEN}}
81+
- name: Download
82+
uses: actions/download-artifact@v4
83+
with:
84+
pattern: example-*
85+
merge-multiple: true
86+
- name: Diff
87+
run: git diff --pretty
88+
- name: Commit
89+
uses: stefanzweifel/git-auto-commit-action@v5
90+
with:
91+
file_pattern: examples/
92+
commit_message: 'docs(examples): converted from e2es'
93+
commit_user_name: theguild-bot
94+
commit_user_email: [email protected]
95+
commit_author: theguild-bot <[email protected]> # dont use the actor as an author

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ tsconfig.tsbuildinfo
1010
sea-prep.blob
1111
hive-gateway
1212
.cache/
13+
*.pem
14+
/examples/**/*/supergraph.graphql

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ __generated__
88
!.changeset/config.json
99
.wrangler/
1010
*.Dockerfile
11+
/examples/

e2e/hmac-auth-https/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

e2e/hmac-auth-https/hmac-signature.e2e.ts renamed to e2e/hmac-auth-https/hmac-auth-https.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createTenv } from '@internal/e2e';
44
import { describe, expect, it } from 'vitest';
55

66
describe('HMAC Signature', async () => {
7-
execSync('yarn workspace hmac-auth-https generate-users-cert');
7+
execSync('yarn workspace @e2e/hmac-auth-https generate-users-cert');
88
const { service, gateway, gatewayRunner } = createTenv(__dirname);
99
const localCertFile = join(__dirname, 'users_cert.pem');
1010
const dockerCertFile = '/gateway/users_cert.pem';

e2e/hmac-auth-https/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"name": "hmac-auth-https",
2+
"name": "@e2e/hmac-auth-https",
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
66
"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"
77
},
88
"dependencies": {
9+
"@apollo/server": "^4.10.3",
910
"@apollo/subgraph": "^2.9.3",
1011
"@graphql-hive/gateway": "workspace:^",
1112
"@graphql-mesh/compose-cli": "^1.3.3",

examples/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
> [!CAUTION]
2+
> These examples are auto-generated using the [e2e](/e2e) tests, do NOT modify them directly!
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"setupTasks": [
3+
{
4+
"name": "Install",
5+
"command": "npm i"
6+
},
7+
{
8+
"name": "Start service greetings",
9+
"command": "npm run service:greetings &"
10+
},
11+
{
12+
"name": "Wait for service greetings",
13+
"command": "curl --retry-connrefused --retry 10 --retry-delay 3 http://0.0.0.0:4001"
14+
},
15+
{
16+
"name": "Compose",
17+
"command": "npm run compose"
18+
}
19+
],
20+
"tasks": {
21+
"gateway": {
22+
"name": "Hive Gateway",
23+
"runAtStart": true,
24+
"command": "npm run gateway",
25+
"preview": {
26+
"port": 4000
27+
}
28+
}
29+
}
30+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Node.js",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:20"
4+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineConfig } from '@graphql-hive/gateway';
2+
3+
let fetchCnt = 0;
4+
export const gatewayConfig = defineConfig({
5+
transportEntries: {
6+
greetings: {
7+
options: {
8+
apq: true,
9+
},
10+
},
11+
},
12+
plugins: () => [
13+
{
14+
onFetch({ options }) {
15+
fetchCnt++;
16+
process.stdout.write(`fetch ${fetchCnt} ${options.body}\n`);
17+
},
18+
},
19+
],
20+
});

0 commit comments

Comments
 (0)