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

Update with upstream to fix compilation and docker setup #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// "shutdownAction": "none",

// Uncomment next line if you want to copy your .ssh creds and other config files for easier use inside container
"postCreateCommand": "bash ./docker/scripts/copy-local-config-and-ssh-creds.sh",
//"postCreateCommand": "bash ./docker/scripts/copy-local-config-and-ssh-creds.sh",

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
Expand Down
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
**/dist
/data
/data/schema.graphql
/data/schema.sql
/@app/graphql/index.*
/@app/client/.next
31 changes: 31 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module.exports = {
parser: "@typescript-eslint/parser",
extends: [
"plugin:react/recommended",
"plugin:import/errors",
"plugin:import/typescript",
"prettier",
"prettier/@typescript-eslint",
"prettier/react",
Expand Down Expand Up @@ -89,6 +91,35 @@ module.exports = {
{
env: "literal",
schemaString,
validators: [
"ExecutableDefinitions",
"FieldsOnCorrectType",
"FragmentsOnCompositeTypes",
"KnownArgumentNames",
"KnownDirectives", // disabled by default in relay
// 'KnownFragmentNames', // disabled by default in all envs
"KnownTypeNames",
"LoneAnonymousOperation",
"NoFragmentCycles",
"NoUndefinedVariables", //disabled by default in relay
// 'NoUnusedFragments' // disabled by default in all envs
// 'NoUnusedVariables' throws even when fragments use the variable
"OverlappingFieldsCanBeMerged",
"PossibleFragmentSpreads",
"ProvidedRequiredArguments", // disabled by default in relay
"ScalarLeafs", // disabled by default in relay
"SingleFieldSubscriptions",
"UniqueArgumentNames",
"UniqueDirectivesPerLocation",
"UniqueFragmentNames",
"UniqueInputFieldNames",
"UniqueOperationNames",
"UniqueVariableNames",
"ValuesOfCorrectType",
"VariablesAreInputTypes",
// "VariablesDefaultValueAllowed",
"VariablesInAllowedPosition",
],
},
],
"graphql/named-operations": [
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.md text=auto eol=lf
*.sh text=auto eol=lf
*.yml text=auto eol=lf
*.sql text=auto eol=lf
11 changes: 8 additions & 3 deletions .github/workflows/production-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

services:
postgres:
image: postgres:10.11
image: postgres:11.6
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -21,14 +21,19 @@ jobs:
--health-retries 5

steps:
- uses: actions/checkout@v1
- name: Checkout
uses: actions/checkout@v2
# TODO: we should be able to get rid of Node here
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install pg_dump
run: sudo apt-get install postgresql-client-10
run: |
sudo bash -c "echo deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main >> /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -yqq install postgresql-client-11
- name: setup database
run: |
cp .env.ci .env
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fetch = require("node-fetch");
const AbortController = require("abort-controller");
const { execSync } = require("child_process");

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function main() {
let attempts = 0;
Expand Down Expand Up @@ -48,7 +48,7 @@ async function main() {
console.log("Docker tests passed.");
}

main().catch(e => {
main().catch((e) => {
console.error(e);
process.exit(1);
});
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ dist
/@app/server/.nuxt/
.agignore
*.tsbuildinfo
.ethereal
yarn-error.log
.idea/*
7 changes: 3 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// See https://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"EditorConfig.EditorConfig", // http://editorconfig.org
"dbaeumer.vscode-eslint", // ESLint
"esbenp.prettier-vscode", // Prettier
"msjsdiag.debugger-for-chrome", // Chrome debugger integration
"apollographql.vscode-apollo", // GraphQL support
"ms-vscode-remote.vscode-remote-extensionpack", // OPTIONAL: develop inside of Docker containers
"sdras.vue-vscode-extensionpack", // various helpfull Vue extensions
"mrmlnc.vscode-less" // less, because we are using ANTD
"msjsdiag.debugger-for-chrome", // Chrome debugger integration
"ms-vscode-remote.vscode-remote-extensionpack" // OPTIONAL: develop inside of Docker containers
]
}
26 changes: 16 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,34 @@
"eslint.enable": true,
"eslint.lintTask.enable": true,
"eslint.lintTask.options": "--ext .js,.jsx,.ts,.tsx,.graphql .",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,

// ESLint calls prettier for these types already, so don't let them squabble
"javascript.format.enable": false,
"typescript.format.enable": false,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"graphql"
],
"editor.codeActionsOnSaveTimeout": 750,
"editor.codeActionsOnSave": {
"source.fixAll": true
},

"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,

"prettier.disableLanguages": [],

"files.associations": {
".gmrc": "jsonc"
},

"[graphql]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": false
}
},
"[typescriptreact]": {
"editor.formatOnSave": false
},
"[markdown]": {
"files.trimTrailingWhitespace": false
}
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
Expand Down
36 changes: 32 additions & 4 deletions @app/__tests__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ if (!process.env.TEST_DATABASE_URL) {
}
export const TEST_DATABASE_URL: string = process.env.TEST_DATABASE_URL;

export type User = { id: number; _password?: string; _email?: string };
export type User = {
id: string;
username: string;
_password?: string;
_email?: string;
};
export type Organization = { id: string; name: string };

// Make sure we release those pgPools so that our tests exit!
afterAll(() => {
const keys = Object.keys(pools);
return Promise.all(
keys.map(async key => {
keys.map(async (key) => {
try {
const pool = pools[key];
delete pools[key];
Expand Down Expand Up @@ -126,18 +132,40 @@ export const createUsers = async function createUsers(
return users;
};

export const createOrganizations = async function createOrganizations(
client: PoolClient,
count: number = 1
) {
const organizations: Organization[] = [];
for (let i = 0; i < count; i++) {
const slug = `organization-${i}`;
const name = `Organization ${i}`;
const {
rows: [organization],
} = await client.query(
`
select * from app_public.create_organization($1, $2)
`,
[slug, name]
);
organizations.push(organization);
}

return organizations;
};

/******************************************************************************/

export const createSession = async (
client: PoolClient,
userId: number
userId: string
): Promise<{ uuid: string }> => {
const {
rows: [session],
} = await client.query(
`
insert into app_private.sessions (user_id)
values ($1::int)
values ($1::uuid)
returning *
`,
[userId]
Expand Down
2 changes: 1 addition & 1 deletion @app/db/__tests__/jest.watch.hack.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const ts = null;
export const ts = 1595939926271;
13 changes: 8 additions & 5 deletions @app/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
"commit": "yarn gm commit",
"uncommit": "yarn gm uncommit",
"reset": "yarn gm reset",
"dump": "yarn gm migrate && yarn gm reset --shadow && yarn gm migrate --shadow --force",
"wipe-if-demo": "./scripts/wipe-if-demo"
"dump": "yarn gm migrate && yarn gm reset --shadow --erase && yarn gm migrate --shadow --forceActions",
"wipe-if-demo": "./scripts/wipe-if-demo",
"test": "NODE_ENV=test node -r @app/config/env ./node_modules/.bin/jest"
},
"dependencies": {
"graphile-migrate": "^0.0.17"
"graphile-migrate": "^0.2.0"
},
"devDependencies": {
"@types/pg": "^7.11.2",
"@types/pg": "^7.14.1",
"graphile-worker": "^0.6.0",
"jest": "^25.5.4",
"lodash": "^4.17.15",
"pg": "^7.15.0"
"pg": "^8.0.3"
}
}
1 change: 1 addition & 0 deletions @app/e2e/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../babel.config");
2 changes: 1 addition & 1 deletion @app/e2e/cypress/integration/manage_emails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ context("Manage emails", () => {
});

// Action: verify the email
cy.serverCommand("getEmailSecrets", { email }).then(secrets => {
cy.serverCommand("getEmailSecrets", { email }).then((secrets) => {
const { user_email_id, verification_token } = secrets;
const url = `${Cypress.env("ROOT_URL")}/verify?id=${encodeURIComponent(
user_email_id
Expand Down
47 changes: 47 additions & 0 deletions @app/e2e/cypress/integration/organization_create.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/// <reference types="Cypress" />

context("Create organizations", () => {
beforeEach(() => cy.serverCommand("clearTestUsers"));
beforeEach(() => cy.serverCommand("clearTestOrganizations"));

it("can create an organization", () => {
// Setup
cy.login({ next: "/", verified: true });

// Action
cy.getCy("layout-dropdown-user").trigger("mouseover");
cy.getCy("layout-link-create-organization").click();
cy.url().should("equal", Cypress.env("ROOT_URL") + "/create-organization");
cy.getCy("createorganization-input-name").type("Test Organization");
cy.getCy("createorganization-slug-value").contains("test-organization");
cy.getCy("createorganization-button-create").click();

// Assertion
cy.url().should("equal", Cypress.env("ROOT_URL") + "/o/test-organization");
cy.getCy("layout-header-title").contains("Test Organization");
cy.getCy("layout-header-titlelink")
.invoke("attr", "href")
.should("equal", "/o/test-organization");
});

it("handles conflicting organization name", () => {
// Setup
cy.login({
next: "/",
verified: true,
orgs: [["Test Organization", "test-organization"]],
});

// Action
cy.getCy("layout-dropdown-user").trigger("mouseover");
cy.getCy("layout-link-create-organization").click();
cy.url().should("equal", Cypress.env("ROOT_URL") + "/create-organization");
cy.getCy("createorganization-input-name").type("Test Organization");
cy.getCy("createorganization-slug-value").contains("test-organization");

// Assertion
cy.getCy("createorganization-hint-nameinuse").should("exist");
cy.getCy("createorganization-button-create").click();
cy.getCy("createorganization-alert-nuniq").should("exist");
});
});
61 changes: 61 additions & 0 deletions @app/e2e/cypress/integration/organization_page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/// <reference types="Cypress" />

context("Organization page", () => {
beforeEach(() => cy.serverCommand("clearTestUsers"));
beforeEach(() => cy.serverCommand("clearTestOrganizations"));

it("renders for owner", () => {
// Setup
cy.login({
next: "/o/test-organization",
verified: true,
orgs: [["Test Organization", "test-organization"]],
});

// Action

// Assertions
cy.url().should("equal", Cypress.env("ROOT_URL") + "/o/test-organization");
cy.getCy("layout-header-title").contains("Test Organization");
cy.getCy("layout-header-titlelink")
.invoke("attr", "href")
.should("equal", "/o/test-organization");
cy.getCy("organizationpage-button-settings").should("exist");
});

it("renders 404 for logged out user", () => {
// Setup
cy.login({
next: "/o/test-organization",
verified: true,
orgs: [["Test Organization", "test-organization"]],
});
cy.visit(Cypress.env("ROOT_URL") + "/logout");
cy.visit(Cypress.env("ROOT_URL") + "/o/test-organization");

// Action

// Assertions
cy.url().should("equal", Cypress.env("ROOT_URL") + "/o/test-organization");
cy.getCy("fourohfour-div").should("exist");
});

it("renders without settings link for non-owner member", () => {
// Setup
cy.login({
next: "/o/test-organization",
verified: true,
orgs: [["Test Organization", "test-organization", false]],
});

// Action

// Assertions
cy.url().should("equal", Cypress.env("ROOT_URL") + "/o/test-organization");
cy.getCy("layout-header-title").contains("Test Organization");
cy.getCy("layout-header-titlelink")
.invoke("attr", "href")
.should("equal", "/o/test-organization");
cy.getCy("organizationpage-button-settings").should("not.exist");
});
});
Loading