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

ci: Enhancements to prettier workflow and linting documentation #311

Merged
merged 14 commits into from Aug 12, 2022
28 changes: 22 additions & 6 deletions .github/workflows/prettier.yml
@@ -1,27 +1,43 @@
name: Format with Prettier

on:
pull_request:
push:
branches:
- main
pull_request:
paths:
- "**.php"
- "**.md"
- "**.js"
- "**.css"

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout Pull Request
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Checkout Push
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@v3

- name: Install prettier and plugin-php
run: npm install --global prettier @prettier/plugin-php

- name: Lint with Prettier
continue-on-error: true
run: composer lint

- name: Prettify code
run: composer lint-fix

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
uses: EndBug/add-and-commit@v9
with:
commit_message: "style: Formatted code with Prettier"
branch: ${{ github.head_ref }}
message: "style: Formatted code with Prettier"
default_author: github_actions
1 change: 1 addition & 0 deletions .prettierignore
@@ -0,0 +1 @@
vendor
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -86,6 +86,18 @@ Run the following command to run the PHPUnit test script which will verify that
composer test
```

## Linting

This project uses Prettier for formatting PHP, Markdown, JavaScript and CSS files.

```bash
# Run prettier and show the files that need to be fixed
composer lint

# Run prettier and fix the files
composer lint-fix
```

## Submitting Contributions 👨‍💻

Below you will find the process and workflow used to review and merge your changes.
Expand Down
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -223,6 +223,18 @@ Run the following command to run the PHPUnit test script which will verify that
composer test
```

### Linting

This project uses Prettier for formatting PHP, Markdown, JavaScript and CSS files.

```bash
# Run prettier and show the files that need to be fixed
composer lint

# Run prettier and fix the files
composer lint-fix
```

## 🙋‍♂️ Support

💙 If you like this project, give it a ⭐ and share it with friends!
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -31,7 +31,7 @@
"php -S localhost:8000 -t src"
],
"test": "./vendor/bin/phpunit --testdox tests",
"lint": "prettier --check **/*.{php,md,js,css} !**/*.min.js --print-width 120",
"lint-fix": "prettier --write **/*.{php,md,js,css} !**/*.min.js --print-width 120"
"lint": "prettier --check *.md **/*.{php,md,js,css} !**/*.min.js --print-width 120",
"lint-fix": "prettier --write *.md **/*.{php,md,js,css} !**/*.min.js --print-width 120"
}
}
1 change: 0 additions & 1 deletion src/index.php
Expand Up @@ -8,7 +8,6 @@
require_once "card.php";

// load .env

$dotenv = \Dotenv\Dotenv::createImmutable(dirname(__DIR__, 1));
$dotenv->safeLoad();

Expand Down