diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..9fddac3 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + target-branch: main diff --git a/.github/workflows/local-test-on-mac.yaml b/.github/workflows/local-test-on-mac.yaml new file mode 100644 index 0000000..29ed6ce --- /dev/null +++ b/.github/workflows/local-test-on-mac.yaml @@ -0,0 +1,38 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + workflow_dispatch: + +jobs: + test-packages: + name: test-local-brew + strategy: + fail-fast: false + matrix: + os: [macos-12, macos-13, macos-14, macos-latest] + runs-on: ${{ matrix.os }} + env: + TERM: xterm + steps: + - uses: actions/checkout@v2 + - name: Set up Homebrew + uses: Homebrew/actions/setup-homebrew@master + - name: Brew version output + run: brew --version + - name: INSTALL bats-core + run: | + brew list bats && brew uninstall bats || echo "bats is not present" + brew install bats-core + - name: INSTALL bats-libraries + run: | + brew tap bats-core/bats-core + brew install bats-support + brew install bats-assert + brew install bats-file + brew install bats-detik + - name: LOCAL TEST + run: | + bats -T -p tests diff --git a/.github/workflows/test-brew-formulae.yaml b/.github/workflows/test-brew-formulae.yaml index 30e2b4e..07c0379 100644 --- a/.github/workflows/test-brew-formulae.yaml +++ b/.github/workflows/test-brew-formulae.yaml @@ -1,4 +1,4 @@ -name: test-bats-libs-formulae +name: CI on: push: @@ -8,13 +8,16 @@ on: jobs: test-packages: + name: test-formulae strategy: fail-fast: false matrix: package: [bats-support, bats-assert, bats-detik, bats-file] - runs-on: macos-latest + os: [macos-12, macos-13, macos-14, macos-latest] + runs-on: ${{ matrix.os }} env: PACKAGE: ${{ matrix.package }} + TERM: xterm steps: - uses: actions/checkout@v2 - name: Set up Homebrew diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7897fc4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +repos: + - repo: https://github.com/sirosen/check-jsonschema + rev: 0.28.4 + hooks: + - id: check-github-workflows + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: detect-private-key + - id: trailing-whitespace + - id: end-of-file-fixer diff --git a/Formula/bats-detik.rb b/Formula/bats-detik.rb index c430a00..ac6f261 100644 --- a/Formula/bats-detik.rb +++ b/Formula/bats-detik.rb @@ -1,8 +1,8 @@ class BatsDetik < Formula desc "Library to ease e2e tests of applications in K8s environments" homepage "https://github.com/bats-core/bats-detik" - url "https://github.com/bats-core/bats-detik/archive/refs/tags/v1.3.1.tar.gz" - sha256 "1cf48a74c505d95950c45bab757fd4a65040aa6766889f0be8f54279827b9bff" + url "https://github.com/bats-core/bats-detik/archive/refs/tags/v1.3.2.tar.gz" + sha256 "cb95587cd0e493595eef725339c2d5aa1ad824f459c6e53a9a378e7966008773" license "MIT" head "https://github.com/bats-core/bats-detik.git", branch: "master" diff --git a/tests/1-example-tests.bats b/tests/1-example-tests.bats new file mode 100644 index 0000000..0bbccd5 --- /dev/null +++ b/tests/1-example-tests.bats @@ -0,0 +1,92 @@ +setup() { + load 'tests_helper' + _tests_helper +} + +#bats test_tags=github:true +@test "0: Pre: Create file and dir" { + _create_dir_file + _delete_dir_file +} + +#bats test_tags=github:true +@test "1: Testing file existence" { + _create_dir_file + + run ls testing/example + assert_success + run [ -f "testing/example" ] + assert_success + + _delete_dir_file +} + +#bats test_tags=github:true +@test "2: Testing file permissions" { + _create_dir_file + + run stat -f%p testing/example + assert_success + assert_output 100644 + assert_file_permission 644 testing/example + assert_success + + _delete_dir_file +} + +#bats test_tags=github:true +@test "3: Testing file content" { + _create_dir_file + + run cat testing/example + assert_success + refute_output "Expected content" + assert_file_empty testing/example + assert_success + + _delete_dir_file +} + +#bats test_tags=github:true +@test "4: Testing directory creation" { + _create_dir_file + + run mkdir testing/newdir + assert_success + + [ -d "testing/newdir" ] + assert_success + + run rmdir testing/newdir + assert_success + + _delete_dir_file +} + +#bats test_tags=github:true +@test "5: Testing file creation and deletion inside directory" { + _create_dir_file + + run mkdir testing/newdir + assert_success + + run touch testing/newdir/newfile + assert_success + + run [ -f "testing/newdir/newfile" ] + assert_success + + run rm testing/newdir/newfile + assert_success + + [ ! -f "testing/newdir/newfile" ] + assert_success + + run rmdir testing/newdir + assert_success + + run [ ! -d "testing/newdir" ] + assert_success + + _delete_dir_file +} diff --git a/tests/tests_helper.bash b/tests/tests_helper.bash new file mode 100644 index 0000000..8786c64 --- /dev/null +++ b/tests/tests_helper.bash @@ -0,0 +1,24 @@ +_tests_helper() { + _BREW_PREFIX="$(brew --prefix)" + export BATS_LIB_PATH="${BATS_LIB_PATH}:${_BREW_PREFIX}/lib" + bats_load_library bats-support + bats_load_library bats-assert + bats_load_library bats-file + bats_load_library bats-detik/detik.bash +} + +_create_dir_file() { + run mkdir testing + assert_success + + run touch testing/example + assert_success +} + +_delete_dir_file() { + run rm testing/example + assert_success + + run rmdir testing + assert_success +}