Skip to content

Commit 447c2d2

Browse files
feat: initial version of keyphrase-checker action (#1)
* feat: initial version of keyphrase-checker action * chore: update CI and linter workflows for improved consistency
1 parent d434b52 commit 447c2d2

16 files changed

Lines changed: 464 additions & 432 deletions

File tree

.env.example

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@
33
# Do not commit your actual .env file to Git! This may contain secrets or other
44
# private information.
55

6+
7+
# ACTION INPUTS
8+
9+
# Provide text or text file
10+
# INPUT_TEXT-FILE="README.txt"
11+
INPUT_TEXT="Hello @ProfessortoCat, how is life at GitHub?"
12+
13+
# Keyphrase to search for in text or file
14+
INPUT_KEYPHRASE="@professortocat"
15+
16+
# Should the search be case-sensitive?
17+
INPUT_CASE-SENSITIVE=false
18+
19+
# Minimum number of occurrences for the action to be successful
20+
INPUT_MINIMUM-OCCURRENCES=1
21+
622
# Enable/disable step debug logging (default: `false`). For local debugging, it
723
# may be useful to set it to `true`.
824
ACTIONS_STEP_DEBUG=true
925

10-
# GitHub Actions inputs should follow `INPUT_<name>` format (case-sensitive).
11-
# Hyphens should not be converted to underscores!
12-
INPUT_MILLISECONDS=2400
1326

1427
# GitHub Actions default environment variables. These are set for every run of a
1528
# workflow and can be used in your actions. Setting the value here will override

.github/workflows/ci.yml

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,70 @@ jobs:
4444
id: npm-ci-test
4545
run: npm run ci-test
4646

47-
test-action:
48-
name: GitHub Actions Test
47+
positive-tests:
48+
name: Positive Action Tests
4949
runs-on: ubuntu-latest
50-
5150
steps:
5251
- name: Checkout
53-
id: checkout
5452
uses: actions/checkout@v4
5553

56-
- name: Test Local Action
57-
id: test-action
54+
- name: Test direct text (not case-sensitive)
55+
id: test-direct-text
56+
uses: ./
57+
with:
58+
text: "Hey @PrOfEssortocat, I'm finished with my task"
59+
keyphrase: '@professortocat'
60+
61+
- name: Test text file (not case-sensitive)
62+
id: test-text-file
63+
uses: ./
64+
with:
65+
text-file: ./__tests__/test-mixed-case.md
66+
keyphrase: 'github'
67+
minimum-occurrences: '3'
68+
69+
negative-tests:
70+
name: Negative Action Tests
71+
runs-on: ubuntu-latest
72+
steps:
73+
- uses: actions/checkout@v4
74+
- name: Test direct text (case-sensitive)
75+
id: test-direct-text
76+
continue-on-error: true
77+
uses: ./
78+
with:
79+
text: "Hey @PrOfEssortocat, I'm finished with my task"
80+
keyphrase: '@professortocat'
81+
case-sensitive: true
82+
83+
- name: Check output for direct text test
84+
run: |
85+
if [[ "${{ steps.test-direct-text.outcome }}" != "failure" ]]; then
86+
echo "Expected the test to fail but it passed"
87+
exit 1
88+
fi
89+
if [[ "${{ steps.test-direct-text.outputs.occurrences }}" != "0" ]]; then
90+
echo "Expected 0 occurrences but found ${{ steps.test-direct-text.outputs.occurrences }}"
91+
exit 1
92+
fi
93+
94+
- name: Test text file (case-sensitive)
95+
id: test-text-file
96+
continue-on-error: true
5897
uses: ./
5998
with:
60-
milliseconds: 2000
99+
text-file: ./__tests__/test-mixed-case.md
100+
keyphrase: 'github'
101+
minimum-occurrences: 3
102+
case-sensitive: true
61103

62-
- name: Print Output
63-
id: output
64-
run: echo "${{ steps.test-action.outputs.time }}"
104+
- name: Check output for text file test
105+
run: |
106+
if [[ "${{ steps.test-text-file.outcome }}" != "failure" ]]; then
107+
echo "Expected the test to fail but it passed"
108+
exit 1
109+
fi
110+
if [[ "${{ steps.test-text-file.outputs.occurrences }}" != "1" ]]; then
111+
echo "Expected 1 occurrences but found ${{ steps.test-text-file.outputs.occurrences }}"
112+
exit 1
113+
fi

.github/workflows/linter.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ jobs:
5151
VALIDATE_TYPESCRIPT_ES: false
5252
VALIDATE_JSON: false
5353
VALIDATE_TYPESCRIPT_STANDARD: false
54+
VALIDATE_NATURAL_LANGUAGE: false
55+
VALIDATE_ENV: false

0 commit comments

Comments
 (0)