From 964446a43cda17b235a5577dc586d89c0054f9af Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 18 Oct 2022 08:43:27 +0100 Subject: [PATCH 1/4] move requirements assests to lockfiles zip --- .containerignore | 7 ------- .dockerignore | 10 ++++++++++ .github/workflows/code.yml | 11 ++++++++++- .github/workflows/container_tests.sh | 3 ++- Dockerfile | 16 ++++++++++------ 5 files changed, 32 insertions(+), 15 deletions(-) delete mode 100644 .containerignore create mode 100644 .dockerignore diff --git a/.containerignore b/.containerignore deleted file mode 100644 index eb7d5ae1..00000000 --- a/.containerignore +++ /dev/null @@ -1,7 +0,0 @@ -Dockerfile -build/ -dist/ -.mypy_cache -.tox -.venv* -venv* diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..4fb4c9ef --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +build/ +dist/ +.mypy_cache +.tox +.venv* +venv* +.devcontainer.json +.pre-commit-config.yaml +.vscode +README.rst diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 690bb7cd..d6322890 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -110,6 +110,7 @@ jobs: run: | docker run --name test build bash /project/.github/workflows/container_tests.sh docker cp test:/project/dist . + docker cp test:/project/lockfiles . docker cp test:/project/cov.xml . - name: Upload coverage to Codecov @@ -141,6 +142,12 @@ jobs: name: dist path: dist + - name: Upload lock files + uses: actions/upload-artifact@v3 + with: + name: lockfiles + path: lockfiles + release: # upload to PyPI and make a release on every tag if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') @@ -156,7 +163,9 @@ jobs: uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14 with: prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }} - files: dist/* + files: | + dist/ + lockfiles/ generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/container_tests.sh b/.github/workflows/container_tests.sh index 5f921597..c36bbd9a 100644 --- a/.github/workflows/container_tests.sh +++ b/.github/workflows/container_tests.sh @@ -6,7 +6,8 @@ source /venv/bin/activate touch requirements_dev.txt pip install -r requirements_dev.txt -e .[dev] -pip freeze --exclude-editable > dist/requirements_dev.txt +mkdir -p lockfiles +pip freeze --exclude-editable > lockfiles/requirements_dev.txt pipdeptree diff --git a/Dockerfile b/Dockerfile index b8bfe727..5e04e438 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,29 +17,33 @@ RUN apt-get update && apt-get upgrade -y && \ && busybox --install COPY . /project +WORKDIR /project -RUN cd /project && \ - pip install --upgrade pip build && \ +# make the wheel outside of the venv so 'build' does not dirty requirements.txt +RUN pip install --upgrade pip build && \ export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && \ python -m build --sdist --wheel && \ touch requirements.txt +# set up a virtual environment and put it in PATH RUN python -m venv /venv ENV PATH=/venv/bin:$PATH ENV TOX_DIRECT=1 -RUN cd /project && \ - pip install --upgrade pip && \ +# install the wheel and generate the requirements file +RUN pip install --upgrade pip && \ pip install -r requirements.txt dist/*.whl && \ - pip freeze > dist/requirements.txt && \ + mkdir -p lockfiles && \ + pip freeze > lockfiles/requirements.txt && \ # we don't want to include our own wheel in requirements - remove with sed # and replace with a comment to avoid a zero length asset upload later - sed -i '/file:/s/^/# Requirements for /' dist/requirements.txt + sed -i '/file:/s/^/# Requirements for /' lockfiles/requirements.txt FROM python:3.10-slim as runtime # Add apt-get system dependecies for runtime here if needed +# copy the virtual environment from the build stage and put it in PATH COPY --from=build /venv/ /venv/ ENV PATH=/venv/bin:$PATH From b0426cef26f36c5cc379af879a8a40e1c558721f Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 18 Oct 2022 12:22:16 +0100 Subject: [PATCH 2/4] fix .dockerignore, build options --- .dockerignore | 2 -- .gitignore | 2 ++ Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 4fb4c9ef..e2ed7105 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,7 +4,5 @@ dist/ .tox .venv* venv* -.devcontainer.json .pre-commit-config.yaml .vscode -README.rst diff --git a/.gitignore b/.gitignore index e0fba46a..9fbb6bfe 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,6 @@ target/ .venv* venv* +# further build artifacts +lockfiles/ diff --git a/Dockerfile b/Dockerfile index 5e04e438..55020416 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ WORKDIR /project # make the wheel outside of the venv so 'build' does not dirty requirements.txt RUN pip install --upgrade pip build && \ export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && \ - python -m build --sdist --wheel && \ + python -m build && \ touch requirements.txt # set up a virtual environment and put it in PATH From a8d55dd788dc3b7ed7eba0278683475604d1d2d3 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 1 Nov 2022 08:25:50 +0000 Subject: [PATCH 3/4] add check for dirty repo when building wheel --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 55020416..c96bee05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,7 @@ WORKDIR /project # make the wheel outside of the venv so 'build' does not dirty requirements.txt RUN pip install --upgrade pip build && \ export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && \ + git diff && \ python -m build && \ touch requirements.txt From 081e205c8530f819115e9d8a99be7c3b4d112c45 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 1 Nov 2022 08:34:20 +0000 Subject: [PATCH 4/4] fix dockerignore to not dirty repo --- .dockerignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index e2ed7105..a6fab0ea 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,5 +4,3 @@ dist/ .tox .venv* venv* -.pre-commit-config.yaml -.vscode