diff options
author | John L. Villalovos <john@sodarock.com> | 2022-07-28 21:48:04 -0700 |
---|---|---|
committer | John L. Villalovos <john@sodarock.com> | 2022-07-28 21:48:04 -0700 |
commit | 0f4fa8f573c5b8333b6f1c3ffd61dda35b2affae (patch) | |
tree | 6bca063803d0ce673be29d904435766f13f9d468 | |
parent | 8ba97aa459420ec5ae824d9299d6564656841559 (diff) | |
download | gitlab-jlvillal/create_config.tar.gz |
test(ci): create a dummy ~/.python-gitlab.cfg filejlvillal/create_config
Create a working ~/.python-gitlab.cfg file when running the unit tests
in the CI. This is to ensure our unit tests still work if a config
file exists.
-rw-r--r-- | .github/workflows/test.yml | 2 | ||||
-rwxr-xr-x | tests/ci_tools/setup-dummy-config.sh | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0cbe44a..f8ee64b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,6 +52,8 @@ jobs: python-version: ${{ matrix.python.version }} - name: Install dependencies run: pip3 install tox pytest-github-actions-annotate-failures + - name: Setup dummy config + run: tests/ci_tools/setup-dummy-config.sh - name: Run tests env: TOXENV: ${{ matrix.python.toxenv }} diff --git a/tests/ci_tools/setup-dummy-config.sh b/tests/ci_tools/setup-dummy-config.sh new file mode 100755 index 0000000..4a31618 --- /dev/null +++ b/tests/ci_tools/setup-dummy-config.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -u + +if [[ -z "${CI:-}" || -z "${GITHUB_ACTIONS:-}" ]]; then + echo "ERROR: Not running in the GitHub CI." + exit 2 +fi + +CONFIG_FILE=~/.python-gitlab.cfg +if [[ -e "${CONFIG_FILE}" ]]; then + echo "ERROR: Config file already exists: ${CONFIG_FILE}" + echo "Saved you from destroying your config" + exit 2 +fi + +cat <<EOF >"${CONFIG_FILE}" +[global] +default = gitlab +ssl_verify = true +timeout = 5 +api_version = 4 + +[gitlab] +url = https://gitlab.com/ +private_token = not-a-valid-token +EOF + +echo "Setup config at: ${CONFIG_FILE}" |