Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 99 additions & 23 deletions .github/workflows/__check-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,59 @@ jobs:
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
google-credentials: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_CREDENTIALS }}
google-parent-folder-id: ${{ vars.GOOGLE_DRIVE_MEETUP_FOLDER_ID }}
google-template-folder-id: ${{ vars.GOOGLE_DRIVE_MEETUP_TEMPLATE_FOLDER_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Assert valid meetup issue output
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
env:
VALID_MEETUP_ISSUE: ${{ steps.act.outputs.valid-meetup-issue }}
with:
script: |
const assert = require("node:assert/strict");
const raw = process.env.VALID_MEETUP_ISSUE;

assert.ok(raw, "valid-meetup-issue output is empty");

let parsed;
try {
parsed = JSON.parse(raw);
} catch (error) {
throw new Error(`valid-meetup-issue is not valid JSON: ${error}`);
}
const expectedValidMeetupIssue = {
number: Number(process.env.TEST_VALID_ISSUE_NUMBER),
title: "",
labels: [],
hoster: {
name: "Hoster Test One",
url: "https://example.com/hoster1",
},
speakers: [
{
name: "Speaker One",
url: "https://example.com/speaker1",
},
{
name: "Speaker Two",
url: "https://example.com/speaker2",
},
],
"parsed-body": {

},
"drive-files": {
},
};

assert.deepEqual(
parsed,
expectedValidMeetupIssue,
"valid-meetup-issue payload mismatch"
);

- name: Assert
run: |
if [[ "${{ steps.act.outputs.lint-issues }}" != "" ]]; then
Expand Down Expand Up @@ -98,29 +149,54 @@ jobs:
speakers: '[{"name": "Speaker One", "url": "https://example.com/speaker1"}, {"name": "Speaker Two", "url": "https://example.com/speaker2"}]'
should-fix: false
fail-on-error: false
google-credentials: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_CREDENTIALS }}
google-parent-folder-id: ${{ vars.GOOGLE_DRIVE_MEETUP_FOLDER_ID }}
google-template-folder-id: ${{ vars.GOOGLE_DRIVE_MEETUP_TEMPLATE_FOLDER_ID }}
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
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
env:
LINT_ISSUES: ${{ steps.act.outputs.lint-issues }}
with:
script: |
const assert = require("node:assert/strict");
const lintIssues = process.env.LINT_ISSUES ?? "";

const expected = [
'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"',
].join("\n");

assert.ok(lintIssues, "lint-issues output is empty");
assert.equal(
lintIssues.trim(),
expected,
[
"The action did not return the expected list of issues",
"--- expected ---",
expected,
"--- received ---",
lintIssues,
].join("\n")
);

- name: Assert valid meetup issue output is empty
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
env:
VALID_MEETUP_ISSUE: ${{ steps.act.outputs.valid-meetup-issue }}
with:
script: |
const assert = require("node:assert/strict");
assert.equal(
process.env.VALID_MEETUP_ISSUE ?? "",
"",
"valid-meetup-issue output should be empty when lint issues are returned"
);
1 change: 1 addition & 0 deletions .github/workflows/__shared-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
name: Test action
needs: [check-nodejs, check-dist]
uses: ./.github/workflows/__check-action.yml
secrets: inherit
permissions:
contents: read
issues: write
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ lint-fix: ## Execute linting and fix
-e FIX_MARKDOWN_PRETTIER=true \
-e FIX_NATURAL_LANGUAGE=true)

test: ## Execute tests
npm run test:ci

ci: ## Execute all tasks to prepare commit
npm install
npm run all
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ This action lint the meetup issue for required fields and format

## Outputs

| **Output** | **Description** |
| ----------------- | ----------------------------------------- |
| **`lint-issues`** | List of issues found in the meetup issue. |
| **Output** | **Description** |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`lint-issues`** | List of issues found in the meetup issue. |
| **`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`). |

<!-- outputs:end -->

Expand Down
23 changes: 23 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,33 @@ inputs:
github-token:
description: "The GitHub token with permissions to update the issue."
required: true
google-credentials:
description: "Google Drive service account credentials JSON for auto-creating drive folders."
required: true
google-parent-folder-id:
description: "Google Drive parent folder ID where meetup folders will be created."
required: true
google-template-folder-id:
description: "Google Drive template folder ID containing files to copy to new meetup folders."
required: true

outputs:
lint-issues:
description: "List of issues found in the meetup issue."
valid-meetup-issue:
description: |
Valid meetup issue data in JSON Object.
Only valid data is outputted.

- `number`: Issue number.
- `title`: Issue title.
- `parsed-body`: Parsed issue body.
- `labels`: Issue labels.
- `hoster`: Hoster data.
- `speakers`: Speakers data.
- `drive-files`:
- `announcement-link`: Link to the announcement file in Google Drive.
- `presentation-link`: Link to the presentation file in Google Drive.

runs:
using: node20
Expand Down
Loading
Loading