Skip to content

Commit 4475ff8

Browse files
dmullisdmullis
authored andcommitted
Fix Go package self-test failure, introduced by a914513
Was previously failing Go package self-test due to incorrect version spec syntax in a914513, which had "go-version: '1.20'" in test.yml. Correct status badge stuck on "Passing", hiding CI failures such as the above, by dropping use of GitHub status badges altogether, for reasons elaborated in README.md.tmpl. Drop Windows-based test: There is no Windows-specific code in Goat. Tidy the pre-push workflow for contributors.
1 parent a914513 commit 4475ff8

File tree

5 files changed

+104
-63
lines changed

5 files changed

+104
-63
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@ name: Test
22

33
on:
44
push:
5-
branches: [main]
5+
branches:
66
pull_request:
77
branches: [main]
8+
89
jobs:
910
build:
1011
strategy:
1112
matrix:
12-
go-version: '1.20'
13-
os: [ubuntu-latest, windows-latest]
13+
go-version: [1.20.x]
14+
os: [ubuntu-latest]
1415
runs-on: ${{ matrix.os }}
1516
steps:
1617
- name: Install Go
1718
uses: actions/setup-go@v4
1819
with:
1920
go-version: ${{ matrix.go-version }}
20-
- name: Checkout code
21-
uses: actions/checkout@v3
22-
- name: Test
21+
22+
- name: Check Out Code
23+
uses: actions/checkout@v4
24+
25+
- name: Test Library API For Regressions
2326
run: go test -race -v .

README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
<!-- XX Move this file down to .github/, because its contents are GitHub-specific. -->
2+
13
# GoAT: Go ASCII Tool
24

3-
<!-- Github-specific status icons-->
4-
![](https://github.com/github/docs/actions/workflows/test.yml/badge.svg)
5+
<!-- Github-specific status icon
6+
7+
Github requires explicitly binding a repository owner's username in the text of a README,
8+
implying that a badge in README.md cannot both reflect the status of a test Action after a
9+
contributor pushes to his pull request branch, and
10+
the run of that same test Action after the upstream owner merges the pull request
11+
into his 'main' branch. See:
12+
13+
https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/adding-a-workflow-status-badge
14+
15+
GitHub Community forum shows numerous similar issues with badges:
16+
https://github.com/orgs/community/discussions/categories/actions?discussions_q=is%3Aopen+category%3AActions++badge.svg
17+
18+
=> CONCLUSION: Don't use badges. Instead, pay attention to Action result status.
19+
-->
20+
<!-- ![](https://github.com/blampe/goat/actions/workflows/test.yml/badge.svg) -->
521

622
## What **GoAT** Can Do For You
723

@@ -71,7 +87,7 @@ GoAT's [README.md](README.md), then finally rendered to HTML ```<img>``` element
7187
7288
7389
```
74-
![](./examples/trees.svg)
90+
![](//examples/trees.svg)
7591

7692
### Trees -- mid-range color value
7793
Setting a foreground color in the middle of the possible range of value or luminance
@@ -83,7 +99,7 @@ CSS property by
8399
from within an enclosing `<img>` element such as are generated by Markdown.
84100

85101

86-
![](./trees.mid-blue.svg)
102+
![](//trees.mid-blue.svg)
87103

88104
### Overlaps
89105
```
@@ -97,7 +113,7 @@ from within an enclosing `<img>` element such as are generated by Markdown.
97113
'-' '-' '-' '-' '-' '-'
98114
99115
```
100-
![](./examples/overlaps.svg)
116+
![](//examples/overlaps.svg)
101117

102118
### Line Decorations
103119
```
@@ -110,7 +126,7 @@ from within an enclosing `<img>` element such as are generated by Markdown.
110126
/\ *---------------'
111127
112128
```
113-
![](./examples/line-decorations.svg)
129+
![](//examples/line-decorations.svg)
114130

115131
### Line Ends
116132
```
@@ -127,7 +143,7 @@ from within an enclosing `<img>` element such as are generated by Markdown.
127143
128144
129145
```
130-
![](./examples/line-ends.svg)
146+
![](//examples/line-ends.svg)
131147

132148
### Dot Grids
133149
```
@@ -141,7 +157,7 @@ from within an enclosing `<img>` element such as are generated by Markdown.
141157
142158
```
143159
Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character, encoded with UTF-8.
144-
![](./examples/dot-grids.svg)
160+
![](//examples/dot-grids.svg)
145161

146162
### Large Nodes
147163
```
@@ -156,7 +172,7 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
156172
'-' '---' '-' '---' '-' '-' '---'
157173
158174
```
159-
![](./examples/large-nodes.svg)
175+
![](//examples/large-nodes.svg)
160176

161177
### Small Grids
162178
```
@@ -170,7 +186,7 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
170186
171187
172188
```
173-
![](./examples/small-grids.svg)
189+
![](//examples/small-grids.svg)
174190

175191
### Big Grids
176192
```
@@ -188,7 +204,7 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
188204
189205
190206
```
191-
![](./examples/big-grids.svg)
207+
![](//examples/big-grids.svg)
192208

193209
### Complicated
194210
```
@@ -218,7 +234,7 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
218234
'-' '---------+--' / Nor/is this. ---
219235
220236
```
221-
![](./examples/complicated.svg)
237+
![](//examples/complicated.svg)
222238

223239
### More examples are [here](examples)
224240

@@ -236,7 +252,7 @@ A nicely formatted reference may be found at [pkg.go.dev](https://pkg.go.dev/git
236252
$ go get -u github.com/blampe/goat/
237253
```
238254
### Library Data Flow
239-
![](./goat.svg)
255+
![](//goat.svg)
240256

241257
The diagram above was derived by [./make.sh](./make.sh) from ASCII-art in the Go
242258
source file [./goat.go](./goat.go).

README.md.tmpl

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
<!-- XX Move this file down to .github/, because its contents are GitHub-specific. -->
2+
13
# GoAT: Go ASCII Tool
24

3-
<!-- Github-specific status icons-->
4-
![](https://github.com/github/docs/actions/workflows/test.yml/badge.svg)
5+
<!-- Github-specific status icon
6+
7+
Github requires explicitly binding a repository owner's username in the text of a README,
8+
implying that a badge in README.md cannot both reflect the status of a test Action after a
9+
contributor pushes to his pull request branch, and
10+
the run of that same test Action after the upstream owner merges the pull request
11+
into his 'main' branch. See:
12+
13+
https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/adding-a-workflow-status-badge
14+
15+
GitHub Community forum shows numerous similar issues with badges:
16+
https://github.com/orgs/community/discussions/categories/actions?discussions_q=is%3Aopen+category%3AActions++badge.svg
17+
18+
=> CONCLUSION: Don't use badges. Instead, pay attention to Action result status.
19+
-->
20+
<!-- ![](https://github.com/{{.Github_Repository_Owner}}/goat/actions/workflows/test.yml/badge.svg) -->
521

622
## What **GoAT** Can Do For You
723

@@ -42,7 +58,7 @@ with rows above and below.
4258

4359
## Installation
4460
```
45-
$ go install github.com/{{.GithubUser}}/goat/cmd/goat@latest
61+
$ go install github.com/{{.Github_Repository_Owner}}/goat/cmd/goat@latest
4662
```
4763
<!-- https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections#creating-a-collapsed-section -->
4864

@@ -133,12 +149,12 @@ The core engine of ```goat``` is accessible as a Go library package, for inclusi
133149
code of your own.
134150
The code implements a subset, and some extensions, of the ASCII diagram generation function of the browser-side Javascript in [Markdeep](http://casual-effects.com/markdeep/).
135151

136-
A nicely formatted reference may be found at [pkg.go.dev](https://pkg.go.dev/github.com/{{.GithubUser}}/goat).
152+
A nicely formatted reference may be found at [pkg.go.dev](https://pkg.go.dev/github.com/{{.Github_Repository_Owner}}/goat).
137153

138154
### Installation
139155

140156
```
141-
$ go get -u github.com/{{.GithubUser}}/goat/
157+
$ go get -u github.com/{{.Github_Repository_Owner}}/goat/
142158
```
143159
### Library Data Flow
144160
![]({{.Root}}/goat.svg)
@@ -150,13 +166,13 @@ source file [./goat.go](./goat.go).
150166

151167
<!--
152168
XX XX May need a Github Action to do this substitution at "push" time.
153-
[![resource non-responsive](https://pkg.go.dev/badge/github.com/{{.GithubUser}}/goat)](https://pkg.go.dev/github.com/{{.GithubUser}}/goat)
169+
[![resource non-responsive](https://pkg.go.dev/badge/github.com/{{.Github_Repository_Owner}}/goat)](https://pkg.go.dev/github.com/{{.Github_Repository_Owner}}/goat)
154170
-->
155171

156172
<!--
157173
The scraping of GitHub by godocs.io (see https://sr.ht) does NOT include README.md;
158174
whereas Google's pkg.go.dev does do so, and apparently runs its own variant of GFM processing :-/
159-
[![resource non-responsive](https://godocs.io/github.com/{{.GithubUser}}/goat?status.svg)](https://godocs.io/github.com/{{.GithubUser}}/goat)
175+
[![resource non-responsive](https://godocs.io/github.com/{{.Github_Repository_Owner}}/goat?status.svg)](https://godocs.io/github.com/{{.Github_Repository_Owner}}/goat)
160176
-->
161177

162178
### Project Tenets

local-markdown.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#! /bin/sh
2+
3+
# Render to HTML, for local inspection.
4+
./markdown_to_html.sh README.md >README.html
5+
./markdown_to_html.sh CHANGELOG.md >CHANGELOG.html

make.sh renamed to pre-push.sh

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,47 @@
33
# Run all tests, and all pre-compilation build steps.
44
# Certain output files should be committed to the SCM archive.
55
#
6-
# Recall that an end-user eventually installing with 'go get ...'
7-
# will trigger a compilation from source within the local environment.
8-
# XX Give this file a more descriptive name.
6+
# Recall that an end-user eventually installing with 'go get ...' will
7+
# trigger a compilation from source within the local environment,
8+
# without help from this file.
99

1010
set -e
1111
set -x
1212
usage () {
13+
set +x
1314
printf "%s\n\n" "$*"
14-
printf "usage: %s [-g GitHub_Username] [-w]\n" ${0##*/}
15+
printf "usage: %s [-w]\n" ${0##*/}
1516
printf "\t%s\t%s\n" ""
1617
printf "\t%s\t%s\n" "$*"
1718
exit 1
1819
}
1920

20-
# Define colors for SVG ~foreground~ seen on Github front page.
21-
svg_color_dark_scheme="#EEF"
22-
svg_color_light_scheme="#011"
23-
github_blue_color="#2F81F7"
24-
25-
# GOMOD=$(go env GOMOD)
26-
# from_username=${GOMOD##*github.com/}
27-
# githubuser=${from_username%%/*}
28-
#
29-
# X Is it acceptable to push to a PR branch files that refer to the owner's main branch?
30-
githubuser=blampe
31-
3221
TEST_ARGS=
33-
3422
while getopts hg:iw flag
3523
do
3624
case $flag in
3725
h) usage "";;
38-
g) githubuser=${OPTARG};; # Override guess based on GOMOD
3926
w) TEST_ARGS=${TEST_ARGS}" -write";;
4027
\?) usage "unrecognized option flag";;
4128
esac
4229
done
4330

31+
PACKAGE_PATH=$(go list .)
32+
UPSTREAM_OWNER=${PACKAGE_PATH#*/}
33+
UPSTREAM_OWNER=${UPSTREAM_OWNER%/*}
34+
35+
GITHUB_REPOSITORY_OWNER=$USER
36+
CURRENT_BRANCH_NAME=$(git-branch --show-current)
37+
# If the current branch name contains the GitHub username of the owner of the upstream repo,
38+
# assume the intention is to prepare and push a pull request.
39+
if [ $(expr $CURRENT_BRANCH_NAME : ".*$UPSTREAM_OWNER") != 0 ]
40+
then
41+
GITHUB_REPOSITORY_OWNER=$UPSTREAM_OWNER
42+
fi
43+
4444
tmpl_expand () {
45-
go run ./cmd/tmpl-expand Root="." GithubUser=${githubuser} "$@"
45+
# XX Root="/" resolves to root of the repo -- consider dropping the variable.
46+
go run ./cmd/tmpl-expand Root="/" Github_Repository_Owner=${GITHUB_REPOSITORY_OWNER} "$@"
4647
}
4748

4849
#tmpl_expand <go.tmpl.mod >go.mod
@@ -51,27 +52,18 @@ tmpl_expand () {
5152
# SVG examples/ regeneration.
5253
#
5354
# If the command fails due to expected changes in SVG output, rerun
54-
# this script with "TEST_ARGS=-write" first on the command line.
55+
# this script with "TEST_ARGS=-write".
5556
# X Results are used as "golden" standard for GitHub-side regression tests --
5657
# so arguments here must not conflict with those in "test.yml".
5758
# XX How to share a single arg list shared between the two i.e. "DRY"?
5859
go test -run . -v \
5960
${TEST_ARGS}
6061

61-
# Illustrate a workaround for lack of support in certain browsers e.g. Safari for
62-
# inheritance of CSS property 'color-scheme' from <img> elements downward to nested
63-
# <svg> elements.
64-
# - https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
65-
go run ./cmd/goat <examples/trees.txt \
66-
-svg-color-dark-scheme ${github_blue_color} \
67-
-svg-color-light-scheme ${github_blue_color} \
68-
>trees.mid-blue.svg
69-
70-
# build README.md
71-
tmpl_expand <README.md.tmpl >README.md \
72-
$(bash -c 'echo ./examples/{trees,overlaps,line-decorations,line-ends,dot-grids,large-nodes,small-grids,big-grids,complicated}.{txt,svg}')
73-
74-
# '-d' writes ./awkvars.out
62+
# Build other SVG files; linked to by README.md but not used for regression test.
63+
# Define colors for SVG ~foreground~ seen on Github front page.
64+
svg_color_dark_scheme="#EEF"
65+
svg_color_light_scheme="#011"
66+
github_blue_color="#2F81F7"
7567
cat *.go |
7668
awk '
7769
/[<]goat[>]/ {p = 1; next}
@@ -82,7 +74,16 @@ cat *.go |
8274
-svg-color-dark-scheme ${svg_color_dark_scheme} \
8375
-svg-color-light-scheme ${svg_color_light_scheme} \
8476
>goat.svg
77+
# Illustrate a workaround for lack of support in certain browsers e.g. Safari for
78+
# inheritance of CSS property 'color-scheme' from <img> elements downward to nested
79+
# <svg> elements.
80+
# - https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
81+
go run ./cmd/goat <examples/trees.txt \
82+
-svg-color-dark-scheme ${github_blue_color} \
83+
-svg-color-light-scheme ${github_blue_color} \
84+
>trees.mid-blue.svg
8585

86-
# Render to HTML, for local inspection.
87-
./markdown_to_html.sh README.md >README.html
88-
./markdown_to_html.sh CHANGELOG.md >CHANGELOG.html
86+
# build README.md
87+
# X `tac` is a slightly sleazy way to get the .txt/.svg pairs listed in the
88+
# source/dest order as required by tmpl_expand.
89+
tmpl_expand <README.md.tmpl >README.md $(git-ls-files examples | tac)

0 commit comments

Comments
 (0)