From 4d21bc31ee9a9b8120cb21dfb519c40a48aa3cd8 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Tue, 13 Sep 2022 08:51:26 +0000 Subject: [PATCH 01/20] Run sdist install in container workflow This saves another runner starting up just for this --- .github/workflows/code.yml | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 0aae7fb5..13711d46 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -126,29 +126,20 @@ jobs: context: . labels: ${{ steps.meta.outputs.labels }} - - name: Check runtime + - name: Test cli works in runtime image run: for i in ${{ steps.meta.outputs.tags }}; do docker run ${i} --version; done + - name: Test cli works in sdist installed in local python + # ${GITHUB_REPOSITORY##*/} is the repo name without org + # Replace this with the cli command if different to the repo name + run: pip install dist/*.gz && ${GITHUB_REPOSITORY##*/} --version + - name: Upload build files uses: actions/upload-artifact@v3 with: name: dist path: dist - sdist: - needs: container - runs-on: ubuntu-latest - - steps: - - uses: actions/download-artifact@v3 - - - name: Install sdist in a venv and check cli works - # ${GITHUB_REPOSITORY##*/} is the repo name without org - # Replace this with the cli command if different to the repo name - run: | - pip install dist/*.gz - ${GITHUB_REPOSITORY##*/} --version - release: # upload to PyPI and make a release on every tag if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') From 52038569d52a5471e90f21b0d5ab5d685a18d19c Mon Sep 17 00:00:00 2001 From: Gary Yendell Date: Tue, 13 Sep 2022 09:44:58 +0100 Subject: [PATCH 02/20] Update CI badges --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 0450bd2b..a014631e 100644 --- a/README.rst +++ b/README.rst @@ -33,12 +33,12 @@ Or if it is a commandline tool then you might put some example commands here:: $ python -m python3_pip_skeleton --version -.. |code_ci| image:: https://github.com/DiamondLightSource/python3-pip-skeleton/workflows/Code%20CI/badge.svg?branch=main - :target: https://github.com/DiamondLightSource/python3-pip-skeleton/actions?query=workflow%3A%22Code+CI%22 +.. |code_ci| image:: https://github.com/DiamondLightSource/python3-pip-skeleton/actions/workflows/code.yml/badge.svg?branch=main + :target: https://github.com/DiamondLightSource/python3-pip-skeleton/actions/workflows/code.yml :alt: Code CI -.. |docs_ci| image:: https://github.com/DiamondLightSource/python3-pip-skeleton/workflows/Docs%20CI/badge.svg?branch=main - :target: https://github.com/DiamondLightSource/python3-pip-skeleton/actions?query=workflow%3A%22Docs+CI%22 +.. |docs_ci| image:: https://github.com/DiamondLightSource/python3-pip-skeleton/actions/workflows/docs.yml/badge.svg?branch=main + :target: https://github.com/DiamondLightSource/python3-pip-skeleton/actions/workflows/docs.yml :alt: Docs CI .. |coverage| image:: https://codecov.io/gh/DiamondLightSource/python3-pip-skeleton/branch/main/graph/badge.svg From d96f15a97efae989aabac10b5f815bd1e3ea143c Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Mon, 3 Oct 2022 21:12:20 +0100 Subject: [PATCH 03/20] Update code.yml Fixing a bug that occurs when releasing. (This is already fixed in the skeleton-cli project but failed to get copied to skeleton). --- .github/workflows/code.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 13711d46..89960f22 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -127,7 +127,8 @@ jobs: labels: ${{ steps.meta.outputs.labels }} - name: Test cli works in runtime image - run: for i in ${{ steps.meta.outputs.tags }}; do docker run ${i} --version; done + # check that the first tag can run with --version parameter + run: docker run $(echo ${{ steps.meta.outputs.tags }} | sed -e 's/\s.*$//') --version - name: Test cli works in sdist installed in local python # ${GITHUB_REPOSITORY##*/} is the repo name without org From 68976f406d9c74bc2674897be2cefbd49dbaeba4 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 4 Oct 2022 11:03:29 +0100 Subject: [PATCH 04/20] Update .github/workflows/code.yml Co-authored-by: Tom C (DLS) <101418278+coretl@users.noreply.github.com> --- .github/workflows/code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 89960f22..19773839 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -128,7 +128,7 @@ jobs: - name: Test cli works in runtime image # check that the first tag can run with --version parameter - run: docker run $(echo ${{ steps.meta.outputs.tags }} | sed -e 's/\s.*$//') --version + run: docker run $(echo ${{ steps.meta.outputs.tags }} | head -1) --version - name: Test cli works in sdist installed in local python # ${GITHUB_REPOSITORY##*/} is the repo name without org From 92f10b4dfd56e314255147a989c0103b910f7291 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Fri, 14 Oct 2022 13:52:05 +0100 Subject: [PATCH 05/20] Fix make version switcher to use the right key Pin pydata-sphinx-theme to allow the build to complete https://github.com/pydata/pydata-sphinx-theme/issues/987 --- .github/pages/make_switcher.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/pages/make_switcher.py b/.github/pages/make_switcher.py index 5c65d788..39c12772 100755 --- a/.github/pages/make_switcher.py +++ b/.github/pages/make_switcher.py @@ -59,7 +59,7 @@ def get_versions(ref: str, add: Optional[str], remove: Optional[str]) -> List[st def write_json(path: Path, repository: str, versions: str): org, repo_name = repository.split("/") struct = [ - dict(name=version, url=f"https://{org}.github.io/{repo_name}/{version}/") + dict(version=version, url=f"https://{org}.github.io/{repo_name}/{version}/") for version in versions ] text = json.dumps(struct, indent=2) diff --git a/setup.cfg b/setup.cfg index 3daa1c9b..857492eb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,7 @@ dev = mypy pipdeptree pre-commit - pydata-sphinx-theme + pydata-sphinx-theme < 0.10.1 pytest-cov setuptools_scm[toml]>=6.2 sphinx-copybutton From d35ffdbd28a1cba3fda62503151bcd1da82efbd4 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Fri, 14 Oct 2022 13:54:50 +0100 Subject: [PATCH 06/20] Add sphinx autobuild --- docs/conf.py | 1 - docs/developer/how-to/build-docs.rst | 18 ++++++++++++++++++ setup.cfg | 5 +++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 0b6dd5bb..c4c2126a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,7 +24,6 @@ git_branch = check_output("git branch --show-current".split(), cwd=root) version = git_branch.decode().strip() else: - branch = "main" version = release extensions = [ diff --git a/docs/developer/how-to/build-docs.rst b/docs/developer/how-to/build-docs.rst index 9540de1c..79e3f780 100644 --- a/docs/developer/how-to/build-docs.rst +++ b/docs/developer/how-to/build-docs.rst @@ -17,4 +17,22 @@ locally with a web browse:: $ firefox build/html/index.html +Autobuild +--------- + +You can also run an autobuild process, which will watch your ``docs`` +directory for changes and rebuild whenever it sees changes, reloading any +browsers watching the pages:: + + $ tox -e docs autobuild + +You can view the pages at localhost:: + + $ firefox http://localhost:8000 + +If you are making changes to source code too, you can tell it to watch +changes in this directory too:: + + $ tox -e docs autobuild -- --watch src + .. _sphinx: https://www.sphinx-doc.org/ \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 857492eb..2e9dacb8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,6 +41,7 @@ dev = pydata-sphinx-theme < 0.10.1 pytest-cov setuptools_scm[toml]>=6.2 + sphinx-autobuild sphinx-copybutton sphinx-design tox @@ -122,5 +123,5 @@ allowlist_externals = pre-commit commands = pre-commit run --all-files {posargs} [testenv:docs] -allowlist_externals = sphinx-build -commands = sphinx-build -EWT --keep-going docs build/html {posargs} +allowlist_externals = sphinx-build sphinx-autobuild +commands = sphinx-{posargs:build -EW --keep-going} -T docs build/html From 7c11165980fe4ccc9260538c9490dfe0cdfe40b1 Mon Sep 17 00:00:00 2001 From: Garry O'Donnell Date: Wed, 5 Oct 2022 15:21:53 +0100 Subject: [PATCH 07/20] Use PyPA action for PyPI Publish Use the official Python Packaging Authority (PyPA) Action to publish to PyPI --- .github/workflows/code.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 19773839..93dd6e37 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -162,7 +162,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish to PyPI - env: - TWINE_USERNAME: __token__ + uses: pypa/gh-action-pypi-publish@release/v1 + with: TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: pipx run twine upload dist/*.whl dist/*.tar.gz From 1acb1d47463edeec386cdd82a549e652c57f9b46 Mon Sep 17 00:00:00 2001 From: Garry O'Donnell Date: Wed, 5 Oct 2022 15:27:44 +0100 Subject: [PATCH 08/20] Fix password parameter --- .github/workflows/code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 93dd6e37..690bb7cd 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -164,4 +164,4 @@ jobs: - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + password: ${{ secrets.PYPI_TOKEN }} From 5ff0a302f73174dec5eed0942ef1abd369264b5f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Oct 2022 17:00:48 +0000 Subject: [PATCH 09/20] Bump black from 22.8.0 to 22.10.0 Bumps [black](https://github.com/psf/black) from 22.8.0 to 22.10.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/22.8.0...22.10.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 2e9dacb8..bd277c9a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,7 +32,7 @@ setup_requires = [options.extras_require] # For development tests/docs dev = - black==22.8.0 + black==22.10.0 flake8-isort isort>5.0 mypy From 323424fb1d9d037e029ae45920770f656b2e991a Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Fri, 14 Oct 2022 15:31:24 +0100 Subject: [PATCH 10/20] Sanitize ref name for docs version Translate punctuation and unicode in branch names to _ --- .github/workflows/docs.yml | 8 +++++--- .github/workflows/docs_clean.yml | 13 ++++++++----- setup.cfg | 4 +++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a684d031..f0e7ebb6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -41,12 +41,14 @@ jobs: - name: Build docs run: tox -e docs + - name: Sanitize ref name for docs version + run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV + - name: Move to versioned directory - # e.g. main or 0.1.2 - run: mv build/html ".github/pages/${{ github.ref_name }}" + run: mv build/html .github/pages/$DOCS_VERSION - name: Write switcher.json - run: python .github/pages/make_switcher.py --add "${{ github.ref_name }}" ${{ github.repository }} .github/pages/switcher.json + run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json - name: Publish Docs to gh-pages if: github.event_name == 'push' diff --git a/.github/workflows/docs_clean.yml b/.github/workflows/docs_clean.yml index b80e4c22..d5425e42 100644 --- a/.github/workflows/docs_clean.yml +++ b/.github/workflows/docs_clean.yml @@ -24,17 +24,20 @@ jobs: - name: removing documentation for branch ${{ github.event.ref }} if: ${{ github.event_name != 'workflow_dispatch' }} - run: echo "remove_me=${{ github.event.ref }}" >> $GITHUB_ENV + run: echo "REF_NAME=${{ github.event.ref }}" >> $GITHUB_ENV - name: manually removing documentation version ${{ github.event.inputs.version }} if: ${{ github.event_name == 'workflow_dispatch' }} - run: echo "remove_me=${{ github.event.inputs.version }}" >> $GITHUB_ENV + run: echo "REF_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV + + - name: Sanitize ref name for docs version + run: echo "DOCS_VERSION=${REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV - name: update index and push changes run: | - rm -r ${{ env.remove_me }} - python make_switcher.py --remove ${{ env.remove_me }} ${{ github.repository }} switcher.json + rm -r ${{ env.DOCS_VERSION }} + python make_switcher.py --remove $DOCS_VERSION ${{ github.repository }} switcher.json git config --global user.name 'GitHub Actions Docs Cleanup CI' git config --global user.email 'GithubActionsCleanup@noreply.github.com' - git commit -am"removing redundant docs version ${{ env.remove_me }}" + git commit -am "Removing redundant docs version $DOCS_VERSION" git push diff --git a/setup.cfg b/setup.cfg index bd277c9a..87c5b596 100644 --- a/setup.cfg +++ b/setup.cfg @@ -123,5 +123,7 @@ allowlist_externals = pre-commit commands = pre-commit run --all-files {posargs} [testenv:docs] -allowlist_externals = sphinx-build sphinx-autobuild +allowlist_externals = + sphinx-build + sphinx-autobuild commands = sphinx-{posargs:build -EW --keep-going} -T docs build/html From 10e80ea71c78f8391f89ccc55efc07039e1e1961 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 18 Oct 2022 08:43:27 +0100 Subject: [PATCH 11/20] 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 c38a25e0296e135bee4db82a5a62837e67ea8a37 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 18 Oct 2022 12:22:16 +0100 Subject: [PATCH 12/20] fix .dockerignore, build options --- .dockerignore | 2 -- Dockerfile | 2 +- 2 files changed, 1 insertion(+), 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/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 59cd0f60925bb4466fe322c24d8e0e8e716dfb18 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 18 Oct 2022 12:47:50 +0100 Subject: [PATCH 13/20] dont let lockfiles dirty the version --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e0fba46a..ce564f2f 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,7 @@ target/ .venv* venv* +# further build artifacts +lockfiles/ + From 7b0423d013d9bfe7aec128400730cfe9776463b5 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 18 Oct 2022 12:22:16 +0100 Subject: [PATCH 14/20] 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 0e9c7e18939753d02b56d40f8c43973e9a6c3d5a Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 1 Nov 2022 08:25:50 +0000 Subject: [PATCH 15/20] 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 aab985f6c24b106ffa6f096d42efa5edb8fc59c1 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 1 Nov 2022 08:34:20 +0000 Subject: [PATCH 16/20] 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 From 964446a43cda17b235a5577dc586d89c0054f9af Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 18 Oct 2022 08:43:27 +0100 Subject: [PATCH 17/20] 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 18/20] 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 19/20] 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 20/20] 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