Skip to content

About

Provides shareable workflows and composite actions for the @cycle organization.

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Build Status Software License Commits since latest release Discord Twitter

Shared GitHub Actions

This repository is a collection of reusable workflows and composite actions, specifically designed for use in cycle projects.

These tools encapsulate common and repetitive tasks, allowing for easy integration into multiple projects. This approach not only reduces the need to rewrite code but also ensures standardized operations across all Cycle repositories.


πŸ“‹ Table of Contents


πŸš€ Getting Started

To use these workflows and actions, reference them directly from your project's workflows. Detailed instructions for each are provided below.


πŸ’» Composite Actions

Composite Actions are a powerful feature of GitHub Actions that allow you to create reusable actions using a combination of other actions, shell commands, or both.

This enables you to encapsulate a sequence of steps into a single action, making your workflows more modular, easier to maintain, and reducing duplication across your projects.

Composite Actions can accept inputs and use outputs, making them highly flexible and adaptable to various use cases.

Check each action's README file for detailed instructions on how to use it.

Action Description
composer/get-cache-directory Gets the Composer cache directory path and exports it as env variable.
composer/get-root-version determines the Composer root version based on the specified branch and exports it as env variable.
composer/install Installs dependencies with Composer based on the specified dependency level.
phive/install Install dependencies with Phive.

πŸ’» Workflows

Read more about reusing workflows.

β†’ Auto Label and Release Management

apply-labels.yml:

Automatically applies labels to pull requests based on modified paths.

This workflow triages pull requests and applies labels based on the paths that are modified in the pull request. This can help to categorize your pull requests and make it easier to identify the type of changes included.

To use this workflow, set up a .github/labeler.yml file with your configuration in your project. For more information on how to configure the labeler, see: https://github.com/actions/labeler/blob/master/README.md

Here is an example of how to use this workflow:

.github/workflows/apply-labels.yml
---

on:
  pull_request:

name: 🏷️ Add labels

jobs:
  label:
    uses: cycle/gh-actions/.github/workflows/apply-labels.yml@master
    with:
      os: ubuntu-latest
    secrets:
      token: ${{ secrets.GITHUB_TOKEN }}

...
.github/labeler.yml
---

"type: bug":
    - head-branch: ['^bug', '^fix', 'bug', 'fix']

"type: enhancement":
    - head-branch: ['^feature', '^feat', 'feature']

"type: documentation":
    - changed-files:
          - any-glob-to-any-file: ['assets/**/*', '.github/*', './*.md']

"type: maintenance":
    - changed-files:
          - any-glob-to-any-file: ['tests/**/*', '.github/workflows/*']

...

Real-world examples can be found in the wayofdev/laravel-package-tpl repository.


auto-merge-release.yml:

This workflow automatically merges releases. This workflow utilizes peter-evans/enable-pull-request-automerge to auto-merge releases that are created by googleapis/release-please.

Here is an example of how to use this workflow:

.github/workflows/auto-merge-release.yml
---

on:  # yamllint disable-line rule:truthy
  pull_request:

permissions:
  pull-requests: write
  contents: write

name: 🀞 Auto merge release

jobs:
  auto-merge:
    uses: cycle/gh-actions/.github/workflows/auto-merge-release.yml@master
    with:
      os: ubuntu-latest
      pull-request-number: ${{ github.event.pull_request.number }}
      actor: lotyp
      merge-method: merge
    secrets:
      # to trigger other workflows, pass PAT token instead of GITHUB_TOKEN
      token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}

...

Real-world examples can be found in the wayofdev/laravel-package-tpl repository.


β†’ Code Architecture

create-arch-diagram.yml:

This workflow leverages the codesee-io/codesee-action action to automatically generate architecture diagrams for your codebase whenever a pull request is made.

CodeSee is an open-source tool that helps visualize your codebase and its dependencies, making it easier for new contributors to understand the project or for maintaining a clear view of your project's architecture over time.

Here is an example of how to use this workflow:

.github/workflows/create-arch-diagram.yml
---

on:  # yamllint disable-line rule:truthy
  push:
    branches:
      - develop
  pull_request_target:
    types:
      - opened
      - synchronize
      - reopened

name: πŸ€– CodeSee

permissions: read-all

jobs:
  codesee:
    uses: cycle/gh-actions/.github/workflows/create-arch-diagram.yml@master
    with:
      os: ubuntu-latest
      continue-on-error: true
    secrets:
      codesee-token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}

...

Real-world examples can be found in the wayofdev/laravel-package-tpl repository.


β†’ Static Analysis

shellcheck.yml:

This workflow uses redhat-plumbers-in-action/differential-shellcheck to run shell script analysis.

Here is an example of how to use this workflow:

.github/workflows/shellcheck.yml
---

on:  # yamllint disable-line rule:truthy
  pull_request:

name: 🐞 Differential shell-check

permissions:
  contents: read

jobs:
  shellcheck:
    uses: cycle/gh-actions/.github/workflows/shellcheck.yml@master
    with:
      os: ubuntu-latest
      severity: warning
    secrets:
      token: ${{ secrets.GITHUB_TOKEN }}

...

Real-world examples can be found in the wayofdev/laravel-package-tpl repository.


β†’ Testing

testo.yml:

Runs the tests of a Cycle package built on Testo and cycle/testing. The PHP versions and the database drivers for the whole organisation are set here, so a caller passes only what differs.

The workflow calls the package's composer scripts and never passes Testo flags of its own, so a CI run is the same command as a local one:

Script Used by
test:unit the unit job, on every PHP version
test:sqlite the unit job, after the Unit suite, when sqlite is listed
test:mysql, test:postgres, test:sqlserver one server job per driver
db:up composer db:up -- <driver> starts the database from the compose file of cycle/testing

Every job runs with DB_REQUIRED=1, so an unreachable database fails the run instead of skipping its tests.

The matrix:

  • unit (Unit and SQLite): every version of php with highest dependencies, plus the lowest version with lowest dependencies.
  • server (MySQL, Postgres, SQLServer): the same for server-php, which defaults to the lowest and the highest version of php.
  • With coverage: true, the highest PHP version with highest dependencies collects coverage with pcov and uploads it to Codecov with one flag per suite: unit, sqlite, mysql, postgres, sqlserver.
Input Default Description
php ["8.2","8.3","8.4","8.5","8.6"] PHP versions (JSON list).
server-php lowest and highest of php PHP versions (JSON list) for MySQL, Postgres and SQLServer.
drivers ["sqlite","mysql","postgres","sqlserver"] Drivers to test (JSON list). [] runs the Unit suite only.
dependencies ["highest","lowest"] Composer dependency versions (JSON list).
coverage false Collect coverage and upload it to Codecov.
extensions PHP extensions on top of pdo, pdo_sqlite, mbstring and the driver's PDO extension.
ini-values error_reporting=E_ALL, memory_limit=-1 PHP ini values.
composer-root-version COMPOSER_ROOT_VERSION, for a package that a dependency requires back (cycle/database β†’ 2.x-dev).
composer-options Extra options for composer update.
os ubuntu-latest Runner; a Linux one, as the databases run in Docker.
timeout-minutes 20 Timeout of each test job.

The optional secret CODECOV_TOKEN reaches the workflow through secrets: inherit.

Here is an example of how to use this workflow:

.github/workflows/testing.yml
---

on:  # yamllint disable-line rule:truthy
  pull_request:
  push:
    branches:
      - 2.x

name: πŸ§ͺ Tests

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
  contents: read

jobs:
  testo:
    name: Testo
    uses: cycle/gh-actions/.github/workflows/testo.yml@master
    with:
      coverage: true
    secrets: inherit

...

A package without database tests passes drivers: '[]'; a package that cycle/testing requires back, such as cycle/database, passes composer-root-version: 2.x-dev.

Real-world example: cycle/testing.

infection.yml:

Runs mutation testing with Infection through testo/bridge-infection and uploads the report to the Stryker dashboard.

The package keeps Infection in vendor-bin/infection (installed with composer bin infection install) and defines an infect:ci composer script; the suites, the thresholds and the report branch live in its infection.json. The report goes to the dashboard only on push, so a pull request never overwrites the branch report and needs no secret.

Input Default Description
php 8.4 PHP version.
coverage xdebug Coverage driver for Infection: xdebug or pcov.
extensions PHP extensions on top of pdo, pdo_sqlite and mbstring.
ini-values error_reporting=E_ALL, memory_limit=-1 PHP ini values.
composer-root-version COMPOSER_ROOT_VERSION, as in testo.yml.
composer-options Extra options for composer update.
os ubuntu-latest Runner.
timeout-minutes 30 Timeout of the job.

The optional secret STRYKER_DASHBOARD_API_KEY reaches the workflow through secrets: inherit.

.github/workflows/infection.yml
---

on:  # yamllint disable-line rule:truthy
  pull_request:
  push:
    branches:
      - 1.x

name: 🧬 Mutation Tests

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
  contents: read

jobs:
  infection:
    name: Infection
    uses: cycle/gh-actions/.github/workflows/infection.yml@master
    secrets: inherit

...

Real-world example: cycle/transaction.


πŸ”’ Security Policy

This project has a security policy.


πŸ™Œ Want to Contribute?

Thank you for considering contributing to the cycle community! We are open to all kinds of contributions. If you want to:

You are more than welcome. Before contributing, kindly check our contribution guidelines.

Conventional Commits


🌐 Social Links

  • Twitter (X): Follow our organization @SpiralPHP.
  • Discord: Join our community on Discord.

🫑 Contributors

Contributors Badge


🧱 Useful Resources


🀝 License

Licence


About

Provides shareable workflows and composite actions for the @cycle organization.

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages