From cdd7569e8675edc5151b5563b856c8178c99597e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 13 Jul 2022 22:22:18 +1200 Subject: [PATCH] Contrib updates --- .gitignore | 1 + .phpunit.result.cache | 1 - CONTRIBUTING.md | 42 ++++++++++++++++++++++++++++++------------ 3 files changed, 31 insertions(+), 13 deletions(-) delete mode 100644 .phpunit.result.cache diff --git a/.gitignore b/.gitignore index cd7eb09eda..3151de5adb 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ debug/ app/sdks dev/yasd_init.php +.phpunit.result.cache diff --git a/.phpunit.result.cache b/.phpunit.result.cache deleted file mode 100644 index 50a8533bf7..0000000000 --- a/.phpunit.result.cache +++ /dev/null @@ -1 +0,0 @@ -{"version":1,"defects":{"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testCreateTeamMembership":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testGetTeam":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testGetTeamMemberships":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testGetTeamMembership":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testUpdateTeam":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testUpdateTeamMembershipRoles":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testDeleteTeamMembership":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testDeleteTeam":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreateAccountSession":4,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testGetAccountSession":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testDeleteAccountSession":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testUpdateUserEmailVerification":4,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreatePhoneVerification":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testUpdateAccountPhone":4,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testUpdateUserPhoneVerification":4,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateDatabase":4,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateCollection":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateStringAttribute":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateIntegerAttribute":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateBooleanAttribute":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateFloatAttribute":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateEmailAttribute":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateEnumAttribute":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateIPAttribute":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateURLAttribute":4,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateIndex":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateDocument":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateCustomEntity":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetDatabases":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetDatabase":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetCollections":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetCollection":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetAttributes":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetAttribute":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetIndexes":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetIndex":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetDocuments":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetDocument":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testUpdateDatabase":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testUpdateCollection":1,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testUpdateDocument":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testDeleteDatabase":4,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testDeleteCollection":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testDeleteAttribute":3,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testDeleteDocument":1},"times":{"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testCreateTeam":0.816,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testCreateTeamMembership":0.013,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testGetTeams":0.024,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testGetTeam":0.012,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testGetTeamMemberships":0.013,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testGetTeamMembership":0,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testUpdateTeam":0.008,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testUpdateTeamMembershipRoles":0,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testDeleteTeamMembership":0,"Tests\\E2E\\Services\\GraphQL\\GraphQLTeamsServerTest::testDeleteTeam":0.024,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreateAccount":0.463,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreateAccountSession":0.09,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreateMagicURLSession":0.014,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreateEmailVerification":0.025,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreatePasswordRecovery":0.02,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreateAnonymousSession":0.023,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreateAccountJWT":0.017,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testGetAccount":0.02,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testGetAccountPreferences":0.018,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testGetAccountSessions":0.013,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testGetAccountSession":0.012,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testGetAccountLogs":0.012,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testUpdateAccountName":0.024,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testUpdateAccountEmail":0.032,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testUpdateAccountPassword":0.047,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testUpdateAccountStatus":0.066,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testDeleteAccountSessions":0.065,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testDeleteAccountSession":0.063,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testCreateUser":0.451,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testGetUsers":0.023,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testGetUser":0.059,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testGetUserPreferences":0.016,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testGetUserSessions":0.012,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testGetUserMemberships":0.013,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testGetUserLogs":0.021,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testUpdateUserStatus":0.015,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testUpdateUserEmailVerification":0.02,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testUpdateUserName":0.021,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testUpdateUserEmail":0.018,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testUpdateUserPassword":0.036,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testUpdateUserPrefs":0.018,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testDeleteUserSessions":0.062,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testDeleteUserSession":0.061,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testDeleteUser":0.015,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testCreatePhoneVerification":0.023,"Tests\\E2E\\Services\\GraphQL\\GraphQLAccountTest::testUpdateAccountPhone":0.038,"Tests\\E2E\\Services\\GraphQL\\GraphQLUsersTest::testUpdateUserPhoneVerification":0.019,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateDatabase":0.753,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateCollection":0.043,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateStringAttribute":0.027,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateIntegerAttribute":0.033,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateBooleanAttribute":0.016,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateFloatAttribute":0.015,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateEmailAttribute":0.018,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateEnumAttribute":0.019,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateIPAttribute":0.017,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateURLAttribute":0.001,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateIndex":10.018,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateDocument":3.025,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testCreateCustomEntity":3.017,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetDatabases":0.013,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetDatabase":0.011,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetCollections":0.025,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetCollection":0.015,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetAttributes":5.027,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetAttribute":3.019,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetIndexes":3.016,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetIndex":3.017,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetDocuments":0.012,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testGetDocument":0.018,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testUpdateDatabase":0.028,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testUpdateCollection":0.017,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testUpdateDocument":0.019,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testDeleteDatabase":0.015,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testDeleteCollection":0.013,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testDeleteAttribute":3.022,"Tests\\E2E\\Services\\GraphQL\\GraphQLDatabaseServerTest::testDeleteDocument":0}} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cc039607f6..be2aadcd2a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,19 +51,19 @@ $ git checkout -b [name_of_your_new_branch] 4. Before you push your changes, make sure your code follows the `PSR12` coding standards , which is the standard Appwrite follows currently. You can easily do this by running the formatter. ```bash -composer format +docker run --rm --interactive --tty --volume $PWD:/app composer format ``` Now, go a step further by running the linter by the following command to manually fix the issues the formatter wasn't able to fix. ```bash -composer lint +docker run --rm --interactive --tty --volume $PWD:/app composer lint ``` This will give you a list of errors for you to rectify , if there is an instance you need more information on the errors being displayed you can pass in additional command line arguments. More list of available arguments can be found [here](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage). A very useful command line argument is `--report=diff`. This will give you the expected changes by the linter for easy fixing of formatting issues. ```bash -composer lint --report=diff +docker run --rm --interactive --tty --volume $PWD:/app composer lint --report=diff ``` 5. Push changes to GitHub @@ -187,17 +187,19 @@ Appwrite's current structure is a combination of both [Monolithic](https://en.wi ├── src # Supporting libraries (each lib has one role, common libs are released as individual projects) │ └── Appwrite │ ├── Auth -│ ├── Database │ ├── Detector │ ├── Docker +│ ├── DSN │ ├── Event │ ├── Extend +│ ├── GraphQL +│ ├── Messaging │ ├── Migration │ ├── Network │ ├── OpenSSL -│ ├── Realtime │ ├── Resque │ ├── Specification +│ ├── Stats │ ├── Task │ ├── Template │ ├── URL @@ -218,7 +220,7 @@ Although the Appwrite API is a monolithic app, it has a very clear separation of Each container in Appwrite is a microservice on its own. Each service is an independent process that can scale without regard to any of the other services. -Currently, all of the Appwrite microservices are intended to communicate using the TCP protocol over a private network. You should be aware to not expose any of the services to the public-facing network, besides the public port 80 and 443, who, by default, are used to expose the Appwrite HTTP API. +Currently, all the Appwrite microservices are intended to communicate using the TCP protocol over a private network. You should be aware to not expose any of the services to the public-facing network, besides the public port 80 and 443, who, by default, are used to expose the Appwrite HTTP API. ## Ports @@ -338,7 +340,7 @@ Things to remember when releasing SDKs Appwrite uses [yasd](https://github.com/swoole/yasd) debugger, which can be made available during build of Appwrite. You can connect to the debugger using VS Code [PHP Debug](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug) extension or if you are in PHP Storm you don't need any plugin. Below are the settings required for remote debugger connection. -First, you need to create an init file. Duplicate **dev/yasd_init.php.stub** file and name it **dev/yasd_init.php** and there change the IP address to your development machine's IP. Without the proper IP address debugger will not connect. You will also need to set **DEBUG** build arg in **appwrite** service in **docker-compose.yml** file. +First, you need to set **DEBUG** build arg in **appwrite** service in **docker-compose.yml** file. ### VS Code Launch Configuration @@ -356,7 +358,17 @@ First, you need to create an init file. Duplicate **dev/yasd_init.php.stub** fil ### PHPStorm Setup -In settings, go to **Languages & Frameworks** > **PHP** > **Debug**, there under **Xdebug** set the debug port to **9005** and enable the **can accept external connection** checkbox. +In settings, go to **PHP** > **Debug**, there under **Xdebug** set the debug port to **9005** and enable the **Can accept external connections** checkbox. + +Still in settings, got to **PHP** > **Servers** and select the **+** button to add a new server. Give the server a name and remember this for later. Then enter your host address and port. Next, enable the checkbox for **Use path mappings**. Now enter a mapping for the root of the repository to `/usr/src/code`. + +The final step is adding a new environment variable to the Appwrite server. In the **appwrite** service's environment in **docker-compose.yml**, add the following line: + +```yaml + - PHP_IDE_CONFIG=serverName=YOUR_SERVER_NAME +``` + +Replacing `YOUR_SERVER_NAME` with the name of the server you added in the previous step. ## Tests @@ -384,6 +396,12 @@ To run end-2-end tests for a specific service use: docker compose exec appwrite test /usr/src/code/tests/e2e/Services/[ServiceName] ``` +To run a single test use: + +```bash +docker compose exec appwrite test /usr/src/code/tests/.../[TestClass] --filter "[TestName]" +``` + ## Benchmarking You can use WRK Docker image to benchmark the server performance. Benchmarking is extremely useful when you want to compare how the server behaves before and after a change has been applied. Replace [APPWRITE_HOSTNAME_OR_IP] with your Appwrite server hostname or IP. Note that localhost is not accessible from inside the WRK container. @@ -413,18 +431,18 @@ We use some automation tools to help us keep a healthy codebase. ```bash # Run on all files -composer format +docker run --rm --interactive --tty --volume $PWD:/app composer format # Run on single file or folder -composer format +docker run --rm --interactive --tty --volume $PWD:/app composer format ``` **Run Linter:** ```bash # Run on all files -composer lint +docker run --rm --interactive --tty --volume $PWD:/app composer lint # Run on single file or folder -composer lint +docker run --rm --interactive --tty --volume $PWD:/app composer lint ``` ## Tutorials