Skip to content

Commit

Permalink
feat: migrate action from datalens public (#2)
Browse files Browse the repository at this point in the history
* feat: migrate action from datalens public

* docs: add docs

* refactor: merge package.json

* feat: add test task
  • Loading branch information
flukolo4ek authored Oct 21, 2024
1 parent 7ea1c50 commit 7034d46
Show file tree
Hide file tree
Showing 15 changed files with 11,102 additions and 838 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@gravity-ui/eslint-config"]
}
4 changes: 4 additions & 0 deletions .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ jobs:
- name: Lint PR
run: |
task lint
- name: Test
run: |
task test
76 changes: 72 additions & 4 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,81 @@ jobs:
uses: actions/checkout@v4

- name: Test Run
id: test-run
id: test-run-default
uses: ./
with:
placeholder: "test_placeholder"
github_pr_title: "feat: BI-1234 lyalyalya topolya"

- name: Assert placeholder
uses: nick-fields/assert-action@v2
with:
actual: ${{ steps.test-run.outputs.placeholder }}
expected: "test_placeholder"
actual: ${{ steps.test-run-default.outcome }}
expected: "success"

e2e-with-components:
runs-on: ubuntu-20.04

permissions:
contents: read

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

- name: Test Run
id: test-run-with-components
uses: ./
with:
github_pr_title: "feat(docs, auth): BI-1234 lyalyalya topolya"

- name: Assert placeholder
uses: nick-fields/assert-action@v2
with:
actual: ${{ steps.test-run-with-components.outcome }}
expected: "success"

e2e-wrong-type:
runs-on: ubuntu-20.04

permissions:
contents: read

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

- name: Test Run
id: test-run-wrong-type
uses: ./
with:
github_pr_title: "new-feature: BI-1234 lyalyalya topolya" # legacy type
continue-on-error: true

- name: Assert placeholder
uses: nick-fields/assert-action@v2
with:
actual: ${{ steps.test-run-wrong-type.outcome }}
expected: "failure"

e2e-without-ticket:
runs-on: ubuntu-20.04

permissions:
contents: read

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

- name: Test Run
id: test-run-without-ticket
uses: ./
with:
github_pr_title: "feat: lyalyalya topolya"
continue-on-error: true

- name: Assert placeholder
uses: nick-fields/assert-action@v2
with:
actual: ${{ steps.test-run-without-ticket.outcome }}
expected: "failure"
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![CI](https://github.com/datalens-tech/commitlint-action/workflows/Check%20PR/badge.svg)](https://github.com/datalens-tech/commitlint-action/actions?query=workflow%3A%22%22Check+PR%22%22)
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Template-blue.svg)](https://github.com/marketplace/actions/template)

Action for validate PR tilte for more more semantic meaning to your git history
Action for validate PR tilte for more semantic meaning to your git history

## Usage

Expand All @@ -12,26 +12,21 @@ Action for validate PR tilte for more more semantic meaning to your git history
```yaml
jobs:
template:
permissions:
contents: read

steps:
- name: Template
id: template
- name: Validate commit title
id: validate
uses: datalens-tech/commitlint-action@v1
```
### Action Inputs
| Name | Description | Default |
| ------------- | ------------ | ------- |
| `placeholder` | Placeholder. | |
| Name | Description | Default |
| ----------------- | --------------- | -------------------------------------- |
| `github_pr_title` | GitHub PR title | ${{ github.event.pull_request.title }} |

### Action Outputs

| Name | Description |
| ------------- | ------------ |
| `placeholder` | Placeholder. |
None

## Development

Expand Down
8 changes: 8 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ tasks:
cmds:
- task: _with_nvm
vars: { COMMAND: "npm run lint:fix" }
- task: _with_nvm
vars: { COMMAND: "npm run eslint:fix" }

test:
desc: Test project by jest
cmds:
- task: _with_nvm
vars: { COMMAND: "npm run test" }

clean:
desc: Clean project environment
Expand Down
40 changes: 24 additions & 16 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
name: "Template"
description: "Action for validate PR tilte for more more semantic meaning to your git history"
name: "Commitlint PR Title"
description: "Commitlints PR title input according to config"

inputs:
placeholder:
description: "Placeholder input to be replaced by real inputs"
required: true
default: "placeholder"

outputs:
placeholder:
description: "Placeholder output to be replaced by real outputs"
value: ${{steps.placeholder.outputs.placeholder }}
github_pr_title:
description: "GitHub PR title"
default: ${{ github.event.pull_request.title }}

runs:
using: "composite"
using: composite

steps:
- name: Placeholder
id: placeholder
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "22"

- name: Install Dependencies
shell: bash
working-directory: ${{ github.action_path }}
run: |
npm ci
- name: Lint Commit
id: validation
shell: bash
working-directory: ${{ github.action_path }}
run: |
echo "::set-output name=placeholder::${{ inputs.placeholder }}"
echo "$PR_TITLE" | npx commitlint --config ${{ github.action_path }}/src/commitlint.config.js
env:
PR_TITLE: ${{ inputs.github_pr_title }}

# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#branding
branding:
icon: "message-square"
color: "gray-dark"
3 changes: 3 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [["@babel/preset-env", { targets: { node: "current" } }]],
};
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
transform: {
"^.+\\.(js|jsx)$": "babel-jest",
},
transformIgnorePatterns: ["node_modules/(?!@ngrx|(?!deck.gl)|ng-dynamic)"],
};
Loading

0 comments on commit 7034d46

Please sign in to comment.