From 4fe3940763226db8efc21e8be88fdeac7bf0398f Mon Sep 17 00:00:00 2001 From: Sebastian Tiedtke Date: Sat, 19 Oct 2024 11:24:34 -0700 Subject: [PATCH 1/2] Can't run txtar with coverage --- .github/workflows/CI.md | 14 ++++++++++++-- .github/workflows/ci.yml | 12 ++++++++++-- .vscode/settings.json | 2 +- CONTRIBUTING.md | 5 +++-- Makefile | 1 + main_test.go | 2 +- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/CI.md b/.github/workflows/CI.md index 828895a6a..4ca3cb74f 100644 --- a/.github/workflows/CI.md +++ b/.github/workflows/CI.md @@ -5,22 +5,32 @@ 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" +make test +``` + Run parser/serializer against a large quantity of markdown files. ```sh {"id":"01J5XXFEGPJ5ZJZERQ5YGBBRN8","name":"ci-test-parser","promptEnv":"no"} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55d045e05..6ace6e6c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.vscode/settings.json b/.vscode/settings.json index a18592e30..d37c537ed 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e16505fb..58a642a0d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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: diff --git a/Makefile b/Makefile index 83f5bcc35..3cb26410e 100644 --- a/Makefile +++ b/Makefile @@ -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". diff --git a/main_test.go b/main_test.go index 6d2257f1c..a206f27d5 100644 --- a/main_test.go +++ b/main_test.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build !windows && test_with_txtar package main From 7beb4268f2ac3085ea83ed521eff7791f70bdeb5 Mon Sep 17 00:00:00 2001 From: Sebastian Tiedtke Date: Sat, 19 Oct 2024 11:32:55 -0700 Subject: [PATCH 2/2] Only run txtar --- .github/workflows/CI.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CI.md b/.github/workflows/CI.md index 4ca3cb74f..72d6d0c18 100644 --- a/.github/workflows/CI.md +++ b/.github/workflows/CI.md @@ -28,6 +28,8 @@ 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 ```