Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI tests runtime (halved) #353

Merged
merged 17 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,47 @@ on:

jobs:
tests:
name: "Run tests on ${{ matrix.os }}"
name: "Tests on ${{ matrix.os }} (${{ matrix.test_chunk }})"
runs-on: ${{ matrix.os }}
strategy:
matrix:
test_chunk: [acceptance, functional, unit]
os:
- ubuntu-latest
- macos-latest
- windows-latest
include:
- os: windows-latest
script_name: 'bash -c "./bashunit -e tests/bootstrap.sh tests/**/*_test.sh"'
- os: macos-latest
script_name: 'make test'
- os: ubuntu-latest
script_name: 'make test'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1

- name: Run Tests
run: ${{ matrix.script_name }}
shell: bash
run: |
./bashunit -e tests/bootstrap.sh tests/${{ matrix.test_chunk }}/*_test.sh

simple-output:
name: "Run tests with simple output"
name: "Tests simple output"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1

- name: Run Tests
run: |
./bashunit -e tests/bootstrap.sh --simple tests/

alpine:
name: "Run tests on alpine-latest"
name: "Tests on alpine-latest"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1

- name: Run Tests
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- cleanup_temp_files
- log
- Improved clean up temporal files and directories
- Improved CI test speed by running them in parallel

## [0.17.0](https://github.com/TypedDevs/bashunit/compare/0.16.0...0.17.0) - 2024-10-01

Expand Down
4 changes: 2 additions & 2 deletions src/console_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ function console_results::print_execution_time() {
return
fi

_EXECUTION_TIME=$(clock::total_runtime_in_milliseconds)
printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" "Time taken: ${_EXECUTION_TIME} ms"
printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" \
"Time taken: $(clock::total_runtime_in_milliseconds) ms"
}

function console_results::print_successful_test() {
Expand Down
4 changes: 3 additions & 1 deletion src/globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ function current_timestamp() {
}

function is_command_available() {
command -v "$1" >/dev/null 2>&1
if ! command -v "$1" >/dev/null 2>&1; then
return 1
fi
}

function random_str() {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/console_results_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function test_render_execution_time() {

console_results::render_result
)
assert_matches "Time taken: [[:digit:]]+ ms" "$render_result"
assert_matches "Time taken: [[:digit:]]+(\.[[:digit:]]+)? ms" "$render_result"
}

function test_not_render_execution_time() {
Expand Down Expand Up @@ -304,7 +304,7 @@ function test_render_execution_time_on_osx_without_perl() {
console_results::render_result
)

assert_matches "Time taken: [[:digit:]]+ ms" "$render_result"
assert_matches "Time taken: [[:digit:]]+(\.[[:digit:]]+)? ms" "$render_result"
}

function test_render_execution_time_on_osx_with_perl() {
Expand All @@ -326,7 +326,7 @@ function test_render_execution_time_on_osx_with_perl() {
console_results::render_result
)

assert_matches "Time taken: [[:digit:]]+ ms" "$render_result"
assert_matches "Time taken: [[:digit:]]+(\.[[:digit:]]+)? ms" "$render_result"
}

function test_render_file_with_duplicated_functions_if_found_true() {
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/globals_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ function test_globals_current_timestamp() {
}

function test_globals_is_command_available() {
assert_successful_code "$(is_command_available ls)"
function existing_fn(){
# shellcheck disable=SC2317
return 0
}
assert_successful_code "$(is_command_available existing_fn)"
}

function test_globals_is_command_not_available() {
assert_general_error "$(is_command_available non-existing-command)"
assert_general_error "$(is_command_available non_existing_fn)"
}

function test_globals_random_str_default() {
Expand Down
Loading