From 6ab55ba7e1389cdf38098aed215c9970352c14f4 Mon Sep 17 00:00:00 2001 From: Evan Alter Date: Thu, 3 Jul 2025 22:20:37 -0500 Subject: [PATCH] Add bats tests and CI workflow --- .github/workflows/tests.yml | 25 +++++++++++++++++++++++++ tests/bootstrap.bats | 19 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/tests.yml create mode 100755 tests/bootstrap.bats diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000000..2ff34bb2d72 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,25 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Install Bats on Ubuntu + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y bats + - name: Install Bats on macOS + if: matrix.os == 'macos-latest' + run: brew install bats-core + - name: Run tests + run: bats tests diff --git a/tests/bootstrap.bats b/tests/bootstrap.bats new file mode 100755 index 00000000000..7e703fef76c --- /dev/null +++ b/tests/bootstrap.bats @@ -0,0 +1,19 @@ +#!/usr/bin/env bats + +setup() { + TMPHOME="$(mktemp -d)" +} + +teardown() { + rm -rf "$TMPHOME" +} + +@test "bootstrap script syncs dotfiles" { + git() { :; } + export -f git + cd "$BATS_TEST_DIRNAME/.." + HOME="$TMPHOME" run bash bootstrap.sh --force + [ "$status" -eq 0 ] + [ -f "$TMPHOME/.bashrc" ] + [ -f "$TMPHOME/.bash_profile" ] +}