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

Commit f79bb64

Browse files
committed
move requirements.txt gen to container job
1 parent 853c2ef commit f79bb64

File tree

3 files changed

+23
-36
lines changed

3 files changed

+23
-36
lines changed

.github/workflows/code.yml

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
schedule:
77
# Run every Monday at 8am to check latest versions of dependencies
88
- cron: "0 8 * * WED"
9-
env:
10-
# Target python version. Make sure Dockerfile FROM's match this.
11-
PYTHON: "3.10"
129

1310
jobs:
1411
lint:
@@ -20,15 +17,16 @@ jobs:
2017
- name: Checkout
2118
uses: actions/checkout@v3
2219

20+
# use a version of python that does not require setup.py
2321
- name: Setup python
2422
uses: actions/setup-python@v4
2523
with:
26-
python-version: ${{ env.PYTHON }}
24+
python-version: "3.x"
2725

2826
- name: Lint
2927
run: |
30-
touch requirements_dev_py${{ env.PYTHON }}.txt requirements.txt
31-
pip install -r requirements.txt -r requirements_dev_py${{ env.PYTHON }}.txt -e .[dev]
28+
touch requirements_${{ github.job }}.txt requirements.txt
29+
pip install -r requirements.txt -r requirements_${{ github.job }}.txt -e .[dev]
3230
tox -e pre-commit,mypy
3331
3432
test:
@@ -59,7 +57,7 @@ jobs:
5957
run: |
6058
pip install .[dev]
6159
mkdir -p lockfiles
62-
pip freeze > lockfiles/requirements_dev_py${{ matrix.python }}.txt
60+
pip freeze > lockfiles/requirements-test-${{ matrix.python }}-${{ matrix.os }}.txt
6361
6462
- name: Run tests
6563
run: pytest tests
@@ -86,43 +84,26 @@ jobs:
8684
with:
8785
fetch-depth: 0
8886

89-
- name: Setup python
90-
uses: actions/setup-python@v4
91-
with:
92-
python-version: ${{ env.PYTHON }}
93-
9487
- name: Build Sdist and wheel
9588
run: |
9689
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && \
97-
pipx run --python $(which python${{ env.PYTHON }}) build
90+
pipx run build
9891
9992
# ${GITHUB_REPOSITORY##*/} is the repo name without org
10093
# Replace this with the cli command if different to the repo name
10194
- name: Test cli works in sdist installed in local python
102-
run: |
103-
touch requirements.txt
104-
pip install -r requirements.txt dist/*.gz ${GITHUB_REPOSITORY##*/} --version
105-
106-
# create a requirements.txt to be published as a github release asset
107-
- name: get a requirements.txt from the installed sdist
108-
run: |
109-
mkdir -p lockfiles
110-
pip freeze > lockfiles/requirements.txt
95+
run: touch requirements.txt &&
96+
pip install -r requirements.txt dist/*.whl &&
97+
${GITHUB_REPOSITORY##*/} --version
11198

11299
- name: Upload sdist and wheel as artifacts
113100
uses: actions/upload-artifact@v3
114101
with:
115102
name: dist
116103
path: dist
117104

118-
- name: Upload lock files
119-
uses: actions/upload-artifact@v3
120-
with:
121-
name: lockfiles
122-
path: lockfiles
123-
124105
container:
125-
needs: [dist]
106+
needs: [lint, dist, test]
126107
runs-on: ubuntu-latest
127108

128109
permissions:
@@ -132,13 +113,12 @@ jobs:
132113
steps:
133114
- name: Checkout
134115
uses: actions/checkout@v3
135-
with:
136-
fetch-depth: 0
137116

138117
# image names must be all lower case
139118
- run: |
140119
echo IMAGE_REPOSITORY=ghcr.io/$(tr '[:upper:]' '[:lower:]' <<< "${{ github.repository }}") >> $GITHUB_ENV
141120
121+
# obtain the python wheel from the dist step
142122
- uses: actions/download-artifact@v3
143123

144124
- name: Log in to GitHub Docker Registry
@@ -174,11 +154,20 @@ jobs:
174154

175155
- name: Test cli works in runtime image
176156
# check that the latest tag can run with --version parameter
177-
run: docker run ${{ env.IMAGE_REPOSITORY }} --version
157+
run: |
158+
docker run ${{ env.IMAGE_REPOSITORY }} --version
159+
mkdir -p lockfiles
160+
docker run --entrypoint pip ${{ env.IMAGE_REPOSITORY }} freeze > lockfiles/requirements.txt
161+
162+
- name: Upload requirements.txt freeze file
163+
uses: actions/upload-artifact@v3
164+
with:
165+
name: lockfiles
166+
path: lockfiles
178167

179168
release:
180169
# upload to PyPI and make a release on every tag
181-
needs: [lint, dist]
170+
needs: [lint, dist, test]
182171
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
183172
runs-on: ubuntu-latest
184173

.github/workflows/linkcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
pip install -r requirements_dev.txt -e .[dev]
3232
3333
- name: Check links
34-
run: tox -e docs -- -b linkcheck
34+
run: tox -e docs build -- -b linkcheck

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ ENV PATH=/venv/bin:$PATH
2121

2222
# install the wheel
2323
RUN touch requirements.txt && \
24-
for i in requirements.txt .gitignore lockfiles; do echo $i >> .gitignore; done && \
25-
git diff && \
2624
pip install -r requirements.txt dist/*.whl
2725

2826
FROM python:3.10-slim as runtime

0 commit comments

Comments
 (0)