-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: validate
sh
code-blocks in examples (#273)
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Examples | ||
on: | ||
pull_request: | ||
paths: | ||
- "**.go" | ||
- "go.mod" | ||
- "go.sum" | ||
- "examples/**.md" | ||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout head | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | ||
- name: Setup Go | ||
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | ||
with: | ||
go-version-file: "go.mod" | ||
- name: Install mdtest and upctl | ||
run: | | ||
go install github.com/UpCloudLtd/mdtest@latest | ||
make build | ||
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH | ||
- name: Test examples | ||
env: | ||
UPCLOUD_USERNAME: ${{ secrets.UPCLOUD_USERNAME }} | ||
UPCLOUD_PASSWORD: ${{ secrets.UPCLOUD_PASSWORD }} | ||
run: | | ||
upctl version | ||
mdtest examples/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
# Examples | ||
|
||
This directory contains examples on more complex `upctl` use-cases. As `upctl` is often used in scripts the examples also aim to parse values from machine readable outputs. This allows using the examples also as end-to-end test cases and makes them more copy-pasteable. | ||
|
||
## Testing | ||
|
||
The examples in this directory are validated with [mdtest](https://github.com/UpCloudLtd/mdtest). It parses `env` and `sh` code-blocks from the markdown files and executes those as scripts. | ||
|
||
The tool can be installed with go install. | ||
|
||
```sh | ||
go install github.com/UpCloudLtd/mdtest@latest | ||
``` | ||
|
||
To test the examples, run `mdtest .`. | ||
|
||
```sh | ||
mdtest . | ||
``` |