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

check-links added to repo #1559

Merged
merged 12 commits into from
Nov 4, 2024
Merged
46 changes: 46 additions & 0 deletions .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: check-links
on:
push:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
changedfiles:
name: changed files
runs-on: ubuntu-latest
env:
PR_HEAD: ${{ github.event.pull_request.head.sha }}
outputs:
md: ${{ steps.changes.outputs.md }}
steps:
- name: Checkout Repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
- name: Get changed files
id: changes
run: |
echo "md=$(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base origin/main $PR_HEAD) $PR_HEAD | grep .md$ | xargs)" >> $GITHUB_OUTPUT

check-links:
runs-on: ubuntu-latest
needs: changedfiles
if: ${{needs.changedfiles.outputs.md}}
steps:
- name: Checkout Repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0

- name: Install markdown-link-check
run: npm install

- name: Run markdown-link-check
run: |
npx --no -- markdown-link-check \
--verbose \
--config .github/workflows/check_links_config.json \
${{needs.changedfiles.outputs.md}} \
|| { echo "Check that anchor links are lowercase"; exit 1; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this line a bit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, This line of code runs the markdown-link-check with verbose logging enabled and specifies the custom configuration file (check_links_config.json). The needs.changedfiles.outputs.md variable is used to dynamically target only the markdown files that were modified in the PR.

The || { echo "Check that anchor links are lowercase"; exit 1; } part is a fallback check to ensure that if there are any issues with the anchor links not being lowercase (which is a requirement for valid markdown links), the workflow will fail and print a meaningful message for the contributor to resolve.

However, if this check is redundant, I can adjust or remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not objecting to the current implementation, but I wonder if maybe a linter would do a better job of that particular edge case. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that a linter might be more appropriate for this edge case, as it would likely cover more general cases of markdown formatting and anchor validation. Not quite sure how to implement exactly for this as I'm new here. I'll appreciate any help @tylerbenson

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any specific insight here. Maybe investigate what other OpenTelemetry repos are doing?

28 changes: 28 additions & 0 deletions .github/workflows/check_links_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"ignorePatterns": [
{
"pattern": "http(s)?://\\d+\\.\\d+\\.\\d+\\.\\d+"
},
{
"pattern": "http(s)?://localhost"
},
{
"pattern": "http(s)?://example.com"
},
{
"pattern": "https://docs.aws.amazon.com"
},
{
"pattern": "https://console.aws.amazon.com"
}
],
"aliveStatusCodes": [429, 200],
"httpHeaders": [
{
"urls": ["https://docs.aws.amazon.com", "https://docs.github.com/"],
"headers": {
"Accept-Encoding": "zstd, br, gzip, deflate"
}
}
]
}
25 changes: 0 additions & 25 deletions dotnet/sample-apps/aws-sdk/wrapper/SampleApps/AwsSdkSample.sln

This file was deleted.