Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Presentation 21/12/2021 - Introduction to git-hooks, GitHub, GitHub Actions and (Drupal) Best Practices. #3

Open
theodorosploumis opened this issue Dec 21, 2021 · 0 comments

Comments

@theodorosploumis
Copy link
Owner

theodorosploumis commented Dec 21, 2021

Introduction to git-hooks, GitHub, GitHub Actions and (Drupal) Best Practices.

About GitHub

  • git GUI
  • users, roles and permissions
  • pull requests, code compare, code review
  • Issues (can also integrate with Jira issues)
  • Releases
  • Markdown & documentation
  • Dependabot security updates
  • Show your work globally
  • git flow setup
  • 3rd party tools integrations
  • Online IDE buttons (eg open on Gitpod etc)
  • GitHub Codespaces + VSCode Remote Containers (upcoming)
  • GitHub Actions (CI/CD)

About git-hooks

  • Trigger on events like commit, push, pull, merge etc
  • protected branches (from direct git push)
  • run any command
  • Examples: linting, validation, testing, git flow restrictions, commit message pattern, alert for debug code, conventional commits etc
  • See more usage of git-hooks on Add section for git-hook notes#1

How to execute commands on Drupal projects

  • bash scripts
  • drush
  • composer scripts
  • cli wrapper (eg Robo)
  • other PHP tools (phar, phing, make etc)
  • hook_update_N on Drupal modules (once running commands)
  • ...

This project tools

See https://github.com/theodorosploumis/drupal-actions#development.

Based on https://github.com/theodorosploumis/drupal-best-practices

Why setup a CI/CD process

  • Validate, test code and functionality
  • Automate deployments
  • Allow new developers to contribute easily
  • Educate new people to Drupal
  • Reduce the need for tasks like (human) QA
  • Allow to "dockerize" processes (dockerize once, use everywhere)
  • Reproduce production environment
  • See also: https://github.com/Lullabot/drupal9ci

GitHub Actions

Development example

  • acquire project (PHP 8, composer 2.x)
  • start with ddev
  • open local IDE
  • make changes on module file (git-hooks fail on message error)
  • ddev ssh
  • Example tests ddev cypress open --browser chrome --config-file tests/cypress.json
  • create a PR
  • run GitHub Actions
  • merge PR
  • create relaease (CHANGELOG)
  • open in Gitpod example

Final outcome

  • Put your project restrictions on Composer
  • Put your git related restrictions on git-hooks
  • Use .env to store credentials and important variables
  • Try to not use duplicated commands. Each command should have a unique way to be executed
  • Try to wrap scripts and commands with a tool (eg Robo)
  • CI/CD commands should be as much as possible system agnostic (so they play on every new system)
  • CI/CD commands should be able to run locally too
  • Use a dockerized environment for local development (ddev, lando etc) and commit configuration on git
  • Create your own docker images to have more control over development and testing
  • "Dockerize" once, use everywhere (local development, CI/CD etc). See example ddev with GitHub Actions.
  • Automate your CHANGELOG generation
  • Document in markdown

Tools used for this presentation

@theodorosploumis theodorosploumis changed the title Presentation 21/12/2021 Presentation 21/12/2021 - Introduction to git-hooks, GitHub, GitHub Actions and (Drupal) Best Practices. Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant