Skip to content

Improve CI tests runtime (halved) #353

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

Merged
merged 17 commits into from
Oct 6, 2024
Merged
Changes from all 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
54 changes: 33 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -7,52 +7,51 @@ on:
- main

jobs:
tests:
name: "Run tests on ${{ matrix.os }}"
ubuntu-macos:
name: "On ${{ matrix.os }}"
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
matrix:
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 }}
run: make test

simple-output:
name: "Run tests with simple output"
runs-on: ubuntu-latest
windows:
name: "On windows (${{ matrix.test_chunk }})"
timeout-minutes: 10
runs-on: windows-latest
strategy:
matrix:
test_chunk: [acceptance, functional, unit]
fail-fast: false
steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1

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

alpine:
name: "Run tests on alpine-latest"
name: "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: |
@@ -62,3 +61,16 @@ jobs:
adduser -D builder && \
chown -R builder /project && \
su - builder -c 'cd /project; make test';"

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

- name: Run Tests
run: |
./bashunit -e tests/bootstrap.sh --simple tests/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions src/console_results.sh
Original file line number Diff line number Diff line change
@@ -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() {
6 changes: 3 additions & 3 deletions tests/unit/console_results_test.sh
Original file line number Diff line number Diff line change
@@ -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() {
@@ -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() {
@@ -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() {
8 changes: 6 additions & 2 deletions tests/unit/globals_test.sh
Original file line number Diff line number Diff line change
@@ -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() {
Loading