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

chore: add automated testing for links on markdown documentation #2537

Merged
merged 1 commit into from
Oct 5, 2022
Merged
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
11 changes: 11 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ jobs:
SHELL: /bin/bash
- name: Exit 1 if not empty
run: git diff --exit-code
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@1.0.13
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: '.markdownlinkcheck.json'
folder-path: 'docs'
file-extension: '.md'
18 changes: 18 additions & 0 deletions .markdownlinkcheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"ignorePatterns": [
{
"pattern": "^https://github.com/[^/]+/[^/]+/(issues|labels|pull)"
},
{
"pattern": "^http://169.254.42.42/[^/])"
},
{
"pattern": "^https://api.scaleway.com/account/v1"
}
],
"timeout": "20s",
"retryOn429": true,
"retryCount": 5,
"fallbackRetryDelay": "30s",
"aliveStatusCodes": [200, 206]
}
6 changes: 3 additions & 3 deletions docs/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ Be sure to check out the resource you create in each test and remember to delete
When running a test, you might need information such as ID that you cannot know in advance (such as ID of resources).
The `core.Test` uses different helpers to pass useful information around.

One of them is the [`core.testMetadata`](https://github.com/scaleway/scaleway-cli/blob/v2/internal/core/testing.go#L80).
One of them is the [`core.testMetadata`](https://github.com/scaleway/scaleway-cli/blob/master/internal/core/testing.go#L80).
It is designed to store information such as ID or object describing a resource during a test.
This metadata can use the `render` method to provide helpful golang templating features to have commands arguments computed dynamically.

#### BeforeFunc and AfterFunc

Usually, you might need to set up and teardown resources when you are running a test for testing a specific command.
For that you can use [`BeforeFunc`](https://github.com/scaleway/scaleway-cli/blob/v2/internal/core/testing.go#L84) and [`AfterFunc`](https://github.com/scaleway/scaleway-cli/blob/v2/internal/core/testing.go#L86).
For that you can use [`BeforeFunc`](https://github.com/scaleway/scaleway-cli/blob/master/internal/core/testing.go#L100) and [`AfterFunc`](https://github.com/scaleway/scaleway-cli/blob/master/internal/core/testing.go#L102).
Those types allow you to execute code before (`BeforeFunc`) or after (`AfterFunc`) the main command you want to test.
Those functions can access the metadata to change dynamically their behavior.

Expand Down Expand Up @@ -75,4 +75,4 @@ If you want to contribute new tests you should have the following:
- Install go for your platform
- Install your credentials, preferably in a configuration file (run `scw init`)
- Keep in mind that if you record interaction, the resource you will instantiate will be delivered and billed.
- Clean up the resource you don't use once the recording is over.
- Clean up the resource you don't use once the recording is over.