Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit b3109d7

Browse files
authored
Merge pull request #19 from epics-containers/dev
Further code review changes
2 parents 832ae77 + 6948faa commit b3109d7

File tree

11 files changed

+53
-29
lines changed

11 files changed

+53
-29
lines changed

.github/workflows/code.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ jobs:
115115
run: |
116116
docker run --name test build bash /project/.github/workflows/container_tests.sh
117117
docker cp test:/project/dist .
118-
docker cp test:/project/requirements.txt .
119-
docker cp test:/project/requirements_dev.txt .
120118
docker cp test:/project/cov.xml .
121119
122120
- name: Upload coverage to Codecov
@@ -140,11 +138,8 @@ jobs:
140138
- name: Upload build files
141139
uses: actions/upload-artifact@v3
142140
with:
143-
name: build_files
144-
path: |
145-
dist
146-
requirements.txt
147-
requirements_dev.txt
141+
name: dist
142+
path: dist/*
148143

149144
sdist:
150145
needs: container
@@ -158,7 +153,7 @@ jobs:
158153
# Replace this with the cli command if different to the repo name
159154
# (In the python3-pip-skeleton-cli this is already renamed)
160155
run: |
161-
pip install build_files/dist/*.gz
156+
pip install dist/*.gz
162157
python3-pip-skeleton --version
163158
164159
release:
@@ -176,14 +171,13 @@ jobs:
176171
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
177172
with:
178173
files: |
179-
build_files/*
180-
build_files/dist/*
174+
dist/*
181175
generate_release_notes: true
182176
env:
183177
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184178

185179
- name: Publish to PyPI
186180
env:
187181
TWINE_USERNAME: __token__
188-
TWINE_PASSWORD: ${{ secrets.pypi_token }}
189-
run: pipx run twine upload build_files/dist/*
182+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
183+
run: pipx run twine upload dist/*/whl dist/*.tar.gz

.github/workflows/container_tests.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
set -x
33

44
cd /project
5-
6-
python -m venv /tmp/venv
7-
source /tmp/venv/bin/activate
5+
source /venv/bin/activate
86

97
touch requirements_dev.txt
108
pip install -r requirements_dev.txt -e .[dev]
11-
pip freeze --exclude-editable > requirements_dev.txt
9+
pip freeze --exclude-editable > dist/requirements_dev.txt
1210

1311
pipdeptree
1412

15-
# ensure non-zero length requirements.txt
16-
echo "# runtime dependencies" >> requirements.txt
17-
1813
git config --global user.email "[email protected]"
1914
git config --global user.name "Your Name"
2015

.github/workflows/docs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
os: ["ubuntu-latest"]
1312
python: ["3.10"]
1413

1514
runs-on: ubuntu-latest

.github/workflows/linkcheck.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
os: ["ubuntu-latest"]
1413
python: ["3.10"]
1514

1615
runs-on: ubuntu-latest

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ ENV PATH=/venv/bin:$PATH
3030
RUN cd /project && \
3131
pip install --upgrade pip && \
3232
pip install -r requirements.txt dist/*.whl && \
33-
pip freeze > requirements.txt && \
33+
pip freeze > dist/requirements.txt && \
3434
# we don't want to include our own wheel in requirements - remove with sed
35-
sed -i '/file:\/\//d' requirements.txt
35+
# and replace with a comment to avoid a zero length asset upload later
36+
sed -i '/file:/s/^/# Requirements for /' dist/requirements.txt
3637

3738
FROM python:3.10-slim as runtime
3839

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ It integrates the following tools:
1919

2020
- pip and setuptools_scm for version management
2121
- Pre-commit with black, flake8 and isort for static analysis
22-
- Pytest for tests and code [email protected]:dls-controls/python3-pip-skeleton.gitcoverage
22+
- Pytest for code and coverage
2323
- Sphinx for tutorials, how-to guides, explanations and reference documentation
2424
- GitHub Actions for code and docs CI and deployment to PyPI and GitHub Pages
2525
- tox -p: runs pre-commit, pytest, mypy and make docs

docs/how-to.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Practical step-by-step guides for the more experienced user.
1212
how-to/existing
1313
how-to/update
1414
how-to/excalidraw
15+
how-to/pypi

docs/how-to/existing.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ How to adopt the skeleton in an existing repo
44
If you have an existing repo and would like to adopt the skeleton structure
55
then you can use the commandline tool to merge the skeleton into your repo::
66

7-
python3-pip-skeleton existing /path/to/existing/repo
7+
python3-pip-skeleton existing /path/to/existing/repo --org my_github_user_or_org
88

99
This will:
1010

@@ -16,6 +16,9 @@ This will:
1616
- Push that merge branch back to the existing repo
1717
- Merge with the currently checked out branch, leaving you to fix the conflicts
1818

19+
.. note::
20+
21+
To enable publishing to PyPI see `../how-to/pypi`
1922

2023
Example merge
2124
-------------

docs/how-to/pypi.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Creating a PyPI Token
2+
=====================
3+
4+
To publish your package on PyPI requires a PyPI account and for GitHub Actions
5+
to have a PyPI token authorizing access to that account.
6+
7+
The simplest approach is to set up a PyPI token that is scoped to your PyPI account
8+
and add it to the secrets for your GitHub Organization (or user). This means
9+
that all new projects created in the Organization will automatically gain
10+
permission to publish to PyPI.
11+
12+
Alternatively you can create a project scoped token for each project. This
13+
is more work but more secure as a bad actor that obtains the key can only
14+
affect a single project.
15+
16+
If you do not already have a PyPI account use this link: create_account_.
17+
18+
To learn how to create a token and store it in Github see: adding_a_token_.
19+
You can ignore the other sections of the page regarding Github Actions because
20+
these are already provided by skeleton. Note that skeleton uses ``PYPI_TOKEN``
21+
as the secret name instead of ``PYPI_API_TOKEN`` described in the link.
22+
23+
24+
.. _create_account: https://pypi.org/account/register/
25+
.. _adding_a_token: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#saving-credentials-on-github

docs/tutorials/new.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ You can then run any entry points declared in setup.cfg e.g.::
3131
will run the python interpreter with access to all the packages you need to
3232
develop your repo.
3333

34+
PyPI Token
35+
----------
36+
37+
The Github Actions Continuous Integration will publish your package to PyPI.
38+
To do so you need a PyPI account and and a PyPI Token configured in your
39+
project or github Organization.
40+
41+
see `../how-to/pypi`
42+
3443
Running the tests
3544
-----------------
3645

0 commit comments

Comments
 (0)