Skip to content

Commit

Permalink
chore: add automated testing for links on markdown documentation (#2537)
Browse files Browse the repository at this point in the history
  • Loading branch information
yfodil authored Oct 5, 2022
1 parent 028d70d commit f741f1e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
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.

0 comments on commit f741f1e

Please sign in to comment.