diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4020820..6bd9a0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: just ${{ matrix.just_goals || 'build test' }} + env: + GPTCOMMIT__OPENAI__API_KEY: ${{ secrets.GPTCOMMIT__OPENAI__API_KEY }} lint: runs-on: ubuntu-latest diff --git a/Justfile b/Justfile index e940256..94311e3 100644 --- a/Justfile +++ b/Justfile @@ -21,7 +21,10 @@ release: install: cargo install --path . -test *args: +e2e: install + sh -eux -c 'for i in ./e2e/test_*.sh ; do sh -x $i ; done' + +test *args: e2e cargo test alias t := test diff --git a/e2e/test_config_list_get_set.sh b/e2e/test_config_list_get_set.sh new file mode 100755 index 0000000..48a2a52 --- /dev/null +++ b/e2e/test_config_list_get_set.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -eu + +gptcommit config list +# assert is valid TOML + +gptcommit config get openai.model +# assert default = text-davinci-003 +gptcommit config set openai.model foo +gptcommit config get openai.model +# assert is foo + +gptcommit config delete openai.model +gptcommit config get openai.model +# back to default diff --git a/e2e/test_githook.sh b/e2e/test_githook.sh new file mode 100755 index 0000000..40427b4 --- /dev/null +++ b/e2e/test_githook.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -eu + +( + mkdir test_dir_foo4 + cd test_dir_foo4 + git init + + export TEMPFILE=$(mktemp) + echo "foo" > $TEMPFILE + + GPTCOMMIT__OPENAI__MODEL="text-ada-001" \ + gptcommit prepare-commit-msg \ + --git-diff-content ../tests/data/example_1.diff \ + --commit-msg-file $TEMPFILE \ + --commit-source "" + + cat $TEMPFILE +) +rm -rf test_dir_foo4 diff --git a/e2e/test_install.sh b/e2e/test_install.sh new file mode 100755 index 0000000..e8eaf66 --- /dev/null +++ b/e2e/test_install.sh @@ -0,0 +1,36 @@ +#!/bin/sh +set -eu + +( + mkdir test_dir_foo + cd test_dir_foo + git init + gptcommit install + + # assert that git hook is installed + gptcommit install + # assert still works +) +rm -rf test_dir_foo ; + +############################# + +( + mkdir test_dir_foo2 + cd test_dir_foo2 + git init + mkdir a + cd a + gptcommit install +) +rm -rf test_dir_foo2 + +############################# + +( + mkdir test_dir_foo3 + cd test_dir_foo3 + # no git init + gptcommit install ; +) +rm -rf test_dir_foo3 diff --git a/e2e/test_version.sh b/e2e/test_version.sh new file mode 100755 index 0000000..2503485 --- /dev/null +++ b/e2e/test_version.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +gptcommit --version +# assert matches version in Cargo.toml + +gptcommit --help +