Skip to content

Commit 7d7b634

Browse files
committed
Fix Docker integration test
Also: - Create scripts/ folder to keep the scripts together - Update make clean target
1 parent b59e0e3 commit 7d7b634

10 files changed

+34
-24
lines changed

.github/workflows/CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Get versions
1919
id: versions
2020
run: |
21-
py_version="$(./get_version.sh __py_version__)"
21+
py_version="$(./scripts/get_version.sh __py_version__)"
2222
echo "::set-output name=py_version::$py_version"
2323
2424
pre_commit:

.github/workflows/integration.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ jobs:
2020

2121
- name: Docker container can be run
2222
run: |
23-
./tests/generate_test_repos.sh && \
24-
docker run --rm -t \
25-
-v "$(pwd)":/"$(pwd)" \
26-
-w "$(pwd)" strboul/git-substatus:test \
27-
tests/generated-test-proj-dir
23+
docker run --rm \
24+
-v "$(pwd)/scripts/docker_test_entrypoint.sh:/docker_test_entrypoint.sh" \
25+
--entrypoint "/docker_test_entrypoint.sh" \
26+
strboul/git-substatus:test

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
- name: Get versions
2323
id: versions
2424
run: |
25-
version="$(./get_version.sh __version__)"
26-
py_version="$(./get_version.sh __py_version__)"
25+
version="$(./scripts/get_version.sh __version__)"
26+
py_version="$(./scripts/get_version.sh __py_version__)"
2727
# check the tag ref is the same as package version:
2828
if [ "v${version}" != "$tag_ref" ]; then
2929
echo "::error ::fatal! version not matching with tag"
@@ -59,7 +59,7 @@ jobs:
5959
python -m build --sdist --wheel --outdir dist/
6060
6161
- name: Publish to PyPI
62-
uses: pypa/gh-action-pypi-publish@release/v1.5.1
62+
uses: pypa/gh-action-pypi-publish@release/v1
6363
with:
6464
password: ${{ secrets.PYPI_API_TOKEN }}
6565

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ RUN apk add --update --no-cache --no-progress git
88

99
ARG INSTALL_PATH="/opt/git-substatus/"
1010
RUN mkdir -p "$INSTALL_PATH"
11-
COPY setup.py README.md get_version.sh "$INSTALL_PATH"
11+
COPY setup.py README.md "$INSTALL_PATH"
12+
COPY scripts/ "$INSTALL_PATH"/scripts
1213
COPY git_substatus/ "$INSTALL_PATH"/git_substatus
1314
RUN cd "$INSTALL_PATH" && \
1415
python -m pip install --upgrade pip .

Makefile

+12-8
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ define ask_prompt
1313
endef
1414

1515

16-
VERSION := $(shell ./get_version.sh __version__)
17-
PY_VERSION := $(shell ./get_version.sh __py_version__)
16+
VERSION := $(shell ./scripts/get_version.sh __version__)
17+
PY_VERSION := $(shell ./scripts/get_version.sh __py_version__)
1818

1919

2020
all: typecheck black test install docker-build clean
@@ -33,7 +33,7 @@ coverage: gentest runcoverage clean
3333

3434
gentest:
3535
$(call echo_section,"generate test repos")
36-
./tests/generate_test_repos.sh
36+
./scripts/generate_test_repos.sh
3737

3838

3939
unittest:
@@ -67,11 +67,15 @@ black-apply:
6767

6868
clean:
6969
$(call echo_section,"cleaning")
70-
find . -depth -name __pycache__ -exec rm -rf {} \; && \
71-
find . -depth -name *.pyc -exec rm -rf {} \; && \
72-
find . -depth -name *.mypy_cache -exec rm -rf {} \; && \
73-
find . -depth -name .coverage -exec rm {} \; && \
74-
rm -rf tests/generated-test-proj-dir
70+
# directories
71+
find . -depth -name __pycache__ -exec rm -rf {} \;
72+
find . -depth -name *.pyc -exec rm -rf {} \;
73+
find . -depth -name *.mypy_cache -exec rm -rf {} \;
74+
find . -depth -name *.egg-info -exec rm -rf {} \;
75+
# files
76+
find . -depth -name .coverage -exec rm {} \;
77+
# absolute path files
78+
rm -rf tests/generated-test-proj-dir;
7579

7680

7781
tag-create:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Upon cloning the repo, set up `pre-commit`:
131131
### Add tests
132132

133133
+ Write/update unit tests (if relevant). You can start by adding/modifying a
134-
case to generator file `tests/generate_test_repos.sh`.
134+
case to generator file of `scripts/generate_test_repos.sh`.
135135

136136
### Run tests && debugging
137137

scripts/docker_test_entrypoint.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
wget https://raw.githubusercontent.com/strboul/git-substatus/master/scripts/generate_test_repos.sh &&\
3+
chmod +x generate_test_repos.sh &&\
4+
./generate_test_repos.sh &&\
5+
cd tests/generated-test-proj-dir &&\
6+
git-substatus

tests/generate_test_repos.sh renamed to scripts/generate_test_repos.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
22
# This script creates dummy git repositories, which each of them can represent
33
# a different test case. It is meant to be called from the unit tests but it
44
# can also be called independently.
File renamed without changes.

setup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ def readme():
99

1010

1111
def get_version(variable):
12-
cmd = ["./get_version.sh", variable]
12+
cmd = ["./scripts/get_version.sh", variable]
1313
run = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
1414
return run.stdout.decode("utf-8").strip("\n")
1515

1616

1717
setup(
1818
name="git-substatus",
1919
author="Metin Yazici",
20-
version=get_version("version"),
20+
version=get_version("__version__"),
2121
description="Display the 'git status' in sub-directories",
2222
long_description=readme(),
2323
long_description_content_type="text/markdown",
2424
keywords="git sub status fetch directory folder",
2525
url="https://github.com/strboul/git-substatus",
26-
python_requires=f">={get_version('py_version')}",
26+
python_requires=f">={get_version('__py_version__')}",
2727
license="MIT",
2828
packages=["git_substatus"],
2929
entry_points={
@@ -39,6 +39,6 @@ def get_version(variable):
3939
"Operating System :: MacOS",
4040
"Operating System :: Microsoft :: Windows",
4141
"Operating System :: POSIX :: Linux",
42-
f"Programming Language :: Python :: {get_version('py_version')}+",
42+
f"Programming Language :: Python :: {get_version('__py_version__')}",
4343
],
4444
)

0 commit comments

Comments
 (0)