Skip to content

Commit

Permalink
feat: Set up dependabot (#101)
Browse files Browse the repository at this point in the history
* Add dependabot config

* Add automerge workflow

* Fix formatting

* ci: Generate code

* Update .prettierrc.json

* Simplify generate

* Add ..editorconfig

* Add .prettierrc for all non-PHP file types

* ci: Generate code

* End .editorconfig file with a newline

* Use .prettierrc.json for both php and non-php files

* ci: Generate code

---------

Co-authored-by: Seam Bot <[email protected]>
  • Loading branch information
andrii-balitskyi and seambot authored Apr 24, 2024
1 parent dba904c commit 9264c77
Show file tree
Hide file tree
Showing 114 changed files with 4,721 additions and 5,448 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.php]
indent_size = 4

[Makefile]
indent_style = tab
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ inputs:
node_version:
description: The Node.js version.
required: false
default: "20"
default: '20'
registry_url:
description: The Node.js package registry URL.
required: false
default: https://registry.npmjs.org
install_dependencies:
description: Install dependencies.
required: false
default: "true"
default: 'true'

runs:
using: composite
Expand Down
24 changes: 24 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: daily
commit-message:
prefix: feat
include: scope
allow:
- dependency-type: development
ignore:
- dependency-name: '*'
update-types:
- 'version-update:semver-major'
groups:
seam:
dependency-type: development
patterns:
- '@seamapi/*'
update-types:
- patch
- minor
62 changes: 62 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: Automerge

on:
pull_request:
branches:
- main

jobs:
changes:
name: Get changes
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.actor == 'dependabot[bot]'
permissions:
checks: read
outputs:
has_changes: ${{ steps.changed.outputs.any_changed == 'true' }}
is_generation_successful: ${{ steps.checks.outputs.conclusion == 'success' }}
steps:
- name: Wait for checks
uses: fountainhead/[email protected]
id: checks
with:
checkName: Generate code
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get changed generated files
id: changed
uses: tj-actions/changed-files@v44
with:
files: |
src/**
merge:
name: Merge
runs-on: ubuntu-latest
timeout-minutes: 30
needs: changes
if: needs.changes.outputs.has_changes == 'true'
steps:
- name: Approve pull request
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Merge pull request
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
close:
name: Close
runs-on: ubuntu-latest
timeout-minutes: 30
needs: changes
if: needs.changes.outputs.has_changes == 'false' && needs.changes.outputs.is_generation_successful == 'true'
steps:
- name: Close pull request
run: gh pr close "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ jobs:
- name: Setup
uses: ./.github/actions/setup
with:
install_dependencies: "false"
install_dependencies: 'false'
- name: Normalize package-lock.json
run: npm install
- name: Generate SDK
run: npm run generate
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "ci: Generate code"
commit_message: 'ci: Generate code'
commit_user_name: ${{ secrets.GIT_USER_NAME }}
commit_user_email: ${{ secrets.GIT_USER_EMAIL }}
commit_author: ${{ secrets.GIT_USER_NAME }} <${{ secrets.GIT_USER_EMAIL }}>
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
with:
token: ${{ secrets.GH_TOKEN }}
prerelease: ${{ contains(github.ref_name, '-') }}
files: ""
files: ''
body_path: ${{ github.workspace }}/${{ steps.changelog.outputs.outfile }}
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: PHP Test
on: ["pull_request"]
on: ['pull_request']
jobs:
test:
if: "!contains(github.event.head_commit.message, 'skip ci')"
Expand All @@ -11,7 +11,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
php-version: '8.0'
- run: composer install
- run: composer exec phpunit tests
env:
Expand Down
1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

16 changes: 14 additions & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"semi": false,
"endOfLine": "lf"
"plugins": ["@prettier/plugin-php"],
"parser": "php",

"overrides": [
{
"files": "**/*.{js,json,yml,md}",
"options": {
"semi": false,
"singleQuote": true,
"jsxSingleQuote": true,
"endOfLine": "lf"
}
}
]
}
26 changes: 26 additions & 0 deletions generate-routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'

import {
generatePhpSDK as generateSdk,
writeFs,
} from '@seamapi/nextlove-sdk-generator'
import { openapi } from '@seamapi/types/connect'
import { deleteAsync } from 'del'

const libDirName = 'src'

const rootPath = dirname(fileURLToPath(import.meta.url))
const outputPath = resolve(rootPath, libDirName)

await deleteAsync(outputPath)

const fileSystem = await generateSdk({
openApiSpecObject: openapi,
})

const files = Object.entries(fileSystem).filter(([fileName]) =>
fileName.startsWith(`${libDirName}/`),
)

writeFs(rootPath, Object.fromEntries(files))
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"license": "MIT",
"scripts": {
"postversion": "git push --follow-tags",
"generate": "node ./scripts/generate.js",
"postgenerate": "prettier --write --ignore-path .gitignore ."
"generate": "node generate-routes.js",
"postgenerate": "npm run format",
"format": "prettier --write --ignore-path .gitignore ."
},
"devDependencies": {
"@prettier/plugin-php": "^0.22.1",
Expand Down
37 changes: 0 additions & 37 deletions scripts/generate.js

This file was deleted.

32 changes: 15 additions & 17 deletions src/Objects/AccessCode.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions src/Objects/AcsAccessGroup.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9264c77

Please sign in to comment.