Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx links checker warnings #429

Merged
merged 24 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d1b39fe
merge develop
fantkolja Sep 17, 2024
516f6ca
revert adoc templates
fantkolja Sep 17, 2024
1b60cf1
Merge branch 'hazelcast:develop' into develop
fantkolja Sep 17, 2024
e04dea5
Merge branch 'hazelcast:main' into main
fantkolja Sep 17, 2024
a2a6b0f
Merge branch 'develop'
fantkolja Sep 17, 2024
c1eea01
Merge branch 'hazelcast:main' into main
fantkolja Oct 7, 2024
b79404a
Merge branch 'hazelcast:main' into main
fantkolja Oct 16, 2024
93d353b
Merge branch 'hazelcast:main' into main
fantkolja Oct 23, 2024
3737463
Merge branch 'hazelcast:main' into main
fantkolja Nov 12, 2024
73dc36e
Merge branch 'hazelcast:main' into main
fantkolja Nov 15, 2024
313ca45
Merge branch 'hazelcast:main' into main
fantkolja Nov 20, 2024
9aca1ab
Merge branch 'hazelcast:main' into main
fantkolja Nov 20, 2024
e1939ad
Merge remote-tracking branch 'upstream/main'
fantkolja Dec 2, 2024
16fd1aa
Merge remote-tracking branch 'upstream/main'
fantkolja Dec 4, 2024
01d3680
Merge remote-tracking branch 'upstream/main'
fantkolja Dec 5, 2024
96173db
remove collector
fantkolja Dec 5, 2024
fbe938b
remove collector
fantkolja Dec 5, 2024
c70e848
remove collector
fantkolja Dec 5, 2024
b2889e0
Merge branch 'main' into test/link-checker-extension
fantkolja Dec 5, 2024
8e93599
remove collector
fantkolja Dec 5, 2024
ed6e129
remove collector
fantkolja Dec 5, 2024
bbbcac5
copy asciidoc attributes
fantkolja Dec 5, 2024
da3b5bd
copy asciidoc attributes
fantkolja Dec 5, 2024
a1e89e5
copy asciidoc attributes
fantkolja Dec 5, 2024
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
14 changes: 4 additions & 10 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Check for broken internal links
env:
GIT_CREDENTIALS: ${{ secrets.GIT_CREDENTIALS }}
run: |
npm i
npm run-script check-links-local
- name: Checkout Current Repo
uses: actions/checkout@v4
- name: Check dead links
uses: hazelcast/hazelcast-docs/.github/actions/validate@main


3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/docs/
/build/
.DS_Store
package-lock.json
/pdf-docs/
Gemfile.lock
.idea
.idea
26 changes: 22 additions & 4 deletions lib/load-check-links-playbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ function main() {
const { currentRepoName, baseBranchName } = parseInputArgs();

// 1. Load and parse local antora-playbook.yml
const localAntoraPlaybook = loadLocalAntoraPlaybook();
let localAntoraPlaybook = loadLocalAntoraPlaybook();

// 2. Load and parse global antora-playbook.yml's content.sources
const globalSources = loadGlobalContentSources();
let { globalSources, globalAsciidocAttributes } = loadGlobalAntoraData();

// 3. Modify global content.sources
// - add hazelcast-docs GitHub URL
Expand All @@ -21,6 +21,10 @@ function main() {
// - add current branch
addCurrentBranch(currentRepoSource, globalSources);

// - hazelcast-mono antora-playbook, contains global attributes, used across other repos
// need to add them to the local antora-playbook
localAntoraPlaybook = copyGlobalAsciidocAttributes(globalAsciidocAttributes, localAntoraPlaybook);

// 4. Replace local content.sources with the modified content.sources
writeCheckLinksPlaybookFile(localAntoraPlaybook, globalSources);
}
Expand Down Expand Up @@ -52,20 +56,25 @@ function removeProtectedSources(sources) {
&& !(source.url === 'https://github.com/hazelcast/management-center'));
}

function loadGlobalContentSources() {
function loadGlobalAntoraData() {
const globalAntoraPlaybookContent = fs.readFileSync('./hazelcast-docs/antora-playbook.yml', 'utf8');
const globalAntoraPlaybook = YAML.parse(globalAntoraPlaybookContent);

// - remove hazelcast-mono & management-center,
// because they have only Swagger docs thus will never have links to the current
// and also they require authentication
return removeProtectedSources(globalAntoraPlaybook.content.sources);
const globalSources = removeProtectedSources(globalAntoraPlaybook.content.sources);
const globalAsciidocAttributes = globalAntoraPlaybook.asciidoc.attributes;

return { globalSources, globalAsciidocAttributes };
}

function addHazelcastDocsUrl(sources) {
// in the global playbook it's declared with a dot `.`
const hazelcastDocsSource = sources.find(source => source.url === '.');
hazelcastDocsSource.url = 'https://github.com/hazelcast/hazelcast-docs';
hazelcastDocsSource.branches = ['main'];
return sources;
}

function rewriteCurrentVersion() {
Expand Down Expand Up @@ -138,6 +147,15 @@ function addCurrentBranch(repoSource, sources) {
sources.unshift(currentBranchSource);
}

function copyGlobalAsciidocAttributes(globalAsciidocAttributes, localAntoraPlaybook) {
localAntoraPlaybook.asciidoc.attributes = {
...globalAsciidocAttributes,
...localAntoraPlaybook.asciidoc.attributes,
};

return localAntoraPlaybook;
}

function writeCheckLinksPlaybookFile(localPlaybook, sources) {
localPlaybook.content.sources = sources;
const checkLinksPlaybook = YAML.stringify(localPlaybook);
Expand Down
Loading
Loading