Skip to content

Commit 1cf5f5f

Browse files
ci: add testing the action to ci workflow and fix linting (#20)
* ci: add action tests * fix linting * chore: format template-vars for better readability in CI and README * chore: add permissions section to labeler workflow * Fix linting
1 parent 1d6ec8f commit 1cf5f5f

File tree

9 files changed

+78
-33
lines changed

9 files changed

+78
-33
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ updates:
33
- package-ecosystem: github-actions
44
directory: /
55
labels:
6-
- "maintenance"
6+
- 'maintenance'
77
schedule:
88
interval: weekly
99
groups:
@@ -15,7 +15,7 @@ updates:
1515
- package-ecosystem: npm
1616
directory: /
1717
labels:
18-
- "maintenance"
18+
- 'maintenance'
1919
schedule:
2020
interval: weekly
2121
groups:

.github/labeler.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
documentation:
55
- changed-files:
6-
- any-glob-to-any-file: ["**/*.md"]
6+
- any-glob-to-any-file: ['**/*.md']
77

88
maintenance:
99
- changed-files:
1010
- any-glob-to-any-file:
11-
[".github/**/*", "package.json", "package-lock.json"]
11+
['.github/**/*', 'package.json', 'package-lock.json']
1212

1313
enhancement:
1414
- changed-files:
15-
- any-glob-to-any-file: ["src/**/*", "dist/**/*", "action.yml"]
15+
- any-glob-to-any-file: ['src/**/*', 'dist/**/*', 'action.yml']

.github/release-drafter.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
name-template: "v$RESOLVED_VERSION"
2-
tag-template: "v$RESOLVED_VERSION"
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
33
categories:
4-
- title: "🚀 Features and Improvements"
4+
- title: '🚀 Features and Improvements'
55
labels:
6-
- "enhancement"
7-
- title: "🐛 Bug Fixes"
6+
- 'enhancement'
7+
- title: '🐛 Bug Fixes'
88
labels:
9-
- "bug"
10-
- title: "🧰 Maintenance"
9+
- 'bug'
10+
- title: '🧰 Maintenance'
1111
labels:
12-
- "maintenance"
13-
- title: "📚 Documentation"
12+
- 'maintenance'
13+
- title: '📚 Documentation'
1414
labels:
15-
- "documentation"
16-
change-template: "- $TITLE (#$NUMBER)"
15+
- 'documentation'
16+
change-template: '- $TITLE (#$NUMBER)'
1717
version-resolver:
1818
major:
1919
labels:
20-
- "bump-major"
21-
- "breaking"
20+
- 'bump-major'
21+
- 'breaking'
2222
minor:
2323
labels:
24-
- "bump-minor"
25-
- "enhancement"
24+
- 'bump-minor'
25+
- 'enhancement'
2626
default: patch
2727
template: |
2828
## What's Changed
2929
$CHANGES
3030
3131
exclude-labels:
32-
- "skip-release-notes"
32+
- 'skip-release-notes'

.github/workflows/ci.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ on:
44
pull_request:
55
branches:
66
- main
7-
paths:
8-
- '**/*.js'
9-
- 'package.json'
10-
- 'package-lock.json'
117

128
permissions:
139
contents: read
@@ -44,3 +40,42 @@ jobs:
4440
- name: Test
4541
id: npm-ci-test
4642
run: npm run ci-test
43+
44+
run-action-tests:
45+
name: Test Action
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
51+
- name: Direct Text (JSON Variables)
52+
uses: ./
53+
with:
54+
template-text: 'Hello {{ login }}, nice to meet you!'
55+
template-vars: >
56+
{
57+
"login": "octocat"
58+
}
59+
60+
- name: Direct Text (ENV Variables)
61+
uses: ./
62+
with:
63+
template-text: 'Hello {{ login }}, nice to meet you!'
64+
template-vars: |
65+
login=octocat
66+
67+
- name: Text File (JSON variables)
68+
id: test-readme-same-repo
69+
uses: ./
70+
with:
71+
template-file: ./examples/hello.md
72+
template-vars: >
73+
{
74+
"login": "octocat"
75+
}
76+
77+
- name: Text File (ENV variables)
78+
uses: ./
79+
with:
80+
template-file: ./examples/hello.md
81+
template-vars: login=octocat

.github/workflows/labeler.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on:
33
pull_request_target:
44
types: [opened, synchronize, reopened]
55

6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
610
jobs:
711
label:
812
runs-on: ubuntu-latest
@@ -12,5 +16,5 @@ jobs:
1216
steps:
1317
- uses: actions/labeler@v5
1418
with:
15-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
19+
repo-token: '${{ secrets.GITHUB_TOKEN }}'
1620
sync-labels: true

.github/workflows/linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ jobs:
4848
VALIDATE_ALL_CODEBASE: true
4949
VALIDATE_JSCPD: false
5050
VALIDATE_ENV: false
51+
VALIDATE_NATURAL_LANGUAGE: false

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ steps:
4141
uses: skills/action-text-variables@v1
4242
with:
4343
template-text: 'Hello {{ login }}, nice to meet you!'
44-
template-vars: '{"login": "${{ github.actor }}" }'
44+
template-vars: >
45+
{
46+
"login": "${{ github.actor }}"
47+
}
4548
4649
- name: Do something with result
4750
run: echo "${{ steps.build-comment.outputs.updated-text }}"
@@ -75,7 +78,10 @@ steps:
7578
uses: skills/action-text-variables@v1
7679
with:
7780
template-file: my-files/my-template.md
78-
template-vars: '{ "login": "${{ github.actor }}" }'
81+
template-vars: >
82+
{
83+
"login": "${{ github.actor }}"
84+
}
7985
8086
- name: Do something with result
8187
run: echo "${{ steps.build-comment.outputs.updated-text }}"
@@ -100,10 +106,11 @@ steps:
100106
uses: skills/action-text-variables@v1
101107
with:
102108
template-file: response-templates/step-feedback/lesson-finished.md
103-
template-vars: '{
109+
template-vars: >
110+
{
104111
"login": "${{ github.actor }}",
105112
"repo_full_name": "${{ github.repository }}"
106-
}'
113+
}
107114
108115
- name: Do something with result
109116
run: echo "${{ steps.build-comment.outputs.updated-text }}"

__tests__/main.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const core = require('@actions/core')
55
const main = require('../src/main')
66

77
// Mock the GitHub Actions core library
8-
const debugMock = jest.spyOn(core, 'debug').mockImplementation()
98
const getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
109
const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
1110
const setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
@@ -14,7 +13,6 @@ const setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
1413
const runMock = jest.spyOn(main, 'run')
1514

1615
// Other utilities
17-
const timeRegex = /^\d{2}:\d{2}:\d{2}/
1816

1917
describe('action', () => {
2018
beforeEach(() => {

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)