Skip to content

Commit

Permalink
Avoid warning for GOCOVERDIR not set (#687)
Browse files Browse the repository at this point in the history
1. The warning interferes with textar CLI test cases.
2. Unbreak parser CI
  • Loading branch information
sourishkrout authored Oct 19, 2024
1 parent 98d852c commit 2413b43
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/CI.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
cwd: ../..
runme:
id: 01JAGWRDZSF2NHJA774WHDDD1V
version: v3
shell: bash
skipPrompts: true
---
Expand All @@ -8,15 +11,21 @@ skipPrompts: true

Run all tests with coverage reports.

```sh {"id":"01J5XTG2WKVR4WG7B2FNPF6VZT","name":"ci-test"}
```sh {"id":"01J5XTG2WKVR4WG7B2FNPF6VZT","name":"ci-test","promptEnv":"no"}
unset RUNME_SESSION_STRATEGY RUNME_TLS_DIR RUNME_SERVER_ADDR
export SHELL="/bin/bash"
export TZ="UTC"
TAGS="test_with_docker" make test/coverage
export GOCOVERDIR="."
export TAGS="test_with_docker"
make test/coverage
make test/coverage/func
```

Run parser/serializer against a large quantity of markdown files.

```sh {"id":"01J5XXFEGPJ5ZJZERQ5YGBBRN8","name":"ci-test-robustness"}
make test/robustness
```sh {"id":"01J5XXFEGPJ5ZJZERQ5YGBBRN8","name":"ci-test-parser","promptEnv":"no"}
export GOPATH="$(go env GOPATH)"
export NUM_OF_FILES=$(find "$GOPATH/pkg/mod/github.com" -name "*.md" | grep -v "\/\." | grep -v glamour | xargs dirname | uniq | wc -l | tr -d " ")
echo "Checking $NUM_OF_FILES files inside GOPATH=$GOPATH"
make test/parser
```
21 changes: 7 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,40 +95,33 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test
run: make test-docker
- name: Test parser
uses: stateful/runme-action@v2
with:
workflows: test-docker

build-and-robustness-test:
name: Test parser against vast amount of READMEs
build-and-parser-test:
name: Test parser against vast amount of Markdowns
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node version
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: ">=1.22"
- name: Install dependencies
run: make install/dev
- name: Build
- name: Setup & build
uses: stateful/runme-action@v2
with:
workflows: build
workflows: |
setup
build
- name: Test parser
uses: stateful/runme-action@v2
with:
workflows: |
build
ci-test-robustness
ci-test-parser
timeout-minutes: 5
- name: Debug Build
uses: stateful/vscode-server-action@v1.1.0
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test/coverage: TAGS ?= "" # e.g. TAGS="test_with_docker"
# It depends on the build target because the runme binary
# is used for tests, for example, "runme env dump".
test/coverage: build
TZ=UTC go test -ldflags="$(LDTESTFLAGS)" -run="$(RUN)" -tags="$(TAGS)" -timeout=90s -covermode=atomic -coverprofile=cover.out -coverpkg=./... $(PKGS)
TZ=UTC go test -ldflags="$(LDTESTFLAGS)" -run="$(RUN)" -tags="$(TAGS)" -timeout=180s -covermode=atomic -coverprofile=cover.out -coverpkg=./... $(PKGS)

.PHONY: test
test: test/execute
Expand All @@ -58,6 +58,7 @@ test-docker: test-docker/setup test-docker/run
.PHONY: test-docker/setup
test-docker/setup:
docker build \
--progress=plain \
-t runme-test-env:latest \
-f ./docker/runme-test-env.Dockerfile .
docker volume create dev.runme.test-env-gocache
Expand All @@ -77,10 +78,10 @@ test-docker/run:
test/update-snapshots:
@TZ=UTC UPDATE_SNAPSHOTS=true go test ./...

.PHONY: test/robustness
test/robustness:
.PHONY: test/parser
test/parser:
./runme --version
find "$$GOPATH/pkg/mod/github.com" -name "*.md" | grep -v "\/\." | xargs dirname | uniq | xargs -n1 -I {} ./runme fmt --project {} > /dev/null
find "$$GOPATH/pkg/mod/github.com" -name "*.md" | grep -v "\/\." | grep -v glamour | xargs dirname | uniq | xargs -n1 -I {} ./runme fmt --project {} > /dev/null

.PHONY: coverage/html
test/coverage/html:
Expand Down
4 changes: 2 additions & 2 deletions pkg/document/parser_frontmatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func parseRawFrontmatter(l *itemParser, delimiter byte) parserStateFunc {
if !wasEndOfLine {
r = l.next()
if r == eof {
l.errorf("got EOF while looking for the end of the front matter delimiter")
l.errorf("got EOF while looking for the end of the frontmatter delimiter")
return nil
}
}
Expand Down Expand Up @@ -56,7 +56,7 @@ func parseRawFrontmatterJSON(l *itemParser) parserStateFunc {

switch {
case r == eof:
l.errorf("got EOF while looking for the end of the JSON front matter")
l.errorf("got EOF while looking for the end of the JSON frontmatter")
return nil
case r == '{':
if !inQuote {
Expand Down
2 changes: 1 addition & 1 deletion pkg/project/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func FormatFiles(files []string, options *FormatOptions) error {

formatted, err := formatFile(data, options)
if err != nil {
return err
return errors.Wrapf(err, "failed to format %s", file)
}

if options.Write {
Expand Down

0 comments on commit 2413b43

Please sign in to comment.