Skip to content

Commit

Permalink
Can't run txtar with coverage (#688)
Browse files Browse the repository at this point in the history
Reorg how tests run.
  • Loading branch information
sourishkrout authored Oct 19, 2024
1 parent 2413b43 commit efb7bca
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,34 @@ runme:
version: v3
shell: bash
skipPrompts: true
terminalRows: 26
---

## CI/CD

Run all tests with coverage reports.

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

Run txtar-based CLI e2e tests without coverage reports (Go's warnings are getting in the way).

```sh {"id":"01JAJYWF198MWQXJBADFJVJGXM","name":"ci-txtar"}
unset RUNME_SESSION_STRATEGY RUNME_TLS_DIR RUNME_SERVER_ADDR
export SHELL="/bin/bash"
export TZ="UTC"
export TAGS="test_with_txtar"
export RUN="^TestRunme\w*"
export PKGS="github.com/stateful/runme/v3"
make test
```

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

```sh {"id":"01J5XXFEGPJ5ZJZERQ5YGBBRN8","name":"ci-test-parser","promptEnv":"no"}
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ jobs:
run: |
go build -o runme main.go
./runme --version
- name: Test
- name: Test with coverage
uses: stateful/runme-action@v2
with:
workflows: ci-coverage
env:
NO_COLOR: true
FROM_CI: true
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Test without coverage (txtar)
uses: stateful/runme-action@v2
with:
workflows: ci-test
workflows: ci-txtar
env:
NO_COLOR: true
FROM_CI: true
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"--proto_path=/usr/local/include/protoc"
]
},
"go.buildTags": "test_with_docker"
"go.buildTags": "test_with_docker,test_with_txtar"
// Uncomment if you want to work on files in ./web.
// "go.buildTags": "js,wasm",
// Uncomment if you want to check compilation errors on Windows.
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ pre-commit run --files */**

Tests are run with Go's default test runner wrapped in Makefile targets. So, for example, you can run all tests with:

```sh {"id":"01HF7BT3HEQBTBM9SSTS88ZSCF","name":"test","terminalRows":"15"}
```sh {"id":"01HF7BT3HEQBTBM9SSTS88ZSCF","name":"test","promptEnv":"no","terminalRows":"15"}
unset RUNME_SESSION_STRATEGY RUNME_TLS_DIR RUNME_SERVER_ADDR
go clean -testcache
TAGS="test_with_docker" make test
export TAGS="test_with_txtar"
make test
```

Please notice that our tests include integration tests which depend on additional software like Python or node.js. If you don't want to install them or tests fail because of different versions, you can run all tests in a Docker container:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test/execute: build
.PHONY: test/coverage
test/coverage: PKGS ?= "./..."
test/coverage: RUN ?= .*
test/coverage: GOCOVERDIR ?= "."
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".
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !windows
//go:build !windows && test_with_txtar

package main

Expand Down

0 comments on commit efb7bca

Please sign in to comment.