Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature quickadds query #2731

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f11291f
Forward graphql requests to netlify function
cesarvarela Mar 19, 2024
16bba0f
Trigger Build
cesarvarela Mar 19, 2024
eb449b7
update lockfile
cesarvarela Mar 19, 2024
9b219e6
Avoid having to introspect schema for every request
cesarvarela Mar 19, 2024
c545569
Merge remote-tracking branch 'upstream/staging' into feature-netlify-…
cesarvarela Mar 20, 2024
9ffa839
Allow anonymous read only queries
cesarvarela Mar 20, 2024
e7cce66
Allow anonymous read only queries
cesarvarela Mar 20, 2024
27082d3
Merge branch 'feature-netlify-graphql' of github.com:aiidtest/aiid in…
cesarvarela Mar 20, 2024
1a3385f
Trigger Build
cesarvarela Mar 20, 2024
9ae2767
Merge remote-tracking branch 'upstream/staging' into feature-netlify-…
cesarvarela Apr 9, 2024
6491c8e
Add quickadds resolver
cesarvarela Apr 11, 2024
a8d837a
Split resolvers into separate files
cesarvarela Apr 12, 2024
606b325
Separate auth in its own file
cesarvarela Apr 12, 2024
3d33922
Add jest and tests
cesarvarela Apr 12, 2024
1f2f2f4
Add script to boot local api server for development purposes
cesarvarela Apr 12, 2024
bdf03a8
Add quickadd insert field
cesarvarela Apr 15, 2024
ee012b3
Add test workflows
cesarvarela Apr 15, 2024
318a8c1
Move to appropriate folder
cesarvarela Apr 15, 2024
ec02117
Trigger build
cesarvarela Apr 15, 2024
520acc4
Fix step syntax
cesarvarela Apr 15, 2024
c15374c
Remove unnecessary variables
cesarvarela Apr 15, 2024
54637df
Fix title
cesarvarela Apr 15, 2024
ae7da77
Trigger build
cesarvarela Apr 15, 2024
329a8f2
remove
cesarvarela Apr 16, 2024
18c3c6a
Trigger build
cesarvarela Apr 16, 2024
6d62d09
Trigger build
cesarvarela Apr 16, 2024
f869e31
fsdfsf
cesarvarela Apr 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ jobs:
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
exit 1


call-test-api:
if: ${{ !failure() }}
uses: ./.github/workflows/test-api.yml
needs: permissions-check
secrets: inherit
with:
sha: ${{ github.event.pull_request.head.sha }}
environment: staging

call-test-build:
if: ${{ !failure() }}
uses: ./.github/workflows/test-build.yml
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/test-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Run API tests
on:
workflow_call:
inputs:
environment:
description: The Github environment to load secrets from
type: string
required: true
sha:
description: The commit SHA to run the tests against
type: string
required: true
runner-label:
description: The label of the runner to use
type: string
cache-modifier:
description: A modifier for the cache key used to bypass existing cache
type: string
required: false
default: ""

jobs:
test:
name: Run tests
environment: ${{ inputs.environment }}
runs-on:
labels: ${{ inputs.runner-label || 'ubuntu-latest' }}
defaults:
run:
shell: bash
working-directory: site/gatsby-site
steps:

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}

- name: Read node modules from cache
id: cache-nodemodules
uses: actions/cache/restore@v4
env:
cache-name: cache-install-folder
with:
path: |
site/gatsby-site/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-${{ inputs.cache-modifier }}

- name: Install NPM dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci
working-directory: site/gatsby-site

- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
id: extract_branch

- name: Jest run
run: npm run test:api:ci
env:
# Recommended: pass the GitHub token lets this action correctly
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }}
E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ vars.GATSBY_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_SEARCH_KEY: ${{ vars.GATSBY_ALGOLIA_SEARCH_KEY }}
GATSBY_AVAILABLE_LANGUAGES: ${{ vars.GATSBY_AVAILABLE_LANGUAGES }}
GATSBY_REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }}
MONGODB_CONNECTION_STRING: ${{ secrets.MONGODB_CONNECTION_STRING }}
GATSBY_REALM_APP_GRAPHQL_URL: ${{ secrets.GATSBY_REALM_APP_GRAPHQL_URL }}
GATSBY_ROLLBAR_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }}
REALM_GRAPHQL_API_KEY: ${{ secrets.REALM_GRAPHQL_API_KEY }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
14 changes: 14 additions & 0 deletions site/gatsby-site/codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
overwrite: true,
schema: "./src/server/typeDefs.ts",
generates: {
"src/server/generated/graphql.ts": {
plugins: ["typescript", "typescript-resolvers", "typescript-mongodb"]
}
}
};

export default config;
4 changes: 4 additions & 0 deletions site/gatsby-site/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const config = {
db_collection: 'incidents',
},
graphqlApiKey: process.env.REALM_GRAPHQL_API_KEY,
apiAppId: process.env.REALM_API_APP_ID,
apiGroupId: process.env.REALM_API_GROUP_ID,
apiPublicKey: process.env.REALM_API_PUBLIC_KEY,
apiPrivateKey: process.env.REALM_API_PRIVATE_KEY,
},
header: {
logo: '/logos/White_Transparent_AIID_short.png',
Expand Down
15 changes: 15 additions & 0 deletions site/gatsby-site/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,
// be explicit about types included
// to avoid clashing with Jest types
"types": [
"cypress"
]
},
"include": [
"../node_modules/cypress",
"./**/*.ts"
]
}
11 changes: 11 additions & 0 deletions site/gatsby-site/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { MongoMemoryServer } from 'mongodb-memory-server';

export = async function globalSetup() {

const instance = await MongoMemoryServer.create();
const uri = instance.getUri();

(global as any).__MONGOINSTANCE = instance;

process.env.MONGODB_CONNECTION_STRING = uri.slice(0, uri.lastIndexOf('/'));
};
6 changes: 6 additions & 0 deletions site/gatsby-site/globalTeardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { MongoMemoryServer } from 'mongodb-memory-server';

export = async function globalTeardown() {
const instance: MongoMemoryServer = (global as any).__MONGOINSTANCE;
await instance.stop();
};
19 changes: 19 additions & 0 deletions site/gatsby-site/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

import type { Config } from 'jest';

const config: Config = {
preset: "ts-jest",
clearMocks: true,
collectCoverage: true,
coverageDirectory: "coverage",
coverageProvider: "v8",
testEnvironment: "node",
globalSetup: "./globalSetup.ts",
globalTeardown: "./globalTeardown.ts",
};

export default config;
Loading
Loading