From ca9b0619330bf7ae6e929e2984229366a8c10296 Mon Sep 17 00:00:00 2001 From: Bui Dai <140616004+bhdai@users.noreply.github.com> Date: Thu, 11 Dec 2025 11:02:02 +0700 Subject: [PATCH 1/2] test: cli argument parsing (#11) --- tests/unit/test_argument_parsing.bats | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/unit/test_argument_parsing.bats b/tests/unit/test_argument_parsing.bats index 35fc25d..91a7cc1 100644 --- a/tests/unit/test_argument_parsing.bats +++ b/tests/unit/test_argument_parsing.bats @@ -88,6 +88,46 @@ teardown() { [[ "$output" == *"Usage"* ]] || [[ "$output" == *"-k"* ]] || [[ "$output" == *"help"* ]] } +# ============================================================================= +# Exit Code Tests (AC1, AC3) +# ============================================================================= + +@test "P0: help flag (-h) should exit with code 0" { + run bash setup.sh -h + [ "$status" -eq 0 ] + [[ "$output" == *"Usage"* ]] +} + +@test "P0: help flag (--help) should exit with code 0" { + run bash setup.sh --help + [ "$status" -eq 0 ] + [[ "$output" == *"Usage"* ]] +} + +@test "P0: unknown option should exit with code 1" { + run bash setup.sh --invalid-flag + [ "$status" -eq 1 ] + [[ "$output" == *"Unknown option"* ]] +} + +@test "P0: missing required arguments should exit with code 1" { + run bash setup.sh -k "https://example.com/keys" + [ "$status" -eq 1 ] +} + +@test "P0: unknown option should display specific error message" { + run bash setup.sh -x value + [ "$status" -eq 1 ] + [[ "$output" == *"Unknown option: -x"* ]] +} + +@test "P1: usage message should include branch variable" { + run bash setup.sh -h + [ "$status" -eq 0 ] + # Should show branch in usage (via KAGGLELINK_BRANCH variable) + [[ "$output" == *"BRANCH"* ]] || [[ "$output" == *"main"* ]] +} + # ============================================================================= # URL Validation Tests (Future - when URL validation is implemented) # ============================================================================= From 34c38a715599b8fcbf673f3fcb4eaf54a29246dd Mon Sep 17 00:00:00 2001 From: Bui Dai Date: Thu, 11 Dec 2025 19:07:53 +0700 Subject: [PATCH 2/2] feat: add GitHub Actions workflow to sync setup script to Pages repo --- .github/workflows/sync-setup-script.yml | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/sync-setup-script.yml diff --git a/.github/workflows/sync-setup-script.yml b/.github/workflows/sync-setup-script.yml new file mode 100644 index 0000000..8aad3fe --- /dev/null +++ b/.github/workflows/sync-setup-script.yml @@ -0,0 +1,32 @@ +name: Sync Setup Script to GitHub Pages + +on: + push: + branches: + - main + paths: + - 'setup.sh' + workflow_dispatch: + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - name: Checkout kagglelink repo + uses: actions/checkout@v4 + + - name: Create setup file (without .sh extension) + run: cp setup.sh setup + + - name: Push setup to GitHub Pages repo + uses: dmnemec/copy_file_to_another_repo_action@main + env: + API_TOKEN_GITHUB: ${{ secrets.PAGES_DEPLOY_TOKEN }} + with: + source_file: 'setup' + destination_repo: 'bhdai/bhdai.github.io' + destination_folder: '' + destination_branch: 'master' + user_email: 'github-actions[bot]@users.noreply.github.com' + user_name: 'github-actions[bot]' + commit_message: 'Sync setup script from kagglelink repo'