From 38637dafa1937cbe3c6730972dd0ea967650ff47 Mon Sep 17 00:00:00 2001 From: macie Date: Fri, 10 Nov 2023 21:12:09 +0100 Subject: [PATCH] ci: Migrate to GitHub Actions I wanted to use the same CI server in my projects for easier maintenance. --- .circleci/config.yml | 18 ------------------ .github/workflows/check.yml | 27 +++++++++++++++++++++++++++ .gitignore | 20 +++++++++++--------- Makefile | 15 +++++++-------- README.md | 16 ++++++++++++---- 5 files changed, 57 insertions(+), 39 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/check.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 813cc01..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: 2.1 - -jobs: - test: - docker: - - image: cimg/base:stable - steps: - - checkout - - run: - name: "run tests and shellcheck" - command: make - -workflows: - version: 2 - basic: - jobs: - - test - diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..6ee24b5 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,27 @@ +name: Quality check +on: + push: + branches: + - "*" + pull_request: + +jobs: + static-analysis: + name: Static analysis + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + + - run: make check + + tests: + name: Tests + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + + - run: make test diff --git a/.gitignore b/.gitignore index f7c6ef1..928212b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,16 +3,18 @@ # Ignore everything * -# But not these files... +# Allow CI configs !/.gitignore -!README.md -!CONTRIBUTING.md -!LICENSE - -!.circleci/* -!Makefile +!/Makefile +!/.github/workflows/*.yml +# Allow source code... !unittest -!tests/ -!tests/*.sh +!*.sh + +!README.md +!LICENSE +!CONTRIBUTING.md +# ...also in subdirectories +!*/ diff --git a/Makefile b/Makefile index 047529e..de56f9f 100644 --- a/Makefile +++ b/Makefile @@ -6,26 +6,25 @@ TEST=./unittest # MAIN TARGETS -all: test check +all: -debug: - @printf '> OS info: ' +info: + @printf '# OS info: ' @uname -rsv; - @printf '> Development dependencies:\n' + @printf '# Development dependencies:\n' @echo; $(LINT) -V @echo; $(TEST) -v check: $(LINT) - @printf '> Static analysis: $(LINT) unittest tests/*.sh' >&2 + @printf '# Static analysis: $(LINT) unittest tests/*.sh' >&2 @$(LINT) unittest tests/*.sh test: - @echo '> Unit tests: $(TEST)' >&2 + @echo '# Unit tests: $(TEST)' >&2 @$(TEST) # HELPERS $(LINT): - @printf '> $@ installation path: ' >&2 + @printf '# $@ installation path: ' >&2 @command -v $@ >&2 || { echo 'ERROR: Cannot find $@' >&2; exit 1; } - diff --git a/README.md b/README.md index 91d41b7..4632258 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # unittest -[![Build Status](https://dl.circleci.com/status-badge/img/gh/macie/unittest.sh/tree/master.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/macie/unittest.sh/tree/master) +[![Quality check status](https://github.com/macie/unittest.sh/actions/workflows/check.yml/badge.svg)](https://github.com/macie/unittest.sh/actions/workflows/check.yml) _Unittest is the standard test runner._ @@ -16,7 +16,7 @@ in any language. ## Usage -With a basic call, it searches inside `tests\` directory for `test_*.sh` files with `test_*` functions: +With a basic call, it searches inside `tests/` directory for `test_*.sh` files with `test_*` functions: ```bash $ unittest @@ -57,7 +57,7 @@ tests/test_output.sh:test_status_fail PASS For example, tests see files inside the [tests directory](./tests). -## Install +## Installation Using `curl`: ```bash @@ -72,6 +72,15 @@ wget https://raw.githubusercontent.com/macie/unittest.sh/master/unittest chmod +x unittest ``` +## Development + +Use `make` (GNU or BSD): + +- `make` - check dependencies +- `make test` - runs test +- `make check` - static code analysis +- `make info` - print system info (useful for debugging). + ## Alternatives Robert Lehmann created a list of [the most popular shell testing tools](https://github.com/lehmannro/assert.sh#related-projects). @@ -122,4 +131,3 @@ PASS ``` Finally, all tests from a file can be run with some `grep` and loop. And this is basically `unittest`. -