Skip to content

Commit

Permalink
feat: initialize github actions workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Fery Wardiyanto <ferywardiyanto@gmail.com>
  • Loading branch information
feryardiant committed Oct 22, 2024
1 parent 0909ab5 commit dcf447b
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 17 deletions.
17 changes: 8 additions & 9 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

# Exclude unused files
# see: https://redd.it/2jzp6k
/.codeclimate.yml export-ignore
/.coveralls.yml export-ignore
/.travis.yml export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
/tests export-ignore
/README.md export-ignore
.codeclimate.yml export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.github export-ignore
composer.lock export-ignore
package.json export-ignore
tests export-ignore
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2

updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: monthly
timezone: "Asia/Jakarta"

- package-ecosystem: composer
directory: "/"
schedule:
interval: weekly
timezone: "Asia/Jakarta"
versioning-strategy: lockfile-only
groups:
dependencies:
dependency-type: "production"
patterns: ['*']
dev-dependencies:
dependency-type: "development"
patterns: ['*']

- package-ecosystem: npm
directory: "/"
schedule:
interval: monthly
timezone: "Asia/Jakarta"
versioning-strategy: increase-if-necessary
groups:
dependencies:
patterns: ['*']
34 changes: 34 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
api:
- changed-files:
- any-glob-to-any-file: ["src/**.php"]

dependencies:
- changed-files:
- any-glob-to-any-file:
- "composer.json"
- "package.json"
- "pnpm-lock.yaml"

documentation:
- changed-files:
- any-glob-to-any-file: ["**.md"]

enhancement:
- changed-files:
- any-glob-to-any-file: "**"

experimental:
- head-branch: ["^test", "test"]

features:
- head-branch: ["^feat", "feat"]

fixes:
- head-branch: ["^fix", "fix"]

integration:
- changed-files:
- any-glob-to-any-file:
- ".github/**.yml"
- "scripts/**"
- "tests/**.php"
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Release

on:
push:
tags: ['v*.*.*']

jobs:
publish:
name: Publish
uses: projek-xyz/actions/.github/workflows/release.yml@main
106 changes: 106 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Tests

on:
schedule: # scheduled to run at 23.00 on Saturday (UTC), means 6.00 on Monday (WIB)
- cron: '0 23 * * 6'
pull_request:
branches: [main]
push:
branches: [main]

env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_URL: https://codeclimate.com/downloads/test-reporter/test-reporter-0.7.0-linux-amd64

jobs:
prepare:
name: Prepare
uses: projek-xyz/actions/.github/workflows/configure.yml@main
with:
php-version: 8.2
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

tests:
name: Runs on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: prepare
env:
GIT_COMMIT_SHA: ${{ github.sha }}
GIT_BRANCH: ${{ needs.prepare.outputs.target-branch }}

strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

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

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ needs.prepare.outputs.composer-cache }}
key: php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: php-${{ matrix.php }}-composer-

- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-suggest

# https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
# https://github.com/deivid-rodriguez/pry-byebug/blob/377e5b7d229a157bb896f21d776f71fc389a5c00/.github/workflows/ubuntu.yml#L46-L57
- name: Set ENV for CodeClimate (pull_request)
if: github.event_name == 'pull_request'
run: echo "GIT_BRANCH=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV

- name: Spec
run: composer spec

- name: Generate reports for Coveralls
if: needs.prepare.outputs.has-coveralls == '1'
uses: coverallsapp/github-action@v2
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: php-${{ matrix.php }}
file: test/lcov.info
parallel: true

- name: Generate reports for CodeClimate
if: needs.prepare.outputs.has-codeclimate == '1'
id: reports
env:
CODECLIMATE_REPORT: tests/codeclimate.${{ matrix.php }}.json
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}
run: |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t lcov -o $CODECLIMATE_REPORT test/lcov.info
- name: Save Coverage Reports
if: needs.prepare.outputs.has-codeclimate == '1'
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.php }}
path: tests/codeclimate.*.json

reports:
name: Reports
needs: [prepare, tests]
if: needs.prepare.outputs.should-reports == '1'
uses: projek-xyz/actions/.github/workflows/report.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
has-coveralls: ${{ needs.prepare.outputs.has-coveralls == '1' }}
has-codeclimate: ${{ needs.prepare.outputs.has-codeclimate == '1' }}
23 changes: 15 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
# Generic
# --------------------------
Thumbs.db
Desktop.ini
Icon?
.directory
.DS_Store
._*
*.cache
*.old
*.crt
*.log
*.old
*.key
*.pem
*.tmp
*.zip
*~

# Development files
# --------------------------
.php-version
tests/clover.xml
coveralls-upload.json
.tool-versions

# Dependency folders
# --------------------------
composer.lock
node_modules/
vendor/
node_modules
package-lock.json
pnpm-lock.yaml
vendor
yarn.lock

# IDE Project Configurations
# --------------------------
.idea
.settings
.vscode
.project
*.sublime-*

# But Keep these
# --------------------------
!.gitkeep

0 comments on commit dcf447b

Please sign in to comment.