Skip to content

Commit

Permalink
feat: add test task
Browse files Browse the repository at this point in the history
  • Loading branch information
flukolo4ek committed Oct 21, 2024
1 parent e0ba4f0 commit 93c2c1c
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
node_modules/
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-all
72 changes: 69 additions & 3 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,79 @@ jobs:
uses: actions/checkout@v4

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

- name: Assert placeholder
uses: nick-fields/assert-action@v2
with:
actual: ${{ steps.test-run.outputs.result }}
expected: "ok!"
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

- 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"

- name: Assert placeholder
uses: nick-fields/assert-action@v2
with:
actual: ${{ steps.test-run-without-ticket.outcome }}
expected: "failure"
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ jobs:

### Action Outputs

| Name | Description |
| -------- | --------------------------- |
| `result` | Result of commitlint action |
None

## Development

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

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

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

clean:
desc: Clean project environment
cmds:
Expand Down
6 changes: 0 additions & 6 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ inputs:
description: "GitHub PR title"
default: ${{ github.event.pull_request.title }}

outputs:
result:
description: "Result of commitlint action"
value: ${{ steps.validation.outputs.result }}

runs:
using: composite

Expand All @@ -32,7 +27,6 @@ runs:
working-directory: ${{ github.action_path }}
run: |
echo "$PR_TITLE" | npx commitlint --config ${{ github.action_path }}/src/commitlint.config.js
echo "result=ok!" >> $GITHUB_OUTPUT
env:
PR_TITLE: ${{ inputs.github_pr_title }}

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"lint:check:prettier": "prettier --check .",
"lint:fix": "npm run lint:fix:prettier",
"lint:fix:prettier": "prettier --write .",
"prepare": "husky"
"prepare": "husky",
"test": "jest",
"eslint:fix": "eslint --fix",
"all": "npm run eslint:fix && npm run lint:fix:prettier && npm run test"
}
}

0 comments on commit 93c2c1c

Please sign in to comment.