Skip to content

Commit 0f4fa8f

Browse files
test(ci): create a dummy ~/.python-gitlab.cfg file
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.
1 parent 8ba97aa commit 0f4fa8f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.github/workflows/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ jobs:
5252
python-version: ${{ matrix.python.version }}
5353
- name: Install dependencies
5454
run: pip3 install tox pytest-github-actions-annotate-failures
55+
- name: Setup dummy config
56+
run: tests/ci_tools/setup-dummy-config.sh
5557
- name: Run tests
5658
env:
5759
TOXENV: ${{ matrix.python.toxenv }}

tests/ci_tools/setup-dummy-config.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -u
4+
5+
if [[ -z "${CI:-}" || -z "${GITHUB_ACTIONS:-}" ]]; then
6+
echo "ERROR: Not running in the GitHub CI."
7+
exit 2
8+
fi
9+
10+
CONFIG_FILE=~/.python-gitlab.cfg
11+
if [[ -e "${CONFIG_FILE}" ]]; then
12+
echo "ERROR: Config file already exists: ${CONFIG_FILE}"
13+
echo "Saved you from destroying your config"
14+
exit 2
15+
fi
16+
17+
cat <<EOF >"${CONFIG_FILE}"
18+
[global]
19+
default = gitlab
20+
ssl_verify = true
21+
timeout = 5
22+
api_version = 4
23+
24+
[gitlab]
25+
url = https://gitlab.com/
26+
private_token = not-a-valid-token
27+
EOF
28+
29+
echo "Setup config at: ${CONFIG_FILE}"

0 commit comments

Comments
 (0)