Skip to content

Commit ef51442

Browse files
committed
feat: add drive link fix behavior
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
1 parent 7431fb3 commit ef51442

50 files changed

Lines changed: 754616 additions & 23653 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/__check-action.yml

Lines changed: 99 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,59 @@ jobs:
4949
hosters: '[{"name": "Hoster Test One", "url": "https://example.com/hoster1"}, {"name": "Hoster Test Two", "url": "https://example.com/hoster2"}]'
5050
speakers: '[{"name": "Speaker One", "url": "https://example.com/speaker1"}, {"name": "Speaker Two", "url": "https://example.com/speaker2"}]'
5151
should-fix: false
52+
google-credentials: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_CREDENTIALS }}
53+
google-parent-folder-id: ${{ vars.GOOGLE_DRIVE_MEETUP_FOLDER_ID }}
54+
google-template-folder-id: ${{ vars.GOOGLE_DRIVE_MEETUP_TEMPLATE_FOLDER_ID }}
5255
github-token: ${{ secrets.GITHUB_TOKEN }}
5356

57+
- name: Assert valid meetup issue output
58+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
59+
env:
60+
VALID_MEETUP_ISSUE: ${{ steps.act.outputs.valid-meetup-issue }}
61+
with:
62+
script: |
63+
const assert = require("node:assert/strict");
64+
const raw = process.env.VALID_MEETUP_ISSUE;
65+
66+
assert.ok(raw, "valid-meetup-issue output is empty");
67+
68+
let parsed;
69+
try {
70+
parsed = JSON.parse(raw);
71+
} catch (error) {
72+
throw new Error(`valid-meetup-issue is not valid JSON: ${error}`);
73+
}
74+
const expectedValidMeetupIssue = {
75+
number: Number(process.env.TEST_VALID_ISSUE_NUMBER),
76+
title: "",
77+
labels: [],
78+
hoster: {
79+
name: "Hoster Test One",
80+
url: "https://example.com/hoster1",
81+
},
82+
speakers: [
83+
{
84+
name: "Speaker One",
85+
url: "https://example.com/speaker1",
86+
},
87+
{
88+
name: "Speaker Two",
89+
url: "https://example.com/speaker2",
90+
},
91+
],
92+
"parsed-body": {
93+
94+
},
95+
"drive-files": {
96+
},
97+
};
98+
99+
assert.deepEqual(
100+
parsed,
101+
expectedValidMeetupIssue,
102+
"valid-meetup-issue payload mismatch"
103+
);
104+
54105
- name: Assert
55106
run: |
56107
if [[ "${{ steps.act.outputs.lint-issues }}" != "" ]]; then
@@ -98,29 +149,54 @@ jobs:
98149
speakers: '[{"name": "Speaker One", "url": "https://example.com/speaker1"}, {"name": "Speaker Two", "url": "https://example.com/speaker2"}]'
99150
should-fix: false
100151
fail-on-error: false
152+
google-credentials: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_CREDENTIALS }}
153+
google-parent-folder-id: ${{ vars.GOOGLE_DRIVE_MEETUP_FOLDER_ID }}
154+
google-template-folder-id: ${{ vars.GOOGLE_DRIVE_MEETUP_TEMPLATE_FOLDER_ID }}
101155
github-token: ${{ secrets.GITHUB_TOKEN }}
102156

103157
- name: Assert
104-
run: |
105-
LINT_ISSUES=$(cat <<EOF
106-
${{ steps.act.outputs.lint-issues }}
107-
EOF
108-
)
109-
110-
EXPECTED_LINT_ISSUES=$(cat <<EOF
111-
Title: Invalid, expected "[Meetup] - 2025-01-01 - Test Invalid Issue"
112-
Hoster: "Wrong Hoster" is not an existing hoster
113-
Event Description: Invalid input: expected string, received undefined
114-
Agenda: Speaker "Wrong Speaker" is not in the list of speakers
115-
Agenda: Entry "- Wrong agenda entry" must follow the format: "- <speaker(s)>: <talk_description>"
116-
Meetup Link: Must be a valid Meetup link, e.g. https://www.meetup.com/cloud-native-aix-marseille/events/123456789
117-
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
118-
Drive Link: Must be a valid Drive Link, e.g. https://drive.google.com/drive/folders/1a2b3c4d5e6f7g8h9i0j
119-
Labels: Missing label(s) "hoster:confirmed"
120-
EOF
121-
)
122-
123-
if ! diff --color <(echo "${LINT_ISSUES}") <(echo "${EXPECTED_LINT_ISSUES}"); then
124-
echo -e "The action did not return the expected list of issues"
125-
exit 1
126-
fi
158+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
159+
env:
160+
LINT_ISSUES: ${{ steps.act.outputs.lint-issues }}
161+
with:
162+
script: |
163+
const assert = require("node:assert/strict");
164+
const lintIssues = process.env.LINT_ISSUES ?? "";
165+
166+
const expected = [
167+
'Title: Invalid, expected "[Meetup] - 2025-01-01 - Test Invalid Issue"',
168+
'Hoster: "Wrong Hoster" is not an existing hoster',
169+
'Event Description: Invalid input: expected string, received undefined',
170+
'Agenda: Speaker "Wrong Speaker" is not in the list of speakers',
171+
'Agenda: Entry "- Wrong agenda entry" must follow the format: "- <speaker(s)>: <talk_description>"',
172+
'Meetup Link: Must be a valid Meetup link, e.g. https://www.meetup.com/cloud-native-aix-marseille/events/123456789',
173+
'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',
174+
'Drive Link: Must be a valid Drive Link, e.g. https://drive.google.com/drive/folders/1a2b3c4d5e6f7g8h9i0j',
175+
'Labels: Missing label(s) "hoster:confirmed"',
176+
].join("\n");
177+
178+
assert.ok(lintIssues, "lint-issues output is empty");
179+
assert.equal(
180+
lintIssues.trim(),
181+
expected,
182+
[
183+
"The action did not return the expected list of issues",
184+
"--- expected ---",
185+
expected,
186+
"--- received ---",
187+
lintIssues,
188+
].join("\n")
189+
);
190+
191+
- name: Assert valid meetup issue output is empty
192+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
193+
env:
194+
VALID_MEETUP_ISSUE: ${{ steps.act.outputs.valid-meetup-issue }}
195+
with:
196+
script: |
197+
const assert = require("node:assert/strict");
198+
assert.equal(
199+
process.env.VALID_MEETUP_ISSUE ?? "",
200+
"",
201+
"valid-meetup-issue output should be empty when lint issues are returned"
202+
);

.github/workflows/__shared-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
name: Test action
4949
needs: [check-nodejs, check-dist]
5050
uses: ./.github/workflows/__check-action.yml
51+
secrets: inherit
5152
permissions:
5253
contents: read
5354
issues: write

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ lint-fix: ## Execute linting and fix
1515
-e FIX_MARKDOWN_PRETTIER=true \
1616
-e FIX_NATURAL_LANGUAGE=true)
1717

18+
test: ## Execute tests
19+
npm run test:ci
20+
1821
ci: ## Execute all tasks to prepare commit
1922
npm install
2023
npm run all

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ This action lint the meetup issue for required fields and format
9595

9696
## Outputs
9797

98-
| **Output** | **Description** |
99-
| ----------------- | ----------------------------------------- |
100-
| **`lint-issues`** | List of issues found in the meetup issue. |
98+
| **Output** | **Description** |
99+
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
100+
| **`lint-issues`** | List of issues found in the meetup issue. |
101+
| **`valid-meetup-issue`** | JSON string containing the validated meetup issue with `number`, `title`, `parsed-body`, `labels`, resolved `hoster`, `speakers`, and Drive links (`announcement_link`, `presentation_link`). |
101102

102103
<!-- outputs:end -->
103104

action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,33 @@ inputs:
3333
github-token:
3434
description: "The GitHub token with permissions to update the issue."
3535
required: true
36+
google-credentials:
37+
description: "Google Drive service account credentials JSON for auto-creating drive folders."
38+
required: true
39+
google-parent-folder-id:
40+
description: "Google Drive parent folder ID where meetup folders will be created."
41+
required: true
42+
google-template-folder-id:
43+
description: "Google Drive template folder ID containing files to copy to new meetup folders."
44+
required: true
3645

3746
outputs:
3847
lint-issues:
3948
description: "List of issues found in the meetup issue."
49+
valid-meetup-issue:
50+
description: |
51+
Valid meetup issue data in JSON Object.
52+
Only valid data is outputted.
53+
54+
- `number`: Issue number.
55+
- `title`: Issue title.
56+
- `parsed-body`: Parsed issue body.
57+
- `labels`: Issue labels.
58+
- `hoster`: Hoster data.
59+
- `speakers`: Speakers data.
60+
- `drive-files`:
61+
- `announcement-link`: Link to the announcement file in Google Drive.
62+
- `presentation-link`: Link to the presentation file in Google Drive.
4063
4164
runs:
4265
using: node20

0 commit comments

Comments
 (0)