diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml new file mode 100644 index 0000000..5e3255b --- /dev/null +++ b/.github/workflows/links.yml @@ -0,0 +1,32 @@ +name: Links + +on: + push: + pull_request: + schedule: + - cron: "0 13 * * 1" # weekly, to catch external link rot without a commit + workflow_dispatch: + +permissions: + contents: read + +jobs: + linkChecker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Setup mise + uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1 + with: + install: false + + # Install only lychee (not the repo's full toolchain) and run the check. + - name: Check links + env: + MISE_AUTO_INSTALL: "false" + run: | + mise install lychee + mise run check-links diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4bab250..90e48f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,4 +36,4 @@ jobs: # zizmor complains that 'v1' is a ref that can be provided by both the branch and tag namespaces. # specify that we want the v1 branch. - - uses: rubygems/release-gem@6317d8d1f7e28c24d28f6eff169ea854948bd9f7 # 1.2.0 + - uses: rubygems/release-gem@6317d8d1f7e28c24d28f6eff169ea854948bd9f7 # v1.2.0 diff --git a/.gitignore b/.gitignore index 831f7f9..9bf75a2 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,9 @@ # RuboCop cache /.rubocop-* +# Lychee link checker cache +.lycheecache + # IDE/Editor specific /.idea /.vscode diff --git a/CLAUDE.md b/CLAUDE.md index 3d4ed6d..954fc14 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -385,6 +385,6 @@ ruby -Ilib:test test/test_reader.rb ## Additional Resources - [API Documentation](https://www.rubydoc.info/gems/maxmind-geoip2) -- [GeoIP Web Services Docs](https://dev.maxmind.com/geoip/docs/web-services) +- [GeoIP Web Services Docs](https://dev.maxmind.com/geoip/docs/web-services/) - [MaxMind DB Format](https://maxmind.github.io/MaxMind-DB/) - GitHub Issues: https://github.com/maxmind/GeoIP2-ruby/issues diff --git a/README.md b/README.md index 4c98ffb..a443ab1 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ ## Description This is the Ruby API for the GeoIP and GeoLite -[webservices](https://dev.maxmind.com/geoip/docs/web-services?lang=en) -and [databases](https://dev.maxmind.com/geoip/docs/databases?lang=en). +[webservices](https://dev.maxmind.com/geoip/docs/web-services/?lang=en) +and [databases](https://dev.maxmind.com/geoip/docs/databases/?lang=en). ## Installation @@ -300,7 +300,7 @@ point may offer a particular piece of data, MaxMind does not always have every piece of data for any given IP address. See the [GeoIP web service -documentation](https://dev.maxmind.com/geoip/docs/web-services?lang=en) for details on +documentation](https://dev.maxmind.com/geoip/docs/web-services/?lang=en) for details on what data each end point may return. The only piece of data which is always returned is the `ip_address` @@ -324,7 +324,7 @@ GeoNames premium data set. ## Reporting data problems If the problem you find is that an IP address is incorrectly mapped, please -[submit your correction to MaxMind](https://www.maxmind.com/en/correction). +[submit your correction to MaxMind](https://www.maxmind.com/en/geoip-data-correction-request). If you find some other sort of mistake, like an incorrect spelling, please check the [GeoNames site](https://www.geonames.org/) first. Once you've @@ -335,7 +335,7 @@ will be automatically incorporated into future MaxMind releases. If you are a paying MaxMind customer and you're not sure where to submit a correction, please [contact MaxMind -support](https://www.maxmind.com/en/support) for help. +support](https://support.maxmind.com/knowledge-base) for help. ## Support @@ -343,7 +343,7 @@ Please report all issues with this code using the [GitHub issue tracker](https://github.com/maxmind/GeoIP2-ruby/issues). If you are having an issue with a MaxMind service that is not specific to the -client API, please see [our support page](https://www.maxmind.com/en/support). +client API, please see [our support page](https://support.maxmind.com/knowledge-base). ## Requirements diff --git a/lib/maxmind/geoip2/client.rb b/lib/maxmind/geoip2/client.rb index addd92d..ce24938 100644 --- a/lib/maxmind/geoip2/client.rb +++ b/lib/maxmind/geoip2/client.rb @@ -13,7 +13,7 @@ module MaxMind module GeoIP2 # This class provides a client API for all the - # {https://dev.maxmind.com/geoip/docs/web-services?lang=en GeoIP web + # {https://dev.maxmind.com/geoip/docs/web-services/?lang=en GeoIP web # services}. The services are Country, City Plus, and Insights. Each service # returns a different set of data about an IP address, with Country returning # the least data and Insights the most. diff --git a/lib/maxmind/geoip2/model/city.rb b/lib/maxmind/geoip2/model/city.rb index 7439b45..6125cd1 100644 --- a/lib/maxmind/geoip2/model/city.rb +++ b/lib/maxmind/geoip2/model/city.rb @@ -12,7 +12,7 @@ module Model # Model class for the data returned by the GeoIP City Plus web service # and the City database. It is also used for GeoLite City lookups. # - # See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more + # See https://dev.maxmind.com/geoip/docs/web-services/?lang=en for more # details. # # See {MaxMind::GeoIP2::Model::Country} for inherited methods. diff --git a/lib/maxmind/geoip2/model/enterprise.rb b/lib/maxmind/geoip2/model/enterprise.rb index 07a2a52..e4aba0d 100644 --- a/lib/maxmind/geoip2/model/enterprise.rb +++ b/lib/maxmind/geoip2/model/enterprise.rb @@ -7,7 +7,7 @@ module GeoIP2 module Model # Model class for the data returned by GeoIP Enterprise database lookups. # - # See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more + # See https://dev.maxmind.com/geoip/docs/web-services/?lang=en for more # details. # # See {MaxMind::GeoIP2::Model::City} for inherited methods. diff --git a/lib/maxmind/geoip2/model/insights.rb b/lib/maxmind/geoip2/model/insights.rb index 0760e67..b1989bd 100644 --- a/lib/maxmind/geoip2/model/insights.rb +++ b/lib/maxmind/geoip2/model/insights.rb @@ -8,7 +8,7 @@ module GeoIP2 module Model # Model class for the data returned by the GeoIP Insights web service. # - # See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more + # See https://dev.maxmind.com/geoip/docs/web-services/?lang=en for more # details. class Insights < City # Data indicating whether the IP address is part of an anonymizing diff --git a/lychee.toml b/lychee.toml new file mode 100644 index 0000000..0367419 --- /dev/null +++ b/lychee.toml @@ -0,0 +1,61 @@ +# Lychee link checker configuration +# https://lychee.cli.rs/#/usage/config +# +# Run locally with: +# lychee './**/*.md' './lib/**/*.rb' './*.gemspec' + +# Include URL fragments in checks +include_fragments = true + +# Don't allow any redirects, so links that have moved are surfaced and can be +# updated to their canonical destination. +max_redirects = 0 + +# Accept these HTTP status codes +# 100-103: Informational responses +# 200-299: Success responses +# 403: Forbidden (some sites use this for rate limiting) +# 429: Too Many Requests +# 500-599: Server errors (temporary issues shouldn't fail CI) +# 999: LinkedIn's custom status code +accept = ["100..=103", "200..=299", "403", "429", "500..=599", "999"] + +# Exclude URL patterns from checking (treated as regular expressions) +exclude = [ + # GitHub blob URLs with line-number fragments (not parseable as page anchors) + '^https://github\.com/[^/]+/[^/]+/blob/[0-9a-fA-F]+/.+#L\d+$', + # Live / auth-gated MaxMind endpoints: appear as code string literals or + # require login, so they can't be verified by an anonymous request. + '^https://geoip\.maxmind\.com', + '^https://geolite\.info', + '^https://minfraud\.maxmind\.com', + '^https://sandbox\.maxmind\.com', + '^https://updates\.maxmind\.com', + '^https://www\.maxmind\.com/en/accounts/', + '^https://www\.maxmind\.com/en/account/login', + # Local / placeholder URLs (e.g. the proxy example in docstrings) + '^file://', + '^https?://example\.(com|org|net)', + '^http://localhost', + '127\.0\.0\.1', +] + +# Exclude file paths from getting checked (regular expressions, matched against +# the path relative to the working directory). Patterns are segment-anchored +# with (^|/) so short names like "build" don't match unintended paths. +exclude_path = [ + '(^|/)vendor/', + '(^|/)pkg/', + '(^|/)doc/', + '(^|/)\.yardoc/', + '(^|/)coverage/', + # Changelog: historical entries are preserved as-is, not rewritten + '(^|/)CHANGELOG\.md$', +] + +# Cache results for 1 day to speed up repeated checks +cache = true +max_cache_age = "1d" + +# Skip missing input files instead of erroring +skip_missing = true diff --git a/mise.lock b/mise.lock index 20b29f4..7b919bb 100644 --- a/mise.lock +++ b/mise.lock @@ -1,5 +1,33 @@ # @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html +[[tools.lychee]] +version = "0.23.0" +backend = "aqua:lycheeverse/lychee" + +[tools.lychee."platforms.linux-arm64"] +checksum = "sha256:97eb93b02a7d78a752fc33e5b0983439ccaadbf3db952b68a0a4401acd92e6e0" +url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-aarch64-unknown-linux-gnu.tar.gz" + +[tools.lychee."platforms.linux-arm64-musl"] +checksum = "sha256:97eb93b02a7d78a752fc33e5b0983439ccaadbf3db952b68a0a4401acd92e6e0" +url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-aarch64-unknown-linux-gnu.tar.gz" + +[tools.lychee."platforms.linux-x64"] +checksum = "sha256:5538440d2c69a45a0a09983271e5dee0c2fe7137d8035d25b2632e10a66a090a" +url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-x86_64-unknown-linux-musl.tar.gz" + +[tools.lychee."platforms.linux-x64-musl"] +checksum = "sha256:5538440d2c69a45a0a09983271e5dee0c2fe7137d8035d25b2632e10a66a090a" +url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-x86_64-unknown-linux-musl.tar.gz" + +[tools.lychee."platforms.macos-arm64"] +checksum = "sha256:4c8034900e11083b68ac6f6582c377ff1f704e268991999e09d717973e493e7f" +url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-arm64-macos.dmg" + +[tools.lychee."platforms.windows-x64"] +checksum = "sha256:0fda7ff0a60c0250939fc25361c2d4e6e7853c31c996733fdd5a1dd760bcb824" +url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-x86_64-windows.exe" + [[tools.ruby]] version = "4.0.5" backend = "core:ruby" diff --git a/mise.toml b/mise.toml index bea4666..531755b 100644 --- a/mise.toml +++ b/mise.toml @@ -8,6 +8,7 @@ disable_backends = [ [tools] ruby = "latest" +lychee = "latest" [hooks] enter = "mise install --quiet --locked" @@ -15,3 +16,7 @@ enter = "mise install --quiet --locked" [[watch_files]] patterns = ["mise.toml", "mise.lock"] run = "mise install --quiet --locked" + +[tasks.check-links] +description = "Check links with lychee" +run = "lychee --no-progress './**/*.md' './lib/**/*.rb' './*.gemspec'"