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

Ory-specific GitHub action for conventional commits #94

Merged
merged 33 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Tests

on:
pull_request:
types:
- opened
- reopened
push:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: cache-node
uses: actions/cache@v3
with:
path: conventional_commit_config/node_modules
key:
${{ runner.os }}-cococo-node-${{
hashFiles('conventional_commit_config/package-lock.json') }}
- run: npm ci --legacy-peer-deps
if: steps.cache-node.outputs.cache-hit != 'true'
- run: cd conventional_commit_config && npm run test
2 changes: 2 additions & 0 deletions conventional_commit_config/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
lib
19 changes: 19 additions & 0 deletions conventional_commit_config/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
env: {
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier",
],
rules: {
"no-var": 0,
"import/order": ["error", { alphabetize: { order: "asc" } }],
},
}
2 changes: 2 additions & 0 deletions conventional_commit_config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib/
node_modules/
5 changes: 5 additions & 0 deletions conventional_commit_config/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"spec": "src/**/*.test.ts",
"ui": "tdd",
"require": "ts-node/register"
}
2 changes: 2 additions & 0 deletions conventional_commit_config/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
lib/
37 changes: 37 additions & 0 deletions conventional_commit_config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Conventional Commits GitHub Action
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!


This Github Action is only used in
https://github.com/ory/meta/blob/master/templates/repository/common/.github/workflows/conventional_commits.yml.
It allows individual repositories to override the default scopes for
conventional commits via a config file.

This config file must be at `.github/conventional_commits.json` in your
repository and have content that looks like this:

```json
{
"$schema": "https://raw.githubusercontent.com/ory/ci/master/conventional_commit_config/dist/config.schema.json",
"types": ["type1", "type2"],
"addTypes": ["type3", "type4"],
"scopes": ["scope1", "scope2"],
"addScopes": ["scope3", "scope4"],
"requireScope": true
}
```

You never need all options together. Set only the ones you need.

| name | description | default |
| -------------- | -------------------------------------------------- | ------- |
| _types_ | overrides the default types | `[]` |
| _addTypes_ | adds the given types to the set of default types | `[]` |
| _scopes_ | overrides the default scopes | `[]` |
| _addScopes_ | adds the given scopes to the set of default scopes | `[]` |
| _requireScope_ | enforces a scope in pull requests titles | `false` |

### Development

GitHub Actions don't run `npm install` in production. This GitHub Actions
therefore bundles external production dependencies into `dist/index.js`. To keep
this file up to date, please remember to run `npm run build` before committing.
Otherwise, your changes won't show up in production.
28 changes: 28 additions & 0 deletions conventional_commit_config/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Conventional commits configuration
description: determines the configuration for conventional commits

inputs:
config_path:
description: path of the config file
required: true
default_types:
description: the default types to use
required: true
default_scopes:
description: the default scopes to use
required: true
default_require_scope:
description: whether to require scopes by default
required: true

outputs:
types:
description: the types to use
scopes:
description: the scopes to use
requireScope:
description: whether to require scopes by default

runs:
using: node16
main: dist/index.js
45 changes: 45 additions & 0 deletions conventional_commit_config/dist/config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "data format of the configuration file",
"properties": {
"$schema": {
"description": "link to JSON schema",
"type": "string"
},
"addScopes": {
"description": "add to the default scopes",
"items": {
"type": "string"
},
"type": "array"
},
"addTypes": {
"description": "add to the default types",
"items": {
"type": "string"
},
"type": "array"
},
"requireScope": {
"description": "whether to enforce a scope in pull request titles",
"type": "boolean"
},
"scopes": {
"description": "override the default scopes",
"items": {
"type": "string"
},
"type": "array"
},
"types": {
"description": "override the default types",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
}

Loading