Skip to content

Commit 16e4525

Browse files
authored
Code refactor (#269)
1 parent 8e97df0 commit 16e4525

File tree

9 files changed

+1188
-1199
lines changed

9 files changed

+1188
-1199
lines changed

.eslintrc.json

+58-52
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,60 @@
11
{
2-
"plugins": ["@typescript-eslint"],
3-
"extends": ["plugin:github/recommended"],
4-
"parser": "@typescript-eslint/parser",
5-
"parserOptions": {
6-
"ecmaVersion": 9,
7-
"sourceType": "module",
8-
"project": "./tsconfig.json"
9-
},
10-
"rules": {
11-
"i18n-text/no-en": "off",
12-
"eslint-comments/no-use": "off",
13-
"import/no-namespace": "off",
14-
"no-unused-vars": "off",
15-
"@typescript-eslint/no-unused-vars": "error",
16-
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
17-
"@typescript-eslint/no-require-imports": "error",
18-
"@typescript-eslint/array-type": "error",
19-
"@typescript-eslint/await-thenable": "error",
20-
"@typescript-eslint/ban-ts-comment": "error",
21-
"camelcase": "off",
22-
"@typescript-eslint/consistent-type-assertions": "error",
23-
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
24-
"@typescript-eslint/func-call-spacing": ["error", "never"],
25-
"@typescript-eslint/no-array-constructor": "error",
26-
"@typescript-eslint/no-empty-interface": "error",
27-
"@typescript-eslint/no-explicit-any": "error",
28-
"@typescript-eslint/no-extraneous-class": "error",
29-
"@typescript-eslint/no-for-in-array": "error",
30-
"@typescript-eslint/no-inferrable-types": "error",
31-
"@typescript-eslint/no-misused-new": "error",
32-
"@typescript-eslint/no-namespace": "error",
33-
"@typescript-eslint/no-non-null-assertion": "warn",
34-
"@typescript-eslint/no-unnecessary-qualifier": "error",
35-
"@typescript-eslint/no-unnecessary-type-assertion": "error",
36-
"@typescript-eslint/no-useless-constructor": "error",
37-
"@typescript-eslint/no-var-requires": "error",
38-
"@typescript-eslint/prefer-for-of": "warn",
39-
"@typescript-eslint/prefer-function-type": "warn",
40-
"@typescript-eslint/prefer-includes": "error",
41-
"@typescript-eslint/prefer-string-starts-ends-with": "error",
42-
"@typescript-eslint/promise-function-async": "error",
43-
"@typescript-eslint/require-array-sort-compare": "error",
44-
"@typescript-eslint/restrict-plus-operands": "error",
45-
"semi": "off",
46-
"@typescript-eslint/semi": ["error", "never"],
47-
"@typescript-eslint/type-annotation-spacing": "error",
48-
"@typescript-eslint/unbound-method": "error"
49-
},
50-
"env": {
51-
"node": true,
52-
"es6": true
53-
}
2+
"plugins": ["@typescript-eslint"],
3+
"extends": ["plugin:github/recommended"],
4+
"parser": "@typescript-eslint/parser",
5+
"parserOptions": {
6+
"ecmaVersion": 9,
7+
"sourceType": "module",
8+
"project": "./tsconfig.json"
9+
},
10+
"rules": {
11+
"i18n-text/no-en": "off",
12+
"eslint-comments/no-use": "off",
13+
"import/no-namespace": "off",
14+
"no-unused-vars": "off",
15+
"@typescript-eslint/no-unused-vars": "error",
16+
"@typescript-eslint/explicit-member-accessibility": [
17+
"error",
18+
{"accessibility": "no-public"}
19+
],
20+
"@typescript-eslint/no-require-imports": "error",
21+
"@typescript-eslint/array-type": "error",
22+
"@typescript-eslint/await-thenable": "error",
23+
"@typescript-eslint/ban-ts-comment": "error",
24+
"camelcase": "off",
25+
"@typescript-eslint/consistent-type-assertions": "error",
26+
"@typescript-eslint/explicit-function-return-type": [
27+
"error",
28+
{"allowExpressions": true}
29+
],
30+
"@typescript-eslint/func-call-spacing": ["error", "never"],
31+
"@typescript-eslint/no-array-constructor": "error",
32+
"@typescript-eslint/no-empty-interface": "error",
33+
"@typescript-eslint/no-explicit-any": "error",
34+
"@typescript-eslint/no-extraneous-class": "error",
35+
"@typescript-eslint/no-for-in-array": "error",
36+
"@typescript-eslint/no-inferrable-types": "error",
37+
"@typescript-eslint/no-misused-new": "error",
38+
"@typescript-eslint/no-namespace": "error",
39+
"@typescript-eslint/no-non-null-assertion": "warn",
40+
"@typescript-eslint/no-unnecessary-qualifier": "error",
41+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
42+
"@typescript-eslint/no-useless-constructor": "error",
43+
"@typescript-eslint/no-var-requires": "error",
44+
"@typescript-eslint/prefer-for-of": "warn",
45+
"@typescript-eslint/prefer-function-type": "warn",
46+
"@typescript-eslint/prefer-includes": "error",
47+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
48+
"@typescript-eslint/promise-function-async": "error",
49+
"@typescript-eslint/require-array-sort-compare": "error",
50+
"@typescript-eslint/restrict-plus-operands": "error",
51+
"semi": "off",
52+
"@typescript-eslint/semi": ["error", "never"],
53+
"@typescript-eslint/type-annotation-spacing": "error",
54+
"@typescript-eslint/unbound-method": "error"
55+
},
56+
"env": {
57+
"node": true,
58+
"es6": true
5459
}
60+
}

.github/dependabot.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ updates:
44
directory: /
55
schedule:
66
interval: monthly
7-
time: "04:00"
7+
time: '04:00'
88

99
- package-ecosystem: npm
1010
directory: /
1111
schedule:
1212
interval: monthly
13-
time: "04:00"
13+
time: '04:00'
1414
open-pull-requests-limit: 10

.github/workflows/check-dist.yml

-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@ jobs:
5050
with:
5151
name: dist
5252
path: dist/
53-

.github/workflows/test.yml

+23-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,28 @@ jobs:
3636
concurrent_skipping: 'never'
3737
skip_after_successful_duplicate: 'true'
3838
paths_ignore: '["**/README.md", "**/docs/**"]'
39-
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
39+
40+
- name: Print outputs
41+
run: |
42+
echo '::group::should_skip'
43+
echo '${{ steps.skip_check.outputs.should_skip }}'
44+
echo '::endgroup::'
45+
46+
echo '::group::reason'
47+
echo '${{ steps.skip_check.outputs.reason }}'
48+
echo '::endgroup::'
49+
50+
echo '::group::skipped_by'
51+
echo '${{ toJSON(fromJSON(steps.skip_check.outputs.skipped_by)) }}'
52+
echo '::endgroup::'
53+
54+
echo '::group::paths_result'
55+
echo '${{ toJSON(fromJSON(steps.skip_check.outputs.paths_result)) }}'
56+
echo '::endgroup::'
57+
58+
echo '::group::changed_files'
59+
echo '${{ toJSON(fromJSON(steps.skip_check.outputs.changed_files)) }}'
60+
echo '::endgroup::'
4061
4162
main_job:
4263
needs: pre_job
@@ -79,10 +100,10 @@ jobs:
79100
cancel_others: 'true'
80101
concurrent_skipping: 'outdated_runs'
81102
skip_after_successful_duplicate: 'true'
103+
# Test 'do_not_skip' with 'pull_request'
82104
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
83105

84106
- name: Simulate task
85107
if: ${{ steps.skip_check.outputs.should_skip == 'false' }}
86108
run: |
87109
echo "Do stuff..." && sleep 30
88-

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,20 @@ Returns information about the workflow run which caused the current run to be sk
165165

166166
**Example:**
167167

168-
```jsonc
168+
```json
169169
{
170+
"id": 1709469369,
171+
"runNumber": 737,
170172
"event": "pull_request",
171173
"treeHash": "e3434bb7aeb3047d7df948f09419ac96cf03d73e",
172174
"commitHash": "4a0432e823468ecff81a978165cb35586544c795",
173175
"status": "completed",
174176
"conclusion": "success",
175-
"html_url": "https://github.com/fkirc/skip-duplicate-actions/actions/runs/1709469369",
177+
"htmlUrl": "https://github.com/fkirc/skip-duplicate-actions/actions/runs/1709469369",
176178
"branch": "master",
177179
"repo": "fkirc/skip-duplicate-actions",
178-
"runId": 1709469369,
179180
"workflowId": 2640563,
180-
"createdAt": "2022-01-17T18:56:06Z",
181-
"runNumber": 737
181+
"createdAt": "2022-01-17T18:56:06Z"
182182
}
183183
```
184184

@@ -195,7 +195,9 @@ Returns information for each configured filter in `paths_filter`.
195195
"frontend": {
196196
"should_skip": true,
197197
"backtrack_count": 1,
198-
"skipped_by": { // Information about the workflow run },
198+
"skipped_by": {
199+
// Information about the workflow run
200+
},
199201
"backend": {
200202
"should_skip": false,
201203
"backtrack_count": 1,
@@ -230,7 +232,8 @@ You can use `skip-duplicate-actions` to either skip individual steps or entire j
230232
To minimize changes to existing jobs, it is often easier to skip entire jobs.
231233

232234
> **Note**
233-
> - You may need to use [`fromJSON`](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) to access properties of object outputs. For example, for `skipped_by.runId`, you can use the expression: `${{ fromJSON(steps.skip_check.outputs.skipped_by).runId }}`.
235+
>
236+
> - You may need to use [`fromJSON`](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) to access properties of object outputs. For example, for `skipped_by.id`, you can use the expression: `${{ fromJSON(steps.skip_check.outputs.skipped_by).id }}`.
234237
> - For GitHub repositories where [default permissions](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) for `GITHUB_TOKEN` has been set to "permissive (read-only)", the following lines must be included in the workflow (see [permissions syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)):
235238
> ```yaml
236239
> # Minimum permissions required by skip-duplicate-actions

0 commit comments

Comments
 (0)