mattermost / mattermost-gitpod-config

5 stars 11 forks source link

Document general usage of Gitpod #18

Open mickmister opened 2 years ago

mickmister commented 2 years ago

My workflow of doing general Git operations in Gitpod has been done using the VSCode command palette. Opening the command palette can be done by pressing Cmd Shift P. Many of these steps can be done in the terminal instead of the command palette, but these shortcuts provided by VSCode are useful when working with a multi-project workspace.

Here's my workflow:

As noted in one of the steps above, I recommend installing Gitpod as a shortcut, so you can benefit from certain keyboard shortcuts, and have the opened workspaces live in their own dedicated windows on your computer.

Something I may need to fix is it seems when opening a workspace from a plugin project (or project not listed in the additionalRepositories list), it automatically set the upstream remote of the mattermost-gitpod-config repo to the plugin project's remote. Probably not a big deal because it only seems to affect the remotes for mattermost-gitpod-config, which someone will likely not be making edits to unless they are more familiar with this sort of workflow or workarounds anyway.

mickmister commented 2 years ago

@sinansonmez I'm curious how your workflow comapares to this, and if you have any shortcuts or improvements to add/edit here. I'd eventually like this to be in a walkthrough guide or even a tutorial video.

Though a video can get outdated pretty quickly. Maybe the guide can point to the video, and mention anything that may be out of date about the video. I think a video will be the most approachable medium to someone completely new to Gitpod or development/collaboration in general. cc @azigler for thoughts on this idea

sinansonmez commented 2 years ago

@mickmister My workflow is more or less the same. However, I use the user interface of VSCode. I documented my workflow below, together with highlighting the same steps as you with SAME notation. I also attached screenshots to support documentation efforts.

Screen Shot 2022-09-03 at 09 32 48 Screen Shot 2022-09-03 at 09 33 01 Screen Shot 2022-09-03 at 09 33 12 Screen Shot 2022-09-03 at 09 33 20 Screen Shot 2022-09-03 at 09 44 16 Screen Shot 2022-09-03 at 09 33 20
mickmister commented 2 years ago

@sinansonmez Thanks for all of this awesome curated information and screenshots! I also like the idea of using a GitHub comment as an artifact of documentation efforts. Awesome job!!

mickmister commented 2 years ago

@cwarnermm @azigler The information in this issue thus far covers a chunk of the Gitpod development guide we're wanting to make. Specifically the "What to do once your in Gitpod" piece.

I see this as a "developer story" with a few parts:

We should also mention the role of the community server in our contribution process. We should encourage contributors to ask questions on the community server.

I think having this guide in place for Hacktoberfest would be a huge win

cwarnermm commented 2 years ago

Thank you, @mickmister! You've captured a wealth of great information in this issue! I agree that having this available for Hacktoberfest would be amazing.

@azigler - Do you have bandwidth to develop an initial draft of this excellent developer story in September?

azigler commented 2 years ago

Hello everyone -- @cwarnermm @mickmister @sinansonmez !

All of this information is really helpful, as someone who has not really used the Gitpod platform to try and develop for MM. I would love to make this into a video and/or guide, taking advantage of this collected knowledge and @mickmister's excellent organizing/enabling of the repos to be Gitpod-ready.

I made a card for this but have to push it out a few sprints -- currently getting developer experiences created for our fall conferences + Mattercon demo prep. Let's continue these discussions and start working on a step-by-step guide to follow? I'm going to approach it very naively, like any new developer would.

simcard0000 commented 2 years ago

Hello everyone! Just wanted to add my two cents for the workflow on Gitpod that is most intuitive for me personally. I've been tasked with creating 2 videos for Hacktoberfest: getting started with Gitpod, and walking through how to create your first E2E test (which encompasses aspects like how to pick issues and submitting PRs).

Like @sinansonmez, I use the UI of Gitpod for all operations (including Git operations) - so I don't really use the command palette. I will also preface some of my steps with SAME if they match what others have posted in this issue. The steps will be in the vein of what you would do in the second video.

Choosing an issue/ticket

  1. For finding an existing issue to work on, checking out help wanted tickets on GitHub is a good place to start. The list here is generated from these search terms: is:open archived:false org:mattermost label:"Help Wanted" label:"Up For Grabs".

  2. You can also see a lot of issues that need help specifically in the issues tab of the mattermost-server repository and filtering with these search terms: is:issue is:open label:"Help Wanted" label:"Up For Grabs". At the top of this page are three pinned issues: Mattermost Plugins: Help Wanted tickets, 🎯 Focalboard: Help wanted tickets, and 📋 Playbooks: Help-wanted Tickets, which are portals to finding issues that relate to those projects respectively.

mattermost-server e2e issues

  1. Once you find an issue you would like to work on (for example, Write Webapp E2E with Cypress: "MM-T642 Attachment does not collapse" #18184 that's been claimed by me), comment on the issue to claim it. For finding E2E issues specifically, try appending on another search term to filtering, like e2e.

  2. An E2E ticket will have the following format:

    • Steps: what the code in the test should do/emulate
    • Expected: what the results of the test should be
    • Test Folder: where the file that holds the test code should be
    • Test code arrangement: starter code for the test
    • Notes: comments on what not to add to the test file, plus resources for contributing, asking questions, and writing code

Starting up Gitpod

  1. SAME I create a new workspace for a ticket/issue by going to the mattermost-config-repo and clicking the "Open in Gitpod" badge.

    • I also have the Gitpod extension in my Firefox browser (because that's simpler than manually prefixing GitHub repository URLs with gitpod.io/#), if the repository that needs to be worked on is not mattermost-server, mattermost-webapp, or mattermost-plugin-apps. What the extension does is add a green Gitpod button to repository pages on GitHub, and clicking it spins up a new environment for the repository on Gitpod.

mattermost-gitpod-config-repo

  1. You may need to sign in (through GitHub) to access the workspace on GitPod. Once Gitpod has done loading, the user interface presented is that of VSCode. [In my first video, I will be going over the main parts of the IDE, and what has started up, but I won't explain that here.]

mattermost-gitpod-intro

Working on an issue/ticket

  1. SAME Make changes to one of the projects. In the context of the issue that I picked:

    • End-to-end (E2E) integration tests is where software gets checked from the perspective of the user (behavioral flow), whereas with unit testing software components are tested individually. E2E tests in Mattermost are written using Cypress and Playwright; for this issue, we will only need to use Cypress. Cypress documentation can be accessed here, as well as cheatsheets for how to use functions that are common in other Cypress tests in Mattermost repositories.

    • Navigate to the folder where the test file should be, as specified in the Test Folder section of the issue. This would be: mattermost-webapp > e2e > cypress > tests > integration > integrations > incoming_webhook. All tests live inside the ... > e2e > cypress > tests > integration folder.

mattermost-gitpod-editing-file

  1. We can check the test that's been written as follows:

    • In Gitpod, the server and the webapp should still be running. However, you can also run make test-data in the terminal for the mattermost-server repository to preload your server instance with initial seed data.

    • Next, in the terminal for the mattermost-webapp repository, enter the directory mattermost-webapp/e2e/cypress using the cd command, and then run npm i, which will install more dependencies needed for testing.

    • To run all E2E tests, run npm run cypress:run in the terminal for the mattermost-webapp repository. This does not include the spec files in the /cypress/tests/integration/enterprise folder because they need an Enterprise license to run successfully.

mattermost-gitpod-test-passed

  1. Finally, we need to make sure that our code is formatted properly. We can check this by running the command npm run check in the terminal for the mattermost-webapp repository. If there are any problems, we can either fix them manually in the file itself, or use the npm run fix command. This is an important step because if any code is not formatted properly, one of the checks that run when you create a pull request for your branch will fail, and may block merging.

Creating a new branch on your own fork

  1. SAME You most likely won't have direct write access to the repository you are working on. Thus, you will need to bring the changes you've made over from the master or main branch to a new branch on your own fork of the repository.

    • SAME Click the "Source Control" icon on the left sidebar. On the panel next to the side bar, you will see a list of the repositories in the workspace, and under each repository a list of the files that have changed (if any). Next to the label for mattermost-webapp, click the button with the branch name and the source control icon.

    • SAME A dropdown will appear via the command palette. Click the option that says: "+ Create new branch..."

mattermost-gitpod-new-branch

mattermost-gitpod-branch-name

mattermost-gitpod-commit-message

mattermost-gitpod-make-fork

mattermost-gitpod-sign-into-GitHub

   - You may also be asked to update the permissions you give Gitpod to access GitHub through a popup. If this happens, you will have to restart the fork creation process (publish branch -> say yes to creating a fork). Click the "open access control" button on the popup.

mattermost-gitpod-need-perms

   - You will get taken to the Integration section of Gitpod's settings. In the list of Git Providers on the page, find GitHub, click the three dots next to the listing, and select "Edit Permissions" from the dropdown menu.

mattermost-gitpod-open-perms

   - A popup will appear with a list of permission checkboxes. It's a good idea to check all of them off so you don't need to go through this process again. When you're done checking off the permissions, click the "Update Permissions" button.

mattermost-gitpod-select-perms

   - Another tab might also appear where on GitHub's end you accept the additional permissions Gitpod is requesting. Click on the "authorize gitpod-io" button.

mattermost-gitpod-confirm-perms

mattermost-gitpod-open-fork-on-GitHub

Creating a Pull Request

  1. You'll get taken to Github, to the fork of the repository you've worked on in your account instead of the main one in the Mattermost organization. Navigate to the branch you've made on your fork if you're not there already.

    • Near the top of the page will be a bar mentioning how many commits ahead/behind your branch is from the master/main branch of the main repository. There will also be two buttons: "contribute" and "sync fork". Click on the "contribute" button, and in the dropdown that appears, click the "open pull request" button.

mattermost-gitpod-create-PR-on-GitHub

  1. You'll be taken to another page on GitHub called "Open a pull request".

mattermost-gitpod-PR-creation-page

  1. Once you've created your pull request, you'll get taken to it's page, like this one: MM-T642: Attachment does not collapse - Cypress Webapp E2E Test #11231. Below your initial body text of the PR will be a list of commits and other comments. At the end of this list is a checklist which notes the status of reviews required for the pull request, and the checks that the pull request must pass, plus a place to write your own additional comments.

mattermost-gitpod-real-PR-1

Code Review

Information from this section comes from: Code review at Mattermost

  1. Wait for a reviewer to be assigned - normally this is handled automatically, but if you need help feel free to ask for help in the Developers channel of the Mattermost community server.

  2. Wait for a review - if a reviewer requests changes, your PR will disappear from their queue of reviews. Once you've addressed the concerns, re-request a review from any person requesting changes. Avoid force pushing, which is the act of overwriting the commit history on the remote with what you have on local.

  3. Once all reviewers approve your pull request, they will handle the merging of your code. ✔️

This is a pretty long-winded post, but can hopefully serve as the basis of a blog post or an article for reference. If there is anything wrong with this post (spelling, grammar, or content-wise), please let me know.

simcard0000 commented 2 years ago

Edit 1 for this comment: looks like based on this issue (https://github.com/mattermost/mattermost-gitpod-config/issues/20) working on focalboard is not supported yet.

simcard0000 commented 2 years ago

Also tagging @cwarnermm @mickmister and @azigler for visibility 📣

sinansonmez commented 2 years ago

thanks @simcard0000 super detailed guide.

Currently, I am having trouble when I do npm i in e2e/cypress folder. It got stuck at some point and no progress.

I already to tried to delete node-modules folder and package-lock.json but no luck. Any idea why this is happening and how I can overcome this issue?

edit: it was fixed after waiting long time

simcard0000 commented 2 years ago

@sinansonmez Good to know! Let me know if anything else comes up :)

sinansonmez commented 2 years ago

One more thing to be added to guide. Please see @mickmister detailed explanation https://github.com/mattermost/mattermost-gitpod-config/pull/10#issuecomment-1223523082

mickmister commented 2 years ago

@simcard0000 Absolutely amazing work on this!!!! I'm wondering how this can be laid out in our docs in a digestible format as there is a lot of information to take in here. Maybe spread the content out into multiple pages? Or one large page with table of contents? It would be much easier to review the content if it were put into a PR, but I think we should determine the format we want it to exist in the docs first. @cwarnermm What are your thoughts on the format we can approach here?

@simcard0000 @sinansonmez Since this guide incorporates e2e testing, I'm wondering if we should add some more automation in the workspace creation process for e2e tests specifically. This would include instantiating a terminal for the e2e folder, and fetching dependencies during workspace creation. Possibly even running the cypress process and outputting in the console how to access the cypress window (or in a welcome page https://github.com/mattermost/mattermost-gitpod-config/issues/22). Though auto-running e2e processes could put unnecessary load on the workspace if the dev is not going to be interacting with e2e tests.

Something I want to include in the guide is the default login that is made when the workspace runs make test-data. User: sysadmin Password: Sys@dmin-sample1. I've been wondering how new devs have been figuring out this login info.

sinansonmez commented 2 years ago

I've been wondering how new devs have been figuring out this login info.

@mickmister After make test-data command is completed, username and password information is provided to the developer like below

Screen Shot 2022-10-13 at 22 29 44
mickmister commented 2 years ago

In the Gitpod workspace creation process, this command is run automatically, and more commands are run afterwards, so this output is sort of buried in the terminal's logs. I'm thinking it would be beneficial to have these credentials more visible for Gitpod docs specifically for this reason

saturninoabril commented 2 years ago

@simcard0000 This is so great! For https://github.com/mattermost/mattermost-gitpod-config/pull/10#issuecomment-1223523082, you may look at https://community.mattermost.com/core/pl/ju6npwippjbhbpduz96mj8i8ah. I was planning to do it at one point but if you'd like to add in the docs, it would be so nice. Otherwise, I'll help add in the future once the docs/format has been decided/merged.

simcard0000 commented 2 years ago

@mickmister Thanks for the feedback!

@saturninoabril made note of that thread! I think it would be good to add it to what I wrote

cwarnermm commented 2 years ago

Huge +1 to this great information being incorporated into the developer documentation! @simcard0000 Really great work on this! The content and the way you've chunked up the process into bite-sized steps is perfect for inclusion in the docs as individual pages:

Develop using GitPod (open to ideas on this title!)

"issue" versus "ticket" - let's pick one term to use consistently. Which one resonates more with our target audiences?

@simcard0000 - Let either myself or @neflyte know how best we can assist you with this effort.

simcard0000 commented 1 year ago

Check out: https://github.com/mattermost/mattermost-developer-documentation/pull/1170 (first pass at it) 🎊