Skip to content

Commit

Permalink
ci: add release workflow with quality check and semantic release
Browse files Browse the repository at this point in the history
- docs: add CONTRIBUTING.md and SECURITY.md files
- docs: add issue templates for bug-reports and feature-requests
- docs: add pull request template
- build: add node environment with pnpm to manage release and prettier
- test: add Pest with basic Architecture tests
  • Loading branch information
yassinedoghri committed Sep 29, 2024
1 parent 76526f2 commit 343154a
Show file tree
Hide file tree
Showing 25 changed files with 6,904 additions and 2,281 deletions.
5 changes: 3 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ FROM "mcr.microsoft.com/devcontainers/php:1-8.2-bullseye"

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

# Add php intl extension
RUN install-php-extensions intl
# Add php intl extension + xdebug coverage mode
RUN install-php-extensions intl \
&& echo "xdebug.mode = debug,coverage" >> /usr/local/etc/php/conf.d/xdebug.ini
10 changes: 5 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
// Path is relataive to the devcontainer.json file.
"dockerfile": "Dockerfile"
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "composer install && pnpm install",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [8000],
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/git:1": {}
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/node:1": {}
},
// Configure tool-specific properties.
"customizations": {
Expand All @@ -25,14 +28,11 @@
"breezelin.phpstan",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"github.vscode-github-actions",
"pflannery.vscode-versionlens",
"streetsidesoftware.code-spell-checker",
"yzhang.markdown-all-in-one"
]
}
}
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
19 changes: 19 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file tells which files and directories should be ignored and
# NOT downloaded when using composer to pull down a project with
# the --prefer-dist option selected. Used to remove development
# specific files so user has a clean download.

/.devcontainer/ export-ignore
/.github/ export-ignore
/tests/ export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.releaserc export-ignore
/CONTRIBUTING.md export-ignore
/ecs.php export-ignore
/package.json export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/pnpm-lock.yaml export-ignore
/rector.php export-ignore
/SECURITY.md export-ignore
46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE/1-bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: "\U0001F41B Bug Report"
about: "If something isn't working as expected \U0001F914."
title: ""
labels: "i: bug"
assignees: ""
---

**Describe the bug**

A clear and concise description of what the bug is.

**To Reproduce**

Steps to reproduce the behavior:

1. Go to '…'
2. Click on '…'
3. Scroll down to '…'
4. See error

**Expected behavior**

A clear and concise description of what you expected to happen.

**Screenshots**

If applicable, add screenshots to help explain your problem.

**Context (please complete the following information):**

- `php-icons` version: [e.g. 1.0.0]
- OS: [e.g. Ubuntu 22.04]
- Browser: [e.g. firefox]

Add any other context about the problem here.

**Possible fixes**

If you can, link to the line of code that might be responsible for the problem.

---

- [ ] I confirm that I have read the
[Contributing Guide](./../../CONTRIBUTING.md) and
[Security Guide](./../../SECURITY.md)
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/2-feature-request
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: "\U0001F680 Feature Request"
about: "I have a suggestion (and may want to implement it \U0001F642)!"
title: ""
labels: "i: enhancement"
assignees: ""
---

**Is your feature request related to a problem? Please describe.**

A clear and concise description of what the problem is. Ex. I'm always
frustrated when [...]

**Describe the solution you'd like**

A clear and concise description of what you want to happen.

**Describe alternatives you've considered**

A clear and concise description of any alternative solutions or features you've
considered.

**Additional context**

Add any other context or screenshots about the feature request here.

---

- [ ] I confirm that I have read the
[Contributing Guide](./../../CONTRIBUTING.md) and
[Security Guide](./../../SECURITY.md)
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: GitHub Community Support
url: https://github.com/yassinedoghri/codeigniter-icons/discussions
about: Please ask and answer questions here.
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
- Fill in the form below correctly. This will help us to understand the PR and also work on it.
-->

### Subject:

- [ ] Bug fix
- [ ] New feature

### Description:

_Clearly and concisely describe what's in this pull request. Include
screenshots, if necessary._

### Related:

_Link to the issue(s) your PR is solving. If it doesn't exist, remove the
"Related" section_

---

- [ ] I confirm that I have read the [Contributing Guide](./../CONTRIBUTING.md)
and [Security Guide](./../SECURITY.md)
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
21 changes: 21 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: codeigniter-icons-pull-request-lint

on:
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: codeigniter-icons-release

on:
push:
branches: [develop, main]
pull_request:
branches: [develop, main]

permissions:
contents: read

jobs:
quality:
runs-on: ubuntu-latest

steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4

- name: 🐘 Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2

- name: ✅ Validate composer.json and composer.lock
run: composer validate --strict

- name: 🗂️ Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: 📥 Install dependencies
run: composer install --prefer-dist --no-progress

- name: ✨ Quality check
run: |
composer validate --strict --ansi
composer run-script style
composer run-script phpstan
composer run-script rector
composer run-script pest:type-coverage
- name: 🧪 Run tests and collect coverage
run: vendor/bin/pest --parallel --coverage-clover coverage.xml

- name: 📤 Upload coverage to Codecov
uses: codecov/codecov-action@v3

release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: [quality]
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
strategy:
matrix:
node-version: [20]
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN_SEMANTIC_RELEASE }}

- name: 📥 Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: ⚙️ Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"

- name: 🚀 Run Semantic Release
run: |
pnpm install
pnpx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
/vendor/

/.pnpm-store/
/node_modules/

coverage.xml
19 changes: 19 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"prepareCmd": "pnpm exec prettier --write CHANGELOG.md"
}
],
"@semantic-release/npm",
"@semantic-release/git",
"@semantic-release/github"
]
}
Loading

0 comments on commit 343154a

Please sign in to comment.