Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 0311e66

Browse files
committed
Initial commit
0 parents  commit 0311e66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+25675
-0
lines changed

README.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
### vgo by example
2+
3+
vgo by example is a series of work-along guides that look to help explain:
4+
5+
* how vgo works
6+
* how to get things done with vgo
7+
8+
They are work-in-progress and pending review.
9+
10+
### Structure
11+
12+
A guide simply comprises a README.md and an accompanying bash script. For example, the vgo tour has been rewritten as a
13+
vgo by example guide:
14+
15+
```
16+
$ ls vgo_tour
17+
README.md
18+
script.sh
19+
```
20+
21+
script.sh contains, as its name suggests, the overall script for the guide. It includes a pre-amble that defines a
22+
number of helper functions for testing the script, followed by the header:
23+
24+
```
25+
# **START**
26+
```
27+
28+
This marks the start of the script.
29+
30+
What follows are a number of optionally commented "blocks". For example, the following block is labelled `"go get vgo"`
31+
and comprises all the contiguous lines that follow the special `# block:` comment:
32+
33+
```
34+
# block: go get vgo
35+
go get -u golang.org/x/vgo
36+
assert "$? -eq 0" $LINENO
37+
```
38+
39+
The corresponding README.md acts as a template for the guide itself, but crucially it can reference these blocks in
40+
order to include the commands themselves and/or the output, e.g.:
41+
42+
```
43+
{{PrintBlock "go get vgo" -}}
44+
```
45+
46+
Look at the raw [vgo tour README.md](https://raw.githubusercontent.com/myitcv/vgo-by-example/master/vgo_tour/README.md)
47+
for more example of the guide template referencing the script.
48+
49+
50+
### Testing scripts
51+
52+
To ensure reproducibility and isolation, scripts are run in a Docker container; the
53+
[`golang`](https://hub.docker.com/_/golang/) container is used:
54+
55+
```
56+
docker pull golang
57+
```
58+
59+
The following two environment variables must be set:
60+
61+
```bash
62+
GITHUB_USERNAME # your Github username
63+
GITHUB_PAT # a personal access token with public_repo scope
64+
```
65+
66+
_[Create a new personal access token](https://github.com/settings/tokens/new)._
67+
68+
Ensure `egrunner` is installed (and on your PATH):
69+
70+
```
71+
go install myitcv.io/vgo-by-example/cmd/egrunner
72+
```
73+
74+
Now run in debug mode to see real-time output:
75+
76+
```
77+
egrunner -debug vgo_tour/script.sh
78+
```
79+
80+
### Regenerating a guide
81+
82+
First ensure `mdreplace` and `egrunner` are installed (and on your PATH):
83+
84+
```
85+
go install myitcv.io/vgo-by-example/cmd/mdreplace myitcv.io/vgo-by-example/cmd/egrunner
86+
```
87+
88+
Then re-run `mdreplace` on a guide template, e.g. for the vgo tour:
89+
90+
```
91+
mdreplace -w ./vgo_tour/README.md
92+
```
93+
94+
### TODO
95+
96+
* Make this a `vgo` project
97+
* Move away from vendor of `mvdan.cc/sh` - currently vendoring to work around an issue with single statement printing.

0 commit comments

Comments
 (0)