diff --git a/docs/ci_cd.md b/docs/ci_cd.md index f52b9efb..52d1f42e 100644 --- a/docs/ci_cd.md +++ b/docs/ci_cd.md @@ -1,60 +1,109 @@ -# Continuous Integration and Deployment - -This GitHub Actions workflow automates testing, code quality checks, and deployment to platform.sh. - -## Trigger - -The CI workflow is triggered by: - -- Push events to the `main` branch. -- Push events creating new tags. -- Pull request events. - -## Concurrency Control - -The workflow ensures concurrency control, allowing only one workflow run per branch/tag. It cancels in-progress runs if a new run is triggered. - -## Jobs - -Each job checks out the repository code using [actions/checkout](https://github.com/actions/checkout) and performs caching with [actions/cache](https://github.com/actions/cache) to optimize subsequent runs. - -### 1. Drupal Code Quality (`drupal_codequality`) - -**Intent:** Ensure Drupal code quality. - -**Description:** Uses GrumPHP to perform code quality checks on the Drupal codebase, ensuring adherence to our predefined standards. We use [axelerant/drupal-quality-checker](https://github.com/axelerant/drupal-quality-checker) for local checks, so we apply the same configuration in CI to maintain consistency. - -### 2. Frontend Code Quality (`frontend_codequality`) - -**Intent:** Ensure frontend code quality. - -**Description:** This job runs linting checks on JavaScript and other frontend code to maintain code quality and consistency. - -### 3. Drupal Test (`drupal_test`) - -**Intent:** Run comprehensive tests on the Drupal site. - -**Description:** This job sets up the ddev environment in CI to replicate the local development environment. It performs the following tests: -- **Unit Tests with DTT:** Ensures individual units of code work as expected. -- **PHPStan Checks:** Static analysis to find errors in code without running it. -- **Cypress Tests:** End-to-end testing to ensure functionalities work. Integrated with Percy for Visual Testing. - -**Note:** -- We spin up ddev in CI to ensure a consistent environment with our local development setup. This is necessary because we need a site running for Cypress tests and Drupal test traits. -- PHPStan checks are included in this job and not part of the `drupal_codequality` job because it requires all dependencies to be present. - -### 4. Deploy (`deploy`) - -**Intent:** Deploy code to platform.sh. - -**Description:** This job deploys code to platform.sh based on the branch (`main` for production, others for feature environments). It ensures that only code passing the `drupal_codequality` and `drupal_test` jobs is deployed. Dependabot PRs are excluded from deployment. - -## References - -- [Events that trigger workflows](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows) -- [Caching dependencies](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows) -- [Drupal Quality Checker](https://github.com/axelerant/drupal-quality-checker) -- [Defining outputs for jobs](https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs) -- [Storing workflow data as artifacts](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) -- [Using Secrets in GitHub Actions](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) -- [Example Workflows](https://github.com/actions/starter-workflows) +# CI/CD Documentation + +This document outlines the Continuous Integration and Continuous Delivery (CI/CD) workflows implemented in this project. These workflows are designed to automate testing, code quality checks, and environment management, facilitating a robust and efficient development lifecycle. + +## Workflow Overview + +This project leverages GitHub Actions for CI/CD. Workflow definitions are located in the `.github/workflows` directory within the repository. Each workflow addresses a specific aspect of the software development lifecycle, from code quality assurance to environment cleanup. + +## Workflow Details + +### 1. Visual Regression Testing (VR) Workflow + +* **File:** `.github/workflows/vr.yml` +* **Purpose:** Executes visual regression tests to detect unintended visual changes in the application. This helps ensure a consistent user interface across deployments. +* **Triggers:** + * `push` events on tags (`*`): Triggers when a new tag is pushed to the repository, typically indicating a release. + * `workflow_dispatch`: Allows manual triggering of the workflow from the GitHub Actions UI. This is useful for on-demand testing. + * `schedule` (cron: `0 0 * * MON`): Runs the workflow every Monday at midnight (UTC). This provides regular visual regression testing. +* **Concurrency:** Prevents concurrent VR test runs using `vr-${{ github.ref }}`. This ensures that tests are executed in isolation and avoids potential conflicts. +* **Job:** `vr_test` + * **Runs On:** `ubuntu-latest` (latest version of Ubuntu runner). + * **Environment Variables:** Configures environment variables required for the test execution. + * `CYPRESS_ADMIN_USERNAME`: Username for the administrative user in the Cypress testing environment. + * `CYPRESS_ADMIN_PASSWORD`: Password for the administrative user in the Cypress testing environment. + * `PERCY_TOKEN`: API token for authenticating with the Percy visual regression testing platform. This is retrieved from GitHub secrets for security. + * **Steps:** + 1. **Checkout Code:** Checkouts the repository code using `actions/checkout@v4`, making the project code available to the workflow. + 2. **Determine Cache Directories:** This step identifies cache directories for Composer and npm, optimizing dependency management for subsequent runs by storing and retrieving cached dependencies. + +### 2. Pull Request Close Workflow + +* **File:** `.github/workflows/pr-close.yml` +* **Purpose:** Cleans up Platform.sh environments that were provisioned for pull request testing. This helps to minimize resource usage and avoid unnecessary costs. +* **Triggers:** `pull_request` events with `types: [closed]`: Triggers when a pull request is closed (either merged or closed without merging). +* **Job:** `on-pr-close` + * **Runs On:** `ubuntu-latest` + * **Steps:** + 1. **Clean PR Environment:** Utilizes the `axelerant/platformsh-action@v1` action with the `clean-pr-env` parameter. This action automatically removes the Platform.sh environment associated with the closed pull request. The workflow requires the following parameters: + * `project-id`: The Platform.sh project ID. Often configured within the repository settings or workflow file (refer to Axelerant's documentation for specifics) + * `cli-token`: A Platform.sh CLI token with appropriate permissions. This token is securely stored as a GitHub secret (`secrets.PLATFORMSH_CLI_TOKEN`). + +### 3. Cypress Tests Workflow + +* **File:** `.github/workflows/cypress-tests.yml` +* **Purpose:** Executes end-to-end (E2E) tests using Cypress. These tests simulate user interactions with the application, verifying its functionality and behavior. +* **Triggers:** `schedule` (cron: `0 0 * * 0`): Runs the workflow every Sunday at midnight (UTC). This ensures that E2E tests are performed regularly. +* **Job:** `cypress_tests` + * **Runs On:** `ubuntu-latest` + * **Environment Variables:** + * `CYPRESS_ADMIN_USERNAME`: Username for the administrative user in the Cypress testing environment. + * `CYPRESS_ADMIN_PASSWORD`: Password for the administrative user in the Cypress testing environment. + * **Steps:** + 1. **Checkout Code:** Checkouts the repository code. + 2. **Setup DDEV:** Sets up DDEV (a local development environment tool) using the `ddev/github-action-setup-ddev@v1` action. + 3. **Configure DDEV:** Configures DDEV to include the Platform.sh token using `ddev config global`. This allows DDEV to interact with Platform.sh during testing. + 4. **Install Dependencies and Start DDEV:** Installs Composer dependencies using `ddev composer install` and starts the DDEV environment using `ddev`. + +### 4. Continuous Integration (CI) Workflow + +* **File:** `.github/workflows/ci.yml` +* **Purpose:** Performs code quality checks to ensure that the codebase adheres to defined coding standards and best practices. +* **Triggers:** + * `push` events on the `main` branch and tags (`*`): Triggers when changes are pushed to the main branch or when a tag is created. + * `pull_request`: Triggers when a pull request is opened, updated, or synchronized. +* **Concurrency:** Prevents concurrent CI runs using `${{ github.ref }}`. +* **Jobs:** + * `drupal_codequality`: Performs Drupal-specific code quality checks. + * **Uses:** `hussainweb/drupalqa-action@v2` (a GitHub Action designed for Drupal code quality). + * **PHP Version:** Specifies PHP version 8.2 for the code analysis. + * **GrumPHP Configuration:** Configures code quality checks using GrumPHP, including: + * `phplint`: Checks for PHP syntax errors. + * `yamllint`: Checks for YAML syntax errors and formatting issues. + * `jsonlint`: Checks for JSON syntax errors and formatting issues. + * `phpcs`: Checks for PHP coding standard violations using PHP_CodeSniffer. + * `phpmd`: Performs static analysis of PHP code using PHP Mess Detector. + * `twigcs`: Checks for coding standards violations in Twig templates. + * `frontend_codequality`: Performs frontend code quality checks. + * **Container:** Uses a `node:18` container to provide a Node.js environment for the checks. + * **Steps:** + 1. `npm install`: Installs Node.js dependencies. + 2. Runs linting processes (details of specific linting tools and configurations should be found within the `package.json` file or related configuration files in the project repository, for example: ESLint, stylelint). + +## Secrets + +The workflows utilize GitHub secrets for storing sensitive information, enhancing security: + +* `PERCY_TOKEN`: API token for authenticating with the Percy visual regression testing platform. +* `PLATFORMSH_CLI_TOKEN`: A Platform.sh CLI token used for interacting with the Platform.sh API. This secret should have the necessary permissions to manage environments. + +## Dependencies + +The CI/CD workflows rely on several key dependencies: + +* **GitHub Actions:** The underlying platform for workflow execution. +* **Community Actions:** Reusable actions from the GitHub Marketplace that simplify common tasks (e.g., `actions/checkout@v4`, `axelerant/platformsh-action@v1`, `hussainweb/drupalqa-action@v2`, `ddev/github-action-setup-ddev@v1`). +* **DDEV:** A local development environment tool used to configure and manage the testing environment within the CI workflows. +* **Platform.sh:** A cloud hosting platform used for environment management, particularly for pull request environments. +* **GrumPHP:** A PHP task runner used for automating code quality checks in Drupal projects. +* **Node.js/npm:** A javascript runtime environment and package manager, both of which are used for Frontend Code Quality Checks. +* **Composer:** A dependency manager for PHP used to managing project dependencies. + +## Interactions + +The workflows interact with the following services and tools: + +* **GitHub:** Provides source code management, workflow execution, and secure secret storage. +* **Platform.sh:** Provides cloud hosting and environment management. +* **Percy:** A visual regression testing platform. +* **DDEV:** A local development environment platform. \ No newline at end of file diff --git a/docs/content_structure.md b/docs/content_structure.md index a00388b3..438d9be9 100644 --- a/docs/content_structure.md +++ b/docs/content_structure.md @@ -1,84 +1,148 @@ -# Content Structure +# Content Structure Documentation + +This documentation outlines the content structure of the Drupal project, focusing on content types and their configurations, to help manage and display content effectively. ## Content Types -ContribTracker project contains the following content types: - -### Basic page - -- **Description**: Use the Basic page content type for static content such as 'About us' pages, providing essential, unchanging information about organization or website purpose. -- **Fields Used**: the most common field body is used. - -### Code contributions - -- **Description**: Use the Code contributions content type to document various code-related contributions, capturing patches, code updates, and improvements made by contributors. -- **Fields used**: - - Contribution Author (field_contribution_author): References the user who authored the contribution. - - Contribution Date (field_contribution_date): The date the contribution was made. - - Contribution Details (field_contribution_description): A long, formatted text field describing the contribution. - - Contribution Issue Link (field_code_contrib_issue_link): References the related issue content type for the contribution. - - Contribution Link (field_code_contrib_link): A URL link associated with the contribution. - - Contribution Project (field_code_contrib_project): References the project taxonomy term associated with the contribution. - - Contribution Type (field_contribution_type): References the contribution type from the Contribution Type taxonomy. - - Files Count (field_code_contrib_files_count): Number of files included in the contribution. - - Issue Status (field_code_contrib_issue_status): Text list field indicating the current status of the related issue. - - Moderator Comments (field_contrib_moderator_comment): Formatted text field for comments by the moderator. - - Patches Count (field_code_contrib_patches_count): Number of patches included in the contribution. - - Technology (field_contribution_technology): References the technology taxonomy term related to the contribution. - -### Event - -- **Description**: Use the Event content type to create and manage events, specifying details like date, location, and description for organizational or community activities. -- **Fields used**: - - Active Event (field_event_active): Indicates whether the event is currently active or inactive (Boolean). - - Description (body): A detailed, formatted text field with a summary to describe the event. - - Event Additional Links (field_event_additional_links): URLs for additional information or resources related to the event. - - Event Address (field_event_address): The physical address where the event will take place. - - Event Dates (field_event_dates): The start and end dates (and times) for the event. - - Event Link (field_event_link): A primary URL link associated with the event. - - Event Location (field_event_location): Geographical coordinates (latitude and longitude) of the event’s location. - - Event Type (field_event_contrib_event_type): References the type of event, categorized by terms from the Event Type taxonomy. - -### Event Contribution - -- **Description**: Use the Event contributions content type to document contributions made during events, including presentations, workshops, or collaborative efforts. -- **Fields used**: - - Contributor (field_contribution_author): References the user who submitted the contribution. - - Contribution Details (field_contribution_comments): Allows detailed explanations about the contribution using formatted text. - - Submission Date (field_contribution_date): Records the date and time the contribution was submitted. - - Contribution Type (field_event_contribution_type): Categorizes the contribution using predefined types from the "Event Contribution Type" vocabulary (e.g., Bug Fix, Feature Request). - - Linked Event (field_event): References the specific event this contribution is associated with. - - External Link (field_event_contribution_link): (Optional) Provides a link to an external resource related to the contribution (e.g., code repository, documentation). - - Moderator Notes (field_contrib_moderator_comment): Allows moderators to leave feedback on the contribution using formatted text. - - Technology Used (field_contribution_technology): Tags the contribution with relevant technologies (e.g., Programming Language, Framework) using terms from the "Technology" vocabulary. - -### Issue - -- **Description**: Use the Issue content type to create and track new issues, including bugs, tasks, and feature requests, facilitating project management and problem resolution. -- **Fields used**: - - Issue Description (body): A long, formatted text field with a summary for describing the issue. - - Link (field_issue_link): A URL link associated with the issue. - -### Non Code Contributions - -- **Description**: Use the Non code contributions content type to capture and recognize contributions that are not code-related, such as documentation, design, or community support. -- **Fields used**: - - Contribution Author (field_contribution_author): References the user who authored the contribution. - - Contribution Comments (field_contribution_comments): A long, formatted text field for comments on the contribution. - - Contribution Date (field_contribution_date): The date the contribution was made. - - Credit (field_non_code_contrib_credit): Integer field indicating the amount of credit for the contribution. - - Moderator Comments (field_contrib_moderator_comment): Formatted text field for comments by the moderator. - - Profile (field_non_code_contrib_profile): A URL link to the contributor's profile. - - Technology (field_contribution_technology): References the technology taxonomy term related to the contribution. - - Type (field_non_code_contribution_type): Text list field indicating the type of non-code contribution. - -## Taxonomy - -ContribTracker project possesses the following taxonomy vocabularies/terms: - -- **Contribution Type**: This vocabulary stores various contribution types, such as submitting patches, porting modules, to categorize and manage different forms of contributions efficiently. -- **Event Contribution Type**: This vocabulary stores types of event contributions, like sessions, volunteering, and training, to classify and organize different activities and roles within events. -- **Event Type**: This vocabulary categorizes event types, such as DrupalCamps, DrupalCons, and meetups, to help organize and differentiate between various kinds of events. -- **Project**: Stores projects related to community contributions, allowing for the organization and classification of different community-driven initiatives and development efforts. -- **Tags**: Use tags to categorize articles on similar topics, facilitating easy grouping and retrieval of related content across the site. -- **Technology**: This vocabulary stores various technologies used in contributions, aiding in the classification and organization of contributions by the technology they involve. +The project utilizes several content types to represent different kinds of contributions and site content. Each content type definition includes a description of its purpose and a list of Drupal configuration files that define its structure and behavior. + +### 1. Basic Page + +* **Purpose:** For static content such as "About Us" pages. +* **Description:** This content type is designed for creating standard informational pages that are not dynamically updated. +* **Configuration Files:** + * `config/sync/node.type.page.yml`: Defines the content type itself. + * `config/sync/core.entity_view_display.node.page.default.yml`: Defines the default view display of the content type. + * `config/sync/core.entity_view_display.node.page.teaser.yml`: Defines the teaser view display of the content type. + * `config/sync/core.entity_form_display.node.page.default.yml`: Defines the default form display for creating/editing content of this type. + * `config/sync/core.base_field_override.node.page.promote.yml`: Overrides the base field settings for the 'promote to front page' option. + +### 2. Non-Code Contributions + +* **Purpose:** Captures contributions not involving code. +* **Description:** This content type is designed for tracking contributions to the project that do not involve writing code, such as writing blog posts, answering questions on Stack Overflow, or contributing to localization efforts. +* **Fields:** + * Contribution Type (blog, Stack Overflow, localization) + * Author + * Technology + * Date + * Comments + * Profile Link + * Credit +* **Configuration Files:** + * `config/sync/node.type.non_code_contribution.yml`: Defines the content type itself. + * `config/sync/field.storage.node.field_non_code_contribution_type.yml`: Defines the storage for the Contribution Type field. + * `config/sync/field.storage.node.field_non_code_contrib_profile.yml`: Defines the storage for the Profile Link field. + * `config/sync/field.storage.node.field_non_code_contrib_credit.yml`: Defines the storage for the Credit field. + * `config/sync/field.field.node.non_code_contribution.field_non_code_contribution_type.yml`: Defines the field settings for the Contribution Type field. + * `config/sync/field.field.node.non_code_contribution.field_non_code_contrib_profile.yml`: Defines the field settings for the Profile Link field. + * `config/sync/field.field.node.non_code_contribution.field_non_code_contrib_credit.yml`: Defines the field settings for the Credit field. + * `config/sync/core.entity_view_display.node.non_code_contribution.default.yml`: Defines the default view display. + * `config/sync/core.entity_view_display.node.non_code_contribution.teaser.yml`: Defines the teaser view display. + * `config/sync/core.entity_form_display.node.non_code_contribution.default.yml`: Defines the default form display. + * `config/sync/core.base_field_override.node.non_code_contribution.promote.yml`: Overrides the base field settings for the 'promote to front page' option. + +### 3. Issue + +* **Purpose:** Represents bugs, tasks, or feature requests, mainly for linking to code contributions. +* **Description:** This content type is designed to track and manage issues related to the project, and is often linked to specific code contributions that address these issues. +* **Fields:** + * Link to the issue + * Description +* **Configuration Files:** + * `config/sync/node.type.issue.yml`: Defines the content type itself. + * `config/sync/field.storage.node.field_issue_link.yml`: Defines the storage for the Issue Link field. + * `config/sync/field.field.node.issue.field_issue_link.yml`: Defines the field settings for the Issue Link field. + * `config/sync/field.field.node.issue.body.yml`: Defines the field settings for the body (description) field. + * `config/sync/core.entity_view_display.node.issue.default.yml`: Defines the default view display. + * `config/sync/core.entity_view_display.node.issue.teaser.yml`: Defines the teaser view display. + * `config/sync/core.entity_form_display.node.issue.default.yml`: Defines the default form display. + * `config/sync/core.base_field_override.node.issue.promote.yml`: Overrides the base field settings for the 'promote to front page' option. + * `config/sync/core.entity_form_mode.node.inline_issue_create.yml`: Defines the form mode for inline issue creation. + * `config/sync/core.entity_form_display.node.issue.inline_issue_create.yml`: Defines the form display for the inline issue creation form mode. + +### 4. Event Contributions + +* **Purpose:** Captures contributions made during events. +* **Description:** Used to document contributions, such as code sprints or documentation sessions, that occur at specific events. +* **Fields:** + * Contribution Type + * Author + * Technology + * Event + * Event Contribution Link + * Date +* **Configuration Files:** + * `config/sync/node.type.event_contribution.yml`: Defines the content type itself. + * `config/sync/field.storage.node.field_event_contribution_type.yml`: Defines the storage for the Contribution Type field. + * `config/sync/field.storage.node.field_event_contribution_link.yml`: Defines the storage for the Event Contribution Link field. + * `config/sync/field.field.node.event_contribution.field_event_contribution_type.yml`: Defines the field settings for the Contribution Type field. + * `config/sync/field.field.node.event_contribution.field_event_contribution_link.yml`: Defines the field settings for the Event Contribution Link field. + * `config/sync/field.field.node.event_contribution.field_event.yml`: Defines the field settings for the Event reference field. + * `config/sync/core.entity_view_display.node.event_contribution.default.yml`: Defines the default view display. + * `config/sync/core.entity_view_display.node.event_contribution.teaser.yml`: Defines the teaser view display. + * `config/sync/core.entity_form_display.node.event_contribution.default.yml`: Defines the default form display. + * `config/sync/core.base_field_override.node.event_contribution.title.yml`: Overrides the base field settings for the title field. + * `config/sync/core.base_field_override.node.event_contribution.promote.yml`: Overrides the base field settings for the 'promote to front page' option. + * `config/sync/field.field.node.event_contribution.field_contrib_moderator_comment.yml`: Defines the field for moderator comments. + * `config/sync/field.field.node.event_contribution.field_contribution_author.yml`: Defines the field for the contribution author. + * `config/sync/field.field.node.event_contribution.field_contribution_comments.yml`: Defines the field for contribution comments. + * `config/sync/field.field.node.event_contribution.field_contribution_date.yml`: Defines the field for the contribution date. + * `config/sync/field.field.node.event_contribution.field_contribution_technology.yml`: Defines the field for the contribution technology. + + +### 5. Event + +* **Purpose:** Represents events that can be referenced by Event Contributions. +* **Description:** Used to store information about events, such as conferences, workshops, or meetups. This allows Event Contribution nodes to easily link and refer to specific events. +* **Fields:** + * Event Dates + * Address + * Link + * Event Type + * Active Status +* **Configuration Files:** + * `config/sync/node.type.event.yml`: Defines the content type itself. + * `config/sync/field.storage.node.field_event_dates.yml`: Defines the storage for the Event Dates field. + * `config/sync/field.storage.node.field_event_address.yml`: Defines the storage for the Event Address field. + * `config/sync/field.field.node.event.field_event_dates.yml`: Defines the field settings for the Event Dates field. + * `config/sync/field.field.node.event.field_event_address.yml`: Defines the field settings for the Event Address field. + * `config/sync/core.entity_view_display.node.event.default.yml`: Defines the default view display. + * `config/sync/core.entity_view_display.node.event.teaser.yml`: Defines the teaser view display. + * `config/sync/core.entity_form_display.node.event.default.yml`: Defines the default form display. + * `config/sync/core.base_field_override.node.event.promote.yml`: Overrides the base field settings for the 'promote to front page' option. + * `config/sync/field.storage.node.field_event_link.yml`: Defines the storage for the Event Link field. + * `config/sync/field.storage.node.field_event_contrib_event_type.yml`: Defines the storage for the Event Type field. + * `config/sync/field.storage.node.field_event_additional_links.yml`: Defines the storage for additional links related to the event. + * `config/sync/field.storage.node.field_event_location.yml`: Defines the storage for the Event Location field. + * `config/sync/field.field.node.event.field_event_link.yml`: Defines the field settings for the Event Link field. + * `config/sync/field.field.node.event.field_event_contrib_event_type.yml`: Defines the field settings for the Event Type field. + * `config/sync/field.field.node.event.field_event_additional_links.yml`: Defines the field settings for the Additional Event Links field. + * `config/sync/field.field.node.event.field_event_location.yml`: Defines the field settings for the Event Location field. + * `config/sync/field.storage.node.field_event_active.yml`: Defines the storage for the active status of the event. + * `config/sync/field.field.node.event.field_event_active.yml`: Defines the field settings for the Event Active field. + * `config/sync/field.field.node.event.body.yml`: Defines the field settings for the body (description) field. + +### 6. Code Contributions + +* **Purpose:** For capturing code contributions. +* **Description:** Designed to record and manage contributions specifically related to code development, such as patches, modules, or themes. +* **Fields:** + * Contribution Link + * Issue Link + * Project + * Technology + * Patches/Files Count + * Issue Status + * Description +* **Configuration Files:** + * `config/sync/node.type.code_contribution.yml`: Defines the content type itself. + * `config/sync/field.storage.node.field_code_contrib_link.yml`: Defines the storage for the Contribution Link field. + * `config/sync/field.field.node.code_contribution.field_code_contrib_link.yml`: Defines the field settings for the Contribution Link field. + * `config/sync/core.entity_view_display.node.code_contribution.default.yml`: Defines the default view display. + * `config/sync/core.entity_view_display.node.code_contribution.teaser.yml`: Defines the teaser view display. + * `config/sync/core.entity_form_display.node.code_contribution.default.yml`: Defines the default form display. + * `config/sync/core.base_field_override.node.code_contribution.promote.yml`: Overrides the base field settings for the 'promote to front page' option. + * `config/sync/field.storage.node.field_code_contrib_issue_link.yml`: Defines the storage for the Issue Link field. + * `config/sync/field.field.node.code_contribution.field_code_contrib_issue_link.yml`: Defines the field settings for the Issue Link field. + * `config/sync/core.entity_form_mode.node.inline_issue_create.yml`: Defines the form mode for inline issue creation. \ No newline at end of file diff --git a/docs/custom_modules.md b/docs/custom_modules.md index a9eab5c1..8768ecd5 100644 --- a/docs/custom_modules.md +++ b/docs/custom_modules.md @@ -1,75 +1,106 @@ -# Custom Modules and Themes +# Contrib Tracker Project - Custom Modules Documentation -## Custom Modules +This document provides a comprehensive overview of the custom modules developed for the Contrib Tracker project. It aims to facilitate onboarding for new developers and serve as a reference for existing team members. -The custom modules used for this project are: +## Module Overview -### [Contribution Plugin Manager](https://github.com/contrib-tracker/backend/tree/main/web/modules/custom/ct_manager) +The Contrib Tracker project utilizes several custom modules to manage and track contributions within the Drupal ecosystem. These modules are designed to work together to provide a cohesive and efficient contribution tracking system. -- The Contribution Plugin Manager module (ct_manager) is designed to manage and track user contributions from various sources through a plugin-based system. Its primary purpose is to process contributions asynchronously and efficiently using Drupal's queue system and send notifications for recent contributions. +## Module Details -- This module provides functionality to create custom plugins of type `ContributionSource`, which allows for tracking and storing contributions from different sources. When Drupal's cron runs, the module looks for `ContributionSource` plugins, creates instances of each, and processes the associated users. Each user's contributions are tracked, stored in the database, and notifications are sent to a Slack channel for contributions posted within the last hour. The `ContributionSource` plugin is also implemented by `ct_drupal` and `ct_github`. +### 1. Contrib Tracker Module (`contrib_tracker`) -- To add a new contribution source, we can create a plugin with the ContributionSource annotation, implementing the `ContributionSourceInterface` and its methods as needed. The main components of this module include `ct_manager.module`, which executes actions during cron runs, creating instances of plugins and queuing users for processing; `ContributionSourceInterface`, which defines the functions for the plugins; and `ProcessUsers`, which handles the tracking and storage of contributions and sends Slack notifications. +* **Description:** This module serves as the foundation for the Contrib Tracker project, providing core functionality related to contribution tracking. See [`contrib_tracker.info.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/contrib_tracker/contrib_tracker.info.yml). -- To send Slack notifications, it uses the contributed module - [Slack](https://www.drupal.org/slack). +* **Functionality:** -### [Drupal Contribution Tracker](https://github.com/contrib-tracker/backend/tree/main/web/modules/custom/ct_drupal) + * **Email Management:** Disables email sending in non-production Platform.sh environments using `hook_mail_alter()`. This prevents accidental email delivery during development and testing. See [`contrib_tracker.module`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/contrib_tracker/contrib_tracker.module). -The Drupal.org Contribution Tracker module (ct_drupal) integrates with the ct_manager module to automate tracking user contributions made specifically on the Drupal.org platform. ct_manager acts as a central coordinator for various contribution tracking plugins, including ct_drupal. +* **Services:** -Here's how `ct_drupal` leverages `ct_manager` for contribution tracking: + * `logger.channel.contrib_tracker`: Provides a dedicated logger channel for the module. This allows for easy filtering and monitoring of module-specific log messages. See [`contrib_tracker.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/contrib_tracker/contrib_tracker.services.yml). + * `contrib_tracker.event_subscriber`: Registers the `Drupal\contrib_tracker\EventSubscriber\RavenSubscriber` event subscriber. Event subscribers allow the module to react to specific system events. See [`contrib_tracker.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/contrib_tracker/contrib_tracker.services.yml). -- It utilizes a `ContributionSource` plugin named `DrupalContribution.php`. This plugin interacts with the Drupal.org API via a wrapper module built around Guzzle 6 for efficient communication. +* **Drush Command:** -- To track contributions, `ct_drupal` relies on the `do_username` dependency, which manages a dedicated field where users enter their Drupal.org usernames. + * `contrib_tracker.contrib_tracker_issues_sanitise`: A Drush command for sanitizing issues data. This command likely performs data cleaning or formatting tasks on issue records. See [`console.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/contrib_tracker/console.services.yml). -- During cron runs, the `ct_manager` module triggers the `ct_drupal` plugin's functionality. ct_drupal then fetches contributions for all users with a populated Drupal.org username field, retrieving the latest 100 code contributions and 100 issues for each user. All the fetched data is passed backed to `ct_manager` to decide the storing process. +### 2. Contrib Tracker Users Module (`ct_user`) -### [GitHub Contribution Tracker](https://github.com/contrib-tracker/backend/tree/main/web/modules/custom/ct_github) +* **Description:** Manages user-related processes within the Contrib Tracker system. See [`ct_user.info.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_user/ct_user.info.yml). -The GitHub Contribution Tracker module (ct_github) automates tracking user contributions made on Github, specifically issues and code contributions. Here's how it works: +* **Dependencies:** `social_auth` - This module relies on the `social_auth` module, suggesting integration with social login providers. -- It utilizes a `ContributionSource` plugin named `GithubContribution.php` to interact with the Github GraphQL API. +* **Functionality:** -- This module requires each user's Github username to be filled in a dedicated field. + * **Theme:** Provides the `contrib_graph` theme, likely used for visualizing contribution data. See [`ct_user.module`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_user/ct_user.module). + * **Help Text:** Implements `hook_help` to provide context-sensitive help text within the Drupal administration interface. Checks for the route `help.page.ct_user`. See [`ct_user.module`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_user/ct_user.module). + * **Form Alterations:** Implements `hook_form_alter` to modify forms, specifically targeting the `user_login_form`. This allows for customization of the login process. See [`ct_user.module`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_user/ct_user.module). -- It requires a secure [GitHub personal access token](https://github.com/settings/tokens) stored in an environment variable or through other secure means and load it in `settings.php`. +* **Routing:** -- During cron runs, the `ct_manager` module triggers the `ct_github` plugin's functionality. `ct_github` then fetches contributions for users with populated Github username fields, retrieving the latest 100 issues and 100 code contributions for each user. All the fetched data is passed backed to `ct_manager` to decide the storing process. + * `ct_user.graph`: Defines a route `/user/{current_user_id}/graph` that displays a "Contribution Count" graph for the current user. The controller `\Drupal\ct_user\Controller\GetUserPatchesController::content` handles the request, and users must have the "access content" permission to view it. See [`ct_user.routing.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_user/ct_user.routing.yml). -In essence, this module simplifies tracking user activity on Github by offering an automated solution that integrates with existing Drupal functionalities and leverages the `ct_manager` module's infrastructure for processing and storage. +* **Services:** -### [Contribution Tracker Reports](https://github.com/contrib-tracker/backend/tree/main/web/modules/custom/ct_reports) + * `ct_user.ct_user_social_event_listener`: Registers an event subscriber, `Drupal\ct_user\EventSubscriber\ContribTrackerEventListener`. This subscriber likely listens for social authentication events and performs actions related to contribution tracking. It depends on the `@logger.factory` service. See [`ct_user.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_user/ct_user.services.yml) -The Contribution Tracker Reports module (ct_reports) provides functionality to generate reports based on contribution data. +### 3. Contrib Tracker Reports Module (`ct_reports`) -- The Contribution Tracker Reports module builds upon the existing Contribution Tracker functionality in Drupal by providing tools to analyze and visualize contribution data. The report can be generated based on multiple parameters such as Contribution Type, Technology, Title, Name and Contribution Date. +* **Description:** Generates reports based on the contribution data collected by the system. See [`ct_reports.info.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_reports/ct_reports.info.yml). -- The module offers functionalities to generate reports based on the contribution data collected by the core Contribution Tracker modules (e.g., Drupal.org Contribution Tracker or Github Contribution Tracker). +* **Functionality:** -- It provides a dedicated "Contribution Count" report accessible at the `/contribution-count` path. This report displays key metrics like total contributions, code contributions, and the total number of contributors. + * **Theme:** Provides the `ct_reports_contribution_count` theme, presumably for rendering contribution count reports. See [`ct_reports.module`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_reports/ct_reports.module). -Overall, the Contribution Tracker Reports module empowers users to leverage the contribution data for better insights into user activity and potentially identify trends or areas of focus within their Drupal community. +* **Routing:** -### [Contrib Tracker Users](https://github.com/contrib-tracker/backend/tree/main/web/modules/custom/ct_user) + * `ct_reports.count`: Defines a route `/contribution-count` that displays a general "Contribution Count" report. The controller `\Drupal\ct_reports\Controller\ContributionCountController::content` handles the request, and users must have the "access content" permission. See [`ct_reports.routing.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_reports/ct_reports.routing.yml). -The Contribution Tracker User module (ct_user) focuses on managing user login activities within the Contrib Tracker system. +* **Services:** -- It leverages the `social_auth` module, suggesting a focus on social login functionalities for Contrib Tracker. + * `ct_reports.statistics`: Defines a service `Drupal\ct_reports\ContributionStatistics` responsible for calculating contribution statistics. It utilizes the `@entity_type.manager` and `@database` services. See [`ct_reports.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_reports/ct_reports.services.yml). -- The module alters the user login form (`user_login_form`) and implements a custom validation function (`ct_user_user_login_form_validate`). This function checks if a logging-in user has an associated social login profile. +* **Libraries:** -- If a user has a social login profile linked to their account, the module redirects them to the social login provider's login page (e.g., `/user/login/google`) instead of allowing a traditional username/password login. This might be to enforce social login for specific users or enforce a specific login flow within Contrib Tracker. + * `ct-style`: Defines a library containing the `css/ct-style.css` stylesheet. This library likely provides the visual styling for the contribution reports. See [`ct_reports.libraries.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_reports/ct_reports.libraries.yml). -Overall, the Contribution Tracker User module appears to manage user login activities in Contrib Tracker, potentially prioritizing social login methods for certain users. +### 4. Contribution Tracker Manager Module (`ct_manager`) -## Custom Theme +* **Description:** Provides the underlying framework for managing contributions from various sources. See [`ct_manager.info.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_manager/ct_manager.info.yml). -[contribtracker theme](https://github.com/contrib-tracker/backend/tree/main/web/themes/custom/contribtracker): custom theme created specifically for Contrib Tracker. +* **Functionality:** -- Various Drupal Core views are customized by Twig. + * **ContributionSource Plugin Type:** Defines the `ContributionSource` plugin type, allowing for the creation of plugins that fetch contribution data from different sources (e.g., GitHub, Drupal.org). See [`README.md`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_manager/README.md). + * **Cron Processing:** Processes users on cron runs to track and store contributions from configured sources. See [`README.md`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_manager/README.md). + * **Cron Hook:** Implements `hook_cron()` to queue users for contribution processing for each plugin implementation. See [`ct_manager.module`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_manager/ct_manager.module). -- The ContribTracker custom Drupal theme employs several front-end technologies to ensure a robust and maintainable user interface. It utilizes SCSS for modular and advanced CSS styling, JavaScript, and TypeScript for dynamic and type-safe scripting, respectively. Gulp is used as a task runner to automate build processes, while Prettier and ESLint are used for code formatting and linting JavaScript code. Stylelint ensures consistent styling for CSS/Sass. These technologies together create an efficient and cohesive front-end development environment. +* **Services:** -[Gin](https://www.drupal.org/project/gin/releases/8.x-3.0-rc8) is a contributed theme used as an administration theme. + * `logger.channel.ct_manager`: Creates a dedicated logger channel for the module. See [`ct_manager.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_manager/ct_manager.services.yml). + * `plugin.manager.contribution_plugin_manager`: Defines a plugin manager for `ContributionSource` plugins. This service handles the discovery and instantiation of available contribution source plugins. See [`ct_manager.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_manager/ct_manager.services.yml). + * `ct_manager.contribution_storage`: Defines a service `Drupal\ct_manager\ContributionTrackerStorage` for managing the storage of contribution data. It uses `@entity_type.manager` and `@logger.channel.ct_manager` services. See [`ct_manager.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_manager/ct_manager.services.yml). + +### 5. Github Contribution Tracker Module (`ct_github`) + +* **Description:** Tracks contributions of users from GitHub. See [`ct_github.info.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_github/ct_github.info.yml). + +* **Dependencies:** `ct_manager` - This module relies on the `ct_manager` module to handle the overall contribution tracking framework. + +* **Functionality:** + + * **GitHub ContributionSource Plugin:** Provides a `ContributionSource` plugin that uses the GitHub GraphQL API to track contributions. It also provides functionality for storing users' GitHub usernames. See [`README.md`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_github/README.md). + * **User Processing on Cron:** Fetches users with the "Github Username" field set and tracks their latest contributions during cron runs. See [`README.md`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_github/README.md). + +* **Composer Dependencies:** `knplabs/github-api` - This module requires the `knplabs/github-api` library for interacting with the GitHub API. See [`composer.json`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_github/composer.json). + +* **Services:** + + * `ct_github.query`: Defines a service `Drupal\ct_github\GithubQuery` for querying the GitHub API. It utilizes the `@config.factory` and `@cache.data` services for configuration and caching. See [`ct_github.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_github/ct_github.services.yml). + * `ct_github.loggerChannel`: Creates a dedicated logger channel for the module. See [`ct_github.services.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_github/ct_github.services.yml). + +### 6. Drupal.org Contribution Tracker Module (`ct_drupal`) + +* **Description:** Tracks contributions of users from Drupal.org. See [`ct_drupal.info.yml`](/tmp/d00dc975-a6f4-4ecb-a34e-7a8986489f59/repo-dir/web/modules/custom/ct_drupal/ct_drupal.info.yml). + +* **Dependencies:** `ct_manager`, `do_username` - This module depends on `ct_manager` for the contribution tracking \ No newline at end of file diff --git a/docs/custom_themes.md b/docs/custom_themes.md new file mode 100644 index 00000000..cbc3fc39 --- /dev/null +++ b/docs/custom_themes.md @@ -0,0 +1,256 @@ +# ContribTracker Theme Documentation + +This document provides a comprehensive guide to the `contribtracker` custom theme, detailing its purpose, file structure, key configurations, and theming mechanisms within the Drupal environment. This guide is intended for developers and themers who need to understand, maintain, or extend the `contribtracker` theme. + +## Overview + +The `contribtracker` theme is a Drupal theme specifically designed for managing and showcasing community contributions. It offers a structured way to log and display contributions, including code, events, and other non-code related activities made by team members. + +## File Structure + +The `contribtracker` theme comprises several key files, each playing a specific role in defining the theme's behavior and appearance. + +* `contribtracker.info.yml`: Defines the theme's metadata and Drupal integration settings. +* `contribtracker.libraries.yml`: Specifies CSS and JavaScript libraries required by the theme. +* `contribtracker.breakpoints.yml`: Defines breakpoints for responsive design implementation. +* `contribtracker.theme`: Implements Drupal hook functions to modify theme suggestions. +* `package.json`: Manages Node.js dependencies and build/test scripts. +* `README.md`: Provides general theme information and links to functional testing documentation. + +## Key Configuration Files + +### `contribtracker.info.yml` + +This YAML file is the cornerstone of the theme, defining its core attributes and integration with Drupal. + +```yaml +name: contribtracker +description: 'A Drupal theme for managing community contributions.' +type: theme +core_version_requirement: ^10.3 || ^11.0 +base_theme: stable +regions: + header: 'Header' + navigation: 'Navigation' + content: 'Content' + sidebar: 'Sidebar' + footer: 'Footer' +libraries: + - core/normalize + - contribtracker/global +``` + +**Key elements:** + +* **`name`**: The human-readable name of the theme. +* **`description`**: A concise description of the theme's purpose. +* **`type`**: Indicates that this is a `theme`. +* **`core_version_requirement`**: Specifies the Drupal core versions the theme is compatible with (Drupal 10.3 and 11.0 and later). +* **`base_theme`**: Sets `stable` as the base theme. This is a minimal theme that provides a stable rendering environment for creating custom themes. +* **`regions`**: Defines the named regions where blocks can be placed within the theme's layout. +* **`libraries`**: Declares the CSS and JavaScript libraries to be included on every page where the theme is active. `core/normalize` provides CSS normalization, and `contribtracker/global` refers to the custom library defined in `contribtracker.libraries.yml`. + +### `contribtracker.libraries.yml` + +This file defines the CSS and JavaScript assets used by the theme. + +```yaml +global: + css: + theme: + https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Roboto:wght@400;700&display=swap: { type: external, minified: true } + dist/css/global.css: {} + js: + dist/js/navigation.js: {} + dist/js/select2.js: {} + dependencies: + - core/jquery + - contribtracker/select2 + +select2: + css: + component: + assets/select2/select2.min.css: {} + js: + assets/select2/select2.min.js: {} +contrib-graph: + css: + component: + dist/css/components/blocks/graph/contrib-graph.css: {} +``` + +**Key elements:** + +* **`global` library:** + * **`css`**: Includes CSS files. External CSS files, such as Google Fonts, are defined with the `type: external` property. `dist/css/global.css` is the theme's main stylesheet. + * **`js`**: Includes JavaScript files like `dist/js/navigation.js` (likely for handling navigation behavior) and `dist/js/select2.js`. + * **`dependencies`**: Lists dependencies required by the library, such as `core/jquery` and the custom `contribtracker/select2` library. + +* **`select2` library:** This library encapsulates the CSS and JavaScript files required for the Select2 JavaScript library, a jQuery-based replacement for select boxes. + +* **`contrib-graph` library:** Includes custom CSS for the contribution graph component. + +### `contribtracker.breakpoints.yml` + +This file defines the breakpoints used for responsive design, allowing the theme to adapt to different screen sizes. + +```yaml +contribtracker.mobile: + label: mobile + mediaQuery: '(max-width: 767px)' + weight: 0 + multipliers: + - 1x +contribtracker.tablet: + label: tablet + mediaQuery: '(min-width: 768px) and (max-width: 1023px)' + weight: 1 + multipliers: + - 1x +contribtracker.desktop: + label: desktop + mediaQuery: '(min-width: 1024px)' + weight: 2 + multipliers: + - 1x + +``` + +**Key Elements:** + +* Each breakpoint (`mobile`, `tablet`, `desktop`) is defined with: + * **`label`**: A human-readable name for the breakpoint. + * **`mediaQuery`**: The CSS media query that defines the breakpoint. + * **`weight`**: The order in which the breakpoints are applied (lower weights are applied first). + * **`multipliers`**: Defines the supported pixel densities (1x for standard resolution). + +## Theme Alter Hooks (`contribtracker.theme`) + +The `contribtracker.theme` file utilizes Drupal's hook system to modify theme suggestions for blocks, forms, and tables, allowing for more granular control over theming. + +```php + - ``` +## Getting Started - 2. Make the required changes and commit +### Prerequisites - ```bash - git commit -m "commit-message" - ``` +Before you begin, ensure that you have the following: - 3. Push the changes +- The latest versions (or at least the minimum required versions) of necessary development tools (e.g., PHP, Node.js, Composer, DDEV). +- An SSH key added to your GitHub account settings. The link to configure this is available in the original README file. - ```bash - git push origin - ``` +### Local Development Setup using DDEV -For a better understanding of the entire process and standards, please refer to Axelerant's [Git workflow.](https://engg-handbook.axelerant.com/docs/how-we-work/git/git-workflow/) +The project is configured for local development using DDEV. The `cypress-tests.yml` GitHub workflow uses `ddev/github-action-setup-ddev@v1` to set up and configure DDEV. -N.B. If provided with a user account, you can use the management console of [platform.sh](https://platform.sh/) to handle your branch-merge requests. Please refer to the official [documentation](https://docs.platform.sh/frameworks/drupal8/developing-with-drupal.html#merge-code-changes-to-master) for further information. +## Automated Tasks and Code Quality + +The project uses GitHub Actions for automated tasks, ensuring code quality, performing visual regression testing, and managing environments. + +### Code Quality Checks + +The `ci.yml` workflow defines continuous integration checks. It uses `hussainweb/drupalqa-action@v2` to perform Drupal code quality checks, including: + +- phplint +- yamllint +- jsonlint +- phpcs +- phpmd +- twigcs + +Frontend code quality checks are also implemented using the `node:18` container, ensuring adherence to coding standards. + +### Visual Regression Testing + +The `vr.yml` workflow runs visual regression tests using Percy. It is triggered on: + +- Push to tags +- Workflow dispatch +- Scheduled cron jobs + +The workflow sets up the following environment variables: + +- `CYPRESS_ADMIN_USERNAME` +- `CYPRESS_ADMIN_PASSWORD` +- `PERCY_TOKEN` + +These variables are essential for authenticating and running the visual regression tests correctly. + +### Cypress Tests + +The `cypress-tests.yml` workflow executes Cypress tests on a schedule (daily at midnight on Sundays). Key steps include: + +1. Setting up the Drupal environment using DDEV. +2. Installing dependencies via Composer. +3. Running the Cypress tests. + +The `PLATFORMSH_CLI_TOKEN` secret is configured as a global DDEV configuration variable using `ddev config global`. This token is necessary for authenticating with Platform.sh. + +### Platform.sh Environment Management + +The `pr-close.yml` workflow cleans up Platform.sh environments when a pull request is closed. It uses the `axelerant/platformsh-action@v1` action for environment cleanup. + +- **Authentication:** Requires the `PLATFORMSH_CLI_TOKEN` secret to authenticate with Platform.sh. The secret needs to be set up in the GitHub repository settings. \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index de5d2f2e..a328193a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,309 @@ -# Overview +# Contribution Tracker Project Documentation -The Contribution Tracking System is designed to facilitate the monitoring and analysis of contributions across various projects and initiatives within our organization. Leveraging the power of Drupal, this system provides robust features for capturing, categorizing, and reporting on our contributions, thereby enabling better resource allocation, performance evaluation, and recognition of employee achievements. +Welcome to the Contribution Tracker project documentation! + +This documentation provides comprehensive guides for developers and content editors working with the Contribution Tracker, a Drupal application designed to manage community contributions. + +## Who this Documentation is For + +* Developers setting up the local environment, contributing code, and managing CI/CD pipelines. +* Content editors managing and structuring content within the Drupal application. + +## Purpose of this Documentation + +This documentation aims to provide clear and concise information about the project's setup, architecture, and workflows, enabling efficient development and content management. + +## Overview + +### Project Purpose, Goals, and High-Level Description + +The Contribution Tracker is a Drupal application for managing community contributions including code, events, and non-code contributions. It provides tools for tracking, reporting, and acknowledging various contribution types. + +### Target Audience + +* **Developers:** Responsible for setting up the local environment, contributing code, and maintaining the application. +* **Content Editors:** Manage and create content related to community contributions. + +### Tech Stack Overview + +* **Drupal:** Version 10 +* **PHP:** Version 8.2+ (Refer to `composer.json` for specific compatibility) +* **Database:** MariaDB 11.4 (configured via DDEV) +* **Dependencies:** Managed by Composer (see `composer.json`) and npm (see `package.json`). + +## All Documentation Files + +### Developer Onboarding and Setup + +* **Tools and Prerequisites:** [Tools](#tools) +* **Local Development Setup (DDEV):** [Local Development Environment Setup (DDEV)](#local-development-environment-setup-ddev) +* **Local Settings Override:** [Local Settings Override (`settings.local.php`)](#local-settings-override-settingslocalphp) +* **GitHub Actions:** [GitHub Actions](#github-actions) +* **Automated Testing and CI/CD Workflows:** [Automated Testing and CI/CD Workflows](#automated-testing-and-ci-cd-workflows) +* **Gitpod:** [Gitpod](#gitpod) + +### Project Structure and Guidelines + +* **How To Work:** [How To Work](#how-to-work) +* **Content Structure:** [Content Structure](#content-structure) +* **Custom Modules:** [Custom Modules](#custom-modules) +* **Custom Themes:** [Custom Themes](#custom-themes) +* **Directory Structure:** [Directory Structure](#directory-structure) +* **Monitoring and Logging Configuration:** [Monitoring and Logging Configuration](#monitoring-and-logging-configuration) + +--- + +## Tools + +### Contribution Tracker - Developer Onboarding Guide + +This document guides developers setting up and contributing to the Contribution Tracker project. + +### Tools & Prerequisites + +#### Core Requirements + +* **PHP:** 8.2 or higher (check `composer.json`). +* **Composer:** Install [Composer](https://getcomposer.org/). +* **DDEV:** Install [DDEV](https://ddev.readthedocs.io/en/stable/#installation). DDEV configuration is in `.ddev/config.yaml`. + +#### Development Tools + +* **Git:** Required for version control. Ensure SSH key is added to GitHub. +* **Node.js:** Version 18 for frontend code quality checks. Install [Node.js](https://nodejs.org/). + +#### Dependencies + +`composer.json` lists PHP dependencies. Key dependencies: + +* `axelerant/ct_drupal` +* `axelerant/ct_github` +* `composer/installers` +* `cweagans/composer-patches` +* Various Drupal modules (see `composer.json`). + +Install dependencies: + +```bash +composer install +``` + +## Local Development Environment Setup (DDEV) + +`.ddev/config.yaml` configures the DDEV environment. + +**Key Configuration Aspects:** + +* `name`: `contribtracker` - Project name. +* `type`: `drupal10` - Drupal version. +* `php_version`: `8.3` - PHP version. +* `database`: `mariadb`, version `11.4`. +* `web_environment`: `PLATFORM_ENVIRONMENT=main`, `PLATFORM_PROJECT=brbqplxd7ycq6` - Environment variables for Platform.sh. + +**Setting up DDEV:** + +1. Navigate to the project root. +2. Start DDEV: + + ```bash + ddev start + ``` +3. Follow instructions, including importing the database if needed. + +## GitHub Actions + +GitHub Actions for continuous integration, visual regression testing, and environment management. + +* **CI (`ci.yml`):** Automated code checks. + * Drupal code quality checks using `hussainweb/drupalqa-action@v2`. + * Frontend code quality checks using Node.js. +* **Cypress Tests (`cypress-tests.yml`):** End-to-end tests. + * Uses DDEV. + * `PLATFORMSH_CLI_TOKEN` secret for Platform.sh interaction. +* **Clean Platform.sh env on PR Close (`pr-close.yml`):** Cleans up Platform.sh environments. + * Uses `axelerant/platformsh-action@v1`. +* **VR (`vr.yml`):** Visual Regression testing. + * Triggered on tag pushes, manual dispatch, and weekly schedule. + * Uses `PERCY_TOKEN` secret for Percy access. + +## Gitpod + +Gitpod-ready for cloud-based development. Click the Gitpod badge in `README.md`. + +## Notes + +* Add SSH key to your GitHub account. +* See workflow files (`.github/workflows/*.yml`) for details. +* `README.md` contains more information. + +## Local Setup + +### Contribution Tracker: Local Development Environment Setup + +Details for local environment setup using DDEV. + +### Prerequisites + +* DDEV (latest recommended) +* Docker (required by DDEV) +* PHP (8.3+ recommended, managed by DDEV) +* Node.js (18, managed by DDEV) +* Git (latest recommended) +* SSH Key (added to GitHub: [GitHub documentation](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-)). + +### DDEV Configuration + +`.ddev/config.yaml` details: + +```yaml +name: contribtracker +type: drupal10 +docroot: web +php_version: "8.3" +webserver_type: nginx-fpm +router_http_port: "80" +router_https_port: "443" +mariadb_version: "11.4" +additional_hostnames: [] +additional_fqdns: [] +upload_dir: sites/default/files +xdebug_enabled: false +web_environment: + - PLATFORM_ENVIRONMENT=main + - PLATFORM_PROJECT=brbqplxd7ycq6 +nodejs_version: "18" +``` + +**Explanation:** + +* `name`: `contribtracker` - DDEV project name. +* `type`: `drupal10` - Drupal 10 project. +* `docroot`: `web` - Document root. +* `php_version`: `"8.3"` - PHP version. +* `webserver_type`: `nginx-fpm` - Web server type. +* `router_http_port`: `"80"` - HTTP port. +* `router_https_port`: `"443"` - HTTPS port. +* `mariadb_version`: `"11.4"` - MariaDB version. +* `web_environment`: Platform.sh environment variables. +* `nodejs_version`: `"18"` - Node.js version + +**Starting the Environment:** + +```bash +ddev start +``` + +## Local Settings Override (`settings.local.php`) + +Customize settings for local development. + +### Steps: + +1. **Copy the template:** + + ```bash + cp web/sites/example.settings.local.php web/sites/default/settings.local.php + ``` + + or + + ```bash + cp web/sites/example.settings.local.php web/sites/example.com/settings.local.php + ``` + +2. **Enable the include:** Uncomment the include lines in `web/sites/default/settings.php`. + + ```php + if (file_exists(__DIR__ . '/settings.local.php')) { + include __DIR__ . '/settings.local.php'; + } + ``` + +### Purpose + +* Override default settings for local development. +* Specify local database credentials. +* Enable development modules (e.g., Devel). +* Configure assertions. + +## How To Work + +### Contribution Tracker Project Documentation + +Outlines the development practices and setup for the Contribution Tracker project. + +### Project Overview + +Drupal 8 application for managing community contributions: + +* Code contributions +* Event contributions +* Non-code contributions + +### Getting Started + +#### Prerequisites + +* Latest versions of PHP, Node.js, Composer, DDEV +* SSH key added to GitHub. + +#### Local Development Setup using DDEV + +`cypress-tests.yml` uses `ddev/github-action-setup-ddev@v1`. + +### Automated Tasks and Code Quality + +GitHub Actions for code quality, visual regression testing, and environment management. + +#### Code Quality Checks + +`ci.yml` uses `hussainweb/drupalqa-action@v2`: + +* phplint +* yamllint +* jsonlint +* phpcs +* phpmd +* twigcs + +Frontend code quality checks using `node:18`. + +#### Visual Regression Testing + +`vr.yml` uses Percy. + +* Triggered on tags, workflow dispatch, scheduled jobs. +* Environment variables: `CYPRESS_ADMIN_USERNAME`, `CYPRESS_ADMIN_PASSWORD`, `PERCY_TOKEN`. + +#### Cypress Tests + +`cypress-tests.yml` runs daily at midnight on Sundays. + +1. Sets up Drupal with DDEV. +2. Installs Composer dependencies. +3. Runs Cypress tests. + +`PLATFORMSH_CLI_TOKEN` is configured as a global DDEV variable. + +#### Platform.sh Environment Management + +`pr-close.yml` cleans up Platform.sh environments. + +* Uses `axelerant/platformsh-action@v1`. +* Requires `PLATFORMSH_CLI_TOKEN` secret. + +## Content Structure + +### Content Structure Documentation + +Outlines content types and configurations. + +### Content Types + +1. **Basic Page** + * Purpose: Static content ("About Us"). + * Configuration Files: + * `config/sync/node.type.page.yml` + * `config/sync/core.entity_view_display.node.page.default.yml` + * `config/sync/core.entity_view_display.node.page.teaser.yml` + * `config/sync/ \ No newline at end of file diff --git a/docs/local_setup.md b/docs/local_setup.md index c824fe7d..f59b1c03 100644 --- a/docs/local_setup.md +++ b/docs/local_setup.md @@ -1,54 +1,99 @@ -# Local environment setup +# Contribution Tracker: Local Development Environment Setup + +This document details the setup of a local development environment for the Contribution Tracker project using DDEV. Following these steps ensures a consistent and efficient development experience. + +## Prerequisites + +Before proceeding, ensure the following tools are installed and configured on your system: + +* **DDEV:** (Latest version recommended) +* **Docker:** (Required by DDEV) +* **PHP:** (Version 8.3 or higher is recommended, but managed by DDEV) +* **Node.js:** (Version 18, managed by DDEV) +* **Git:** (Latest version recommended) +* **SSH Key:** Ensure your SSH key is added to your GitHub account settings (see [GitHub documentation](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-)). + +## DDEV Configuration + +The project utilizes DDEV for simplified local environment management. The core configuration is defined in the `.ddev/config.yaml` file. + +### `.ddev/config.yaml` Details + +```yaml +name: contribtracker +type: drupal10 +docroot: web +php_version: "8.3" +webserver_type: nginx-fpm +router_http_port: "80" +router_https_port: "443" +mariadb_version: "11.4" +additional_hostnames: [] +additional_fqdns: [] +upload_dir: sites/default/files +xdebug_enabled: false +web_environment: + - PLATFORM_ENVIRONMENT=main + - PLATFORM_PROJECT=brbqplxd7ycq6 +nodejs_version: "18" +``` -Once you have all the tools installed, proceed to run the following to clone the repository. +**Explanation:** -```bash -git clone git@github.com:contrib-tracker/backend.git -``` +* **name:** `contribtracker` - The name of the DDEV project. +* **type:** `drupal10` - Specifies that this is a Drupal 10 project. +* **docroot:** `web` - The document root directory for the Drupal installation. +* **php\_version:** `"8.3"` - The PHP version to use. +* **webserver\_type:** `nginx-fpm` - The web server type (Nginx with FPM). +* **router\_http\_port:** `"80"` - The HTTP port for the router. +* **router\_https\_port:** `"443"` - The HTTPS port for the router. +* **mariadb\_version:** `"11.4"` - The MariaDB version for the database. +* **web\_environment:** + * `PLATFORM_ENVIRONMENT=main` - Defines the environment as "main." + * `PLATFORM_PROJECT=brbqplxd7ycq6` - Specifies the Platform.sh project ID. +* **nodejs\_version:** `"18"` - The Node.js version to use. -Change to the directory of the repository and run DDEV to start. +### Starting the Environment + +To start the local environment, navigate to the project root directory (the directory containing the `.ddev` folder) and run: ```bash -cd backend ddev start ``` -Once DDEV has been set up successfully, it will display the links in the terminal. Next, run the following to fetch all dependencies. +This command will build and start the necessary Docker containers based on the configuration in `.ddev/config.yaml`. -```bash -ddev composer install -``` +## Local Settings Override (`settings.local.php`) -You can pull the database from the platform.sh directly. Make sure that the [PLATFORMSH_CLI_TOKEN is set](https://ddev.readthedocs.io/en/latest/users/providers/platform/). +To customize settings for local development (e.g., database credentials, enabling development modules), use the `settings.local.php` file. -```bash -ddev pull platform -``` +### Steps: -Make sure code changes are updated. +1. **Copy the template:** Copy `web/sites/example.settings.local.php` to `web/sites/default/settings.local.php`. If you are using a site name in the path (e.g., a multi-site installation), copy it to `web/sites/example.com/settings.local.php` instead. Make sure to create the `web/sites/default` directory if it doesn't exist. -```bash -ddev drush deploy -y -``` - -## Post Installation + ```bash + cp web/sites/example.settings.local.php web/sites/default/settings.local.php + ``` -Generate a one-time login link and reset the password through it. + or -```bash -ddev drush uli -``` + ```bash + cp web/sites/example.settings.local.php web/sites/example.com/settings.local.php + ``` -Clear the cache using drush +2. **Enable the include:** Uncomment the lines that include `settings.local.php` in `web/sites/default/settings.php` (or `web/sites/example.com/settings.php` if using a multi-site). -```bash -ddev drush cr -``` + ```php + if (file_exists(__DIR__ . '/settings.local.php')) { + include __DIR__ . '/settings.local.php'; + } + ``` -## Theme Build +### Purpose -```bash -cd web/themes/custom/contribtracker && npm install && npm run build && ddev drush cr -``` +The `settings.local.php` file is intended for: -You can access the site at: [https://contribtracker.ddev.site/](https://contribtracker.ddev.site/). +* Overriding default settings for local development. +* Specifying database credentials for your local database. +* Enabling development-focused modules (e.g., Devel). +* Configuring assertions to catch incorrect API calls during development. \ No newline at end of file diff --git a/docs/monitoring.md b/docs/monitoring.md index 4f383b27..baaa0c31 100644 --- a/docs/monitoring.md +++ b/docs/monitoring.md @@ -1,11 +1,21 @@ -# Monitoring and Logging +# Monitoring and Logging Configuration -We have used monitoring and performance management tools. +This document details the configuration related to monitoring and logging within the Drupal project. -## Debugging +## `system.logging.yml` -- [Sentry](https://axelerant.sentry.io/projects/contrib-tracker/?project=1275643) +This YAML file (`config/sync/system.logging.yml`) configures the core Drupal logging system. It defines how Drupal handles and displays error messages. -## Observability +* **File Path:** `config/sync/system.logging.yml` +* **Description:** Configuration for Drupal's core logging functionality. +* **Key Configuration:** + * `error_level`: Set to `"hide"`. This setting disables the display of error messages in the user interface. This is likely intended for a production environment to prevent potentially sensitive information from being exposed to end-users. -- [NewRelic](https://one.newrelic.com/nr1-core/apm/overview/NDE5NjkxMXxBUE18QVBQTElDQVRJT058NTU4MDEwNzY0?account=4196911&duration=1800000&state=4bfccb86-3294-34ae-3558-149f0e919cb2) +## `settings.php` + +The `settings.php` file (`web/sites/default/settings.php`) serves as Drupal's primary configuration file. While the provided extract doesn't offer direct logging configuration within this file, its role in defining the environment and including conditionally loaded configuration files impacts overall logging behavior. + +* **File Path:** `web/sites/default/settings.php` +* **Description:** Drupal's primary configuration file, responsible for bootstrapping the application and defining environment-specific settings. +* **Relevance to Logging:** + * `settings.php` determines which configuration files are loaded, allowing for different logging configurations across various environments (e.g., development, staging, production). Logging behavior can be altered by modifying or extending environment-specific includes, allowing customized error handling and debugging features for each environment. \ No newline at end of file diff --git a/docs/tools.md b/docs/tools.md index 21e9c919..b3a16658 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -1,11 +1,82 @@ -# Tools & Prerequisites +# Contribution Tracker - Developer Onboarding Guide -Major tools that are required for setting up the site. It is recommended to use the latest version or at least the minimum version as mentioned below. It is mandatory to add [your SSH key to your GitHub account settings](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account). +This document provides a guide for developers setting up and contributing to the Contribution Tracker project. It covers the required tools, project dependencies, local development environment setup, and continuous integration workflows. -- [Composer](https://getcomposer.org/download/) (optional if used via DDEV) +## Tools & Prerequisites -- [Docker](https://docs.docker.com/install/) or [OrbStack](https://orbstack.dev/) +This section outlines the tools and prerequisites necessary for successful development on the Contribution Tracker application. -- [DDEV](https://ddev.com/get-started/) - v1.22.0 +### Core Requirements -- [NodeJs](https://nodejs.org/en/download) +* **PHP:** Version 8.2 or higher. Refer to the `composer.json` file for the specific version compatibility. +* **Composer:** A dependency management tool for PHP. The `composer.json` file defines the project's dependencies, including Drupal modules and other libraries. Install [Composer](https://getcomposer.org/) if you don't have it already. +* **DDEV:** DDEV is used as the local development environment, configured via the `.ddev/config.yaml` file. This configuration specifies the project's name, Drupal version, PHP version, web server type, database type, and other essential environment settings. Install [DDEV](https://ddev.readthedocs.io/en/stable/#installation) if you don't have it already. + +### Development Tools + +* **Git:** Required for version control and collaboration. The project utilizes GitHub Actions workflows, assuming developers can interact with the GitHub repository. If you haven't already, add your SSH key to your GitHub account as described in the `README.md`. +* **Node.js:** Version 18 is employed for frontend code quality checks within the `ci.yml` workflow. This suggests that Node.js (and likely `npm` or `yarn`) is also used for other front-end related development tasks. Install [Node.js](https://nodejs.org/) if you don't have it already. + +### Dependencies + +The `composer.json` file lists the PHP dependencies. Here are some key dependencies: + +* `axelerant/ct_drupal`: Custom Drupal module for the Contribution Tracker. +* `axelerant/ct_github`: Custom Drupal module for GitHub integration. +* `composer/installers`: Composer plugin for handling different package types. +* `cweagans/composer-patches`: Composer plugin for applying patches. +* Various Drupal modules such as `drupal/address`, `drupal/admin_toolbar`, etc. (Refer to `composer.json` for the complete list). + +To install all dependencies, run: + +```bash +composer install +``` + +## Local Development Environment Setup (DDEV) + +The `.ddev/config.yaml` file configures the DDEV environment. + +**Key Configuration Aspects:** + +* **`name`**: `contribtracker` - defines the project name for DDEV. This is how you'll interact with the DDEV environment from the command line. +* **`type`**: `drupal10` - specifies the Drupal version. +* **`php_version`**: `8.3` - defines the PHP version. This should match the version specified in the "Core Requirements" section. +* **`database`**: `mariadb`, version `11.4`. Defines the database type and version. +* **`web_environment`**: `PLATFORM_ENVIRONMENT=main`, `PLATFORM_PROJECT=brbqplxd7ycq6` - Sets environment variables. These are likely specific to the project's Platform.sh environment. + +**Setting up DDEV:** + +1. **Navigate to the project root directory** in your terminal. +2. **Start the DDEV environment** with the command: + + ```bash + ddev start + ``` +3. Follow the instructions output by the `ddev start` command, including importing the database if required. + +## GitHub Actions + +The project utilizes GitHub Actions for continuous integration, visual regression testing, and environment management. Understanding these workflows is crucial for contributing effectively. + +* **CI (`ci.yml`):** This workflow performs automated checks on code changes. + * It runs Drupal code quality checks using `hussainweb/drupalqa-action@v2`, including linting and code style validation to ensure code adheres to standards. + * It also runs frontend code quality checks using Node.js (likely running linters, style checks, and potentially unit tests for the front-end code). +* **Cypress Tests (`cypress-tests.yml`):** Runs Cypress end-to-end tests to verify the application's functionality. + * It uses DDEV to set up the testing environment, ensuring tests run in a consistent and reproducible environment. + * The `PLATFORMSH_CLI_TOKEN` GitHub secret is used for interacting with Platform.sh, likely for deploying and managing testing environments on Platform.sh. +* **Clean Platform.sh env on PR Close (`pr-close.yml`):** This workflow automates the cleanup of Platform.sh environments when pull requests are closed to avoid unnecessary resource consumption. + * It uses the `axelerant/platformsh-action@v1` action. +* **VR (`vr.yml`):** Likely used for Visual Regression (VR) testing to automatically detect unintended visual changes in the application. + * Triggered on tag pushes, manual workflow dispatch, and a weekly schedule. + * Uses the `PERCY_TOKEN` GitHub secret to authorize access to the Percy visual testing service. + +## Gitpod + +The project is Gitpod-ready, offering a convenient cloud-based development environment. You can quickly start a fully configured development environment directly from your web browser; simply click the Gitpod badge in the `README.md` file. + +## Notes + +* Ensure your SSH key has been added to your GitHub account. This is crucial for Git operations and authenticating with Platform.sh. +* Refer to the individual workflow files (`.github/workflows/*.yml`) for detailed configurations of the GitHub Actions. +* The `README.md` file contains further information and useful links. \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 4ec16b80..80e5d69a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Contrib Tracker +site_name: target-dir docs_dir: docs plugins: - techdocs-core @@ -9,8 +9,8 @@ nav: - Local Environment Setup: 'local_setup.md' - How to work on this project: 'how_to_work.md' - Content Structure: 'content_structure.md' - - Custom Modules and Themes: 'custom_modules.md' - - Testing: 'testing.md' + - Custom Modules: 'custom_modules.md' + - Custom Themes: 'custom_themes.md' + - Testing: 'functional_testing.md' - Monitoring and Logging: 'monitoring.md' - CI/CD: 'ci_cd.md' - - Functional Testing with Cypress: 'func_testing.md'