Compile readme examples in CI
This commit is contained in:
parent
a0020d8eef
commit
0e55e09207
13
.github/workflows/main.yml
vendored
13
.github/workflows/main.yml
vendored
|
@ -20,6 +20,19 @@ jobs:
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
||||||
|
|
||||||
|
build-readme:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '1.22'
|
||||||
|
|
||||||
|
- name: Build go snippets in readme
|
||||||
|
run: ./scripts/compile_readme_snippets.sh
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
|
tmp/
|
||||||
|
|
||||||
teeworlds_client
|
teeworlds_client
|
||||||
teeworlds
|
teeworlds
|
||||||
go-teeworlds-protocol
|
go-teeworlds-protocol
|
||||||
|
|
18
scripts/compile_readme_snippets.sh
Executable file
18
scripts/compile_readme_snippets.sh
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mkdir -p tmp
|
||||||
|
awk '/^```go$/ {p=1}; p; /^```$/ {p=0;print"--- --- ---"}' README.md |
|
||||||
|
grep -vE '^```(go)?$' |
|
||||||
|
csplit \
|
||||||
|
-z -s -\
|
||||||
|
'/--- --- ---/' \
|
||||||
|
'{*}' \
|
||||||
|
--suppress-matched \
|
||||||
|
-f tmp/readme_snippet_ -b '%02d.go'
|
||||||
|
|
||||||
|
for snippet in ./tmp/readme_snippet_*.go
|
||||||
|
do
|
||||||
|
echo "building $snippet ..."
|
||||||
|
go build -v "$snippet" || exit 1
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in a new issue