Skip to content

Commit fdbcc0e

Browse files
saihajenisdenjo
andauthored
ci: run docker test only (#1803)
* works * phantom commit * Revert "phantom commit" This reverts commit 9f82991. * update test Co-authored-by: enisdenjo <[email protected]>
1 parent 4c409c2 commit fdbcc0e

File tree

5 files changed

+51
-10
lines changed

5 files changed

+51
-10
lines changed

e2e/tests/docker.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import { DeploymentConfiguration } from '../types'
2-
import { assertGraphiQL, assertQuery, waitForEndpoint } from '../utils'
2+
import {
3+
assertGraphiQL,
4+
assertQuery,
5+
execPromise,
6+
waitForEndpoint,
7+
} from '../utils'
38
import * as docker from '@pulumi/docker'
49
import { interpolate } from '@pulumi/pulumi'
5-
import { resolve } from 'path'
10+
import { join, resolve } from 'path'
611

712
export const dockerDeployment = (
813
image: string,
914
): DeploymentConfiguration<{
1015
endpoint: string
1116
}> => ({
17+
prerequisites: async () => {
18+
await execPromise('yarn build', {
19+
cwd: '../examples/node-ts',
20+
})
21+
},
1222
program: async () => {
1323
const remoteImage = new docker.RemoteImage('node-image', {
1424
name: image,
@@ -17,14 +27,14 @@ export const dockerDeployment = (
1727

1828
const container = new docker.Container('container', {
1929
image: remoteImage.repoDigest,
20-
command: [`npx`, '.'],
30+
command: [`node`, 'index.js'],
2131
volumes: [
2232
{
2333
containerPath: '/app',
24-
hostPath: resolve('../'),
34+
hostPath: resolve('../examples/node-ts/dist'),
2535
},
2636
],
27-
workingDir: '/app/packages/graphql-yoga/dist',
37+
workingDir: '/app',
2838
ports: [
2939
{
3040
internal: 4000,
@@ -38,7 +48,7 @@ export const dockerDeployment = (
3848
)
3949

4050
return {
41-
endpoint: interpolate`http://${endpoint}`,
51+
endpoint: interpolate`http://${endpoint}/graphql`,
4252
}
4353
},
4454
test: async ({ endpoint }) => {

examples/node-ts/__integration-tests__/node-ts.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { yoga } from '../src/yoga'
22

33
describe('node-ts example integration', () => {
44
it('should execute query', async () => {
5-
const response = await yoga.fetch('http://yoga/graphql?query={hello}')
5+
const response = await yoga.fetch('http://yoga/graphql?query={greetings}')
66

77
expect(response.status).toBe(200)
88
expect(await response.text()).toMatchInlineSnapshot(
9-
`"{"data":{"hello":"world"}}"`,
9+
`"{"data":{"greetings":"This is the \`greetings\` field of the root \`Query\` type"}}"`,
1010
)
1111
})
1212

examples/node-ts/build.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { build } = require('esbuild')
2+
const { writeFileSync } = require('fs')
3+
4+
async function main() {
5+
await build({
6+
entryPoints: ['./src/index.ts'],
7+
outfile: 'dist/index.js',
8+
format: 'cjs',
9+
minify: false,
10+
bundle: true,
11+
platform: 'node',
12+
target: 'node14',
13+
})
14+
15+
writeFileSync(
16+
'./dist/package.json',
17+
JSON.stringify({
18+
name: 'yoga-test-function',
19+
version: '0.0.1',
20+
}),
21+
)
22+
23+
console.info(`Node TS build done!`)
24+
}
25+
26+
main().catch((e) => {
27+
console.error(e)
28+
process.exit(1)
29+
})

examples/node-ts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "1.0.0",
55
"scripts": {
66
"start": "ts-node src/index.ts",
7+
"build": "node ./build.js",
78
"check": "tsc --pretty --noEmit"
89
},
910
"dependencies": {

examples/node-ts/src/yoga.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ export const yoga = createYoga<ServerContext, UserContext>({
1616
schema: createSchema({
1717
typeDefs: /* GraphQL */ `
1818
type Query {
19-
hello: String!
19+
greetings: String!
2020
}
2121
type Subscription {
2222
greetings: String!
2323
}
2424
`,
2525
resolvers: {
2626
Query: {
27-
hello: () => 'world',
27+
greetings: () =>
28+
'This is the `greetings` field of the root `Query` type',
2829
},
2930
Subscription: {
3031
greetings: {

0 commit comments

Comments
 (0)