-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (109 loc) · 4.75 KB
/
__check-action.yml
File metadata and controls
126 lines (109 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Internal - Tests for action
on:
workflow_call:
permissions: {}
env:
TEST_VALID_ISSUE_NUMBER: "6" # This issue number should be valid
TEST_INVALID_ISSUE_NUMBER: "11" # This issue number should be valid
jobs:
test-action-with-valid-issue:
runs-on: ubuntu-latest
name: Test with valid issue
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- id: get-issue-body
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: process.env.TEST_VALID_ISSUE_NUMBER
});
core.setOutput('issue-body', issue.data.body);
- name: Parse Issue
id: parser
uses: issue-ops/parser@cb7e2e4e5da701aad0e23e718bc4c91d442ca8ba # v5.0.0
with:
body: ${{ steps.get-issue-body.outputs.issue-body }}
issue-form-template: ../../__tests__/meetup-issue-template.yml
- name: Act
id: act
uses: ./
with:
issue-number: ${{ env.TEST_VALID_ISSUE_NUMBER }}
issue-parsed-body: ${{ steps.parser.outputs.json }}
hosters: '[{"name": "Hoster Test One", "url": "https://example.com/hoster1"}, {"name": "Hoster Test Two", "url": "https://example.com/hoster2"}]'
speakers: '[{"name": "Speaker One", "url": "https://example.com/speaker1"}, {"name": "Speaker Two", "url": "https://example.com/speaker2"}]'
should-fix: false
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Assert
run: |
if [[ "${{ steps.act.outputs.lint-issues }}" != "" ]]; then
echo "The action did not return an empty list of issues"
exit 1
fi
test-action-with-invalid-issue:
runs-on: ubuntu-latest
name: Test with invalid issue
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- id: get-issue-body
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: process.env.TEST_INVALID_ISSUE_NUMBER
});
core.setOutput('issue-body', issue.data.body);
- name: Parse Issue
id: parser
uses: issue-ops/parser@cb7e2e4e5da701aad0e23e718bc4c91d442ca8ba # v5.0.0
with:
body: ${{ steps.get-issue-body.outputs.issue-body }}
issue-form-template: ../../__tests__/meetup-issue-template.yml
- name: Act
id: act
uses: ./
with:
issue-number: ${{ env.TEST_INVALID_ISSUE_NUMBER }}
issue-parsed-body: ${{ steps.parser.outputs.json }}
hosters: '[{"name": "Hoster Test One", "url": "https://example.com/hoster1"}, {"name": "Hoster Test Two", "url": "https://example.com/hoster2"}]'
speakers: '[{"name": "Speaker One", "url": "https://example.com/speaker1"}, {"name": "Speaker Two", "url": "https://example.com/speaker2"}]'
should-fix: false
fail-on-error: false
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Assert
run: |
LINT_ISSUES=$(cat <<EOF
${{ steps.act.outputs.lint-issues }}
EOF
)
EXPECTED_LINT_ISSUES=$(cat <<EOF
Title: Invalid, expected "[Meetup] - 2025-01-01 - Test Invalid Issue"
Hoster: "Wrong Hoster" is not an existing hoster
Event Description: Invalid input: expected string, received undefined
Agenda: Speaker "Wrong Speaker" is not in the list of speakers
Agenda: Entry "- Wrong agenda entry" must follow the format: "- <speaker(s)>: <talk_description>"
Meetup Link: Must be a valid Meetup link, e.g. https://www.meetup.com/cloud-native-aix-marseille/events/123456789
CNCF Link: Must be a valid CNCF link, e.g. https://community.cncf.io/events/details/cncf-cloud-native-aix-marseille-presents-test-meetup-event
Drive Link: Must be a valid Drive Link, e.g. https://drive.google.com/drive/folders/1a2b3c4d5e6f7g8h9i0j
Labels: Missing label(s) "hoster:confirmed"
EOF
)
if ! diff --color <(echo "${LINT_ISSUES}") <(echo "${EXPECTED_LINT_ISSUES}"); then
echo -e "The action did not return the expected list of issues"
exit 1
fi