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

Commit 05a2c5d

Browse files
committed
applying changes for pip based workflow
1 parent fff5058 commit 05a2c5d

File tree

23 files changed

+342
-222
lines changed

23 files changed

+342
-222
lines changed

.github/workflows/code.yml

Lines changed: 116 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,36 @@ jobs:
1919
lint:
2020
runs-on: "ubuntu-latest"
2121
steps:
22-
- name: Run black, flake8, mypy
23-
uses: dls-controls/pipenv-run-action@v1
24-
with:
25-
pipenv-run: lint
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
25+
- name: Lint
26+
run: |
27+
pip install --user .[dev]
28+
tox -e pre-commit,mypy
2629
2730
wheel:
2831
strategy:
2932
fail-fast: false
3033
matrix:
3134
os: ["ubuntu-latest"]
32-
python: ["3.7"]
35+
python: ["3.8"]
3336

3437
runs-on: ${{ matrix.os }}
3538
steps:
3639
- uses: actions/checkout@v2
37-
with:
38-
fetch-depth: 0
3940

4041
- name: Create Sdist and Wheel
4142
# Set SOURCE_DATE_EPOCH from git commit for reproducible build
4243
# https://reproducible-builds.org/
43-
# Set group writable and umask to do the same to match inside DLS
4444
run: |
45-
chmod -R g+w .
46-
umask 0002
4745
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) pipx run build --sdist --wheel
4846
4947
- name: Upload Wheel and Sdist as artifacts
5048
uses: actions/upload-artifact@v2
5149
with:
5250
name: dist
53-
path: dist/*
51+
path: dist
5452

5553
- name: Install minimum python version
5654
uses: actions/setup-python@v2
@@ -67,35 +65,68 @@ jobs:
6765
fail-fast: false
6866
matrix:
6967
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
70-
python: ["3.7", "3.8", "3.9"]
71-
pipenv: ["skip-lock"]
68+
python: ["3.8", "3.9", "3.10"]
69+
lock: [false]
7270

7371
include:
74-
# Add an extra Python3.7 runner to use the lockfile
72+
# Add an extra Python3.10 runner to use the lockfile
7573
- os: "ubuntu-latest"
76-
python: "3.7"
77-
pipenv: "deploy"
74+
python: "3.10"
75+
lock: true
7876

7977
runs-on: ${{ matrix.os }}
8078
env:
8179
# https://github.com/pytest-dev/pytest/issues/2042
8280
PY_IGNORE_IMPORTMISMATCH: "1"
81+
# enable QT tests with no X Display
82+
QT_QPA_PLATFORM: "offscreen"
8383

8484
steps:
85-
- name: Setup repo and test
86-
uses: dls-controls/pipenv-run-action@v1
85+
- name: Checkout
86+
uses: actions/checkout@v2
87+
with:
88+
fetch-depth: 0
89+
90+
- name: Setup python ${{ matrix.python }}
91+
uses: actions/setup-python@v2
8792
with:
8893
python-version: ${{ matrix.python }}
89-
pipenv-install: --dev --${{ matrix.pipenv }}
90-
allow-editable-installs: ${{ matrix.pipenv == 'deploy' }}
91-
pipenv-run: tests
94+
95+
- name: Install with locked dependencies
96+
if: matrix.lock
97+
run: |
98+
touch requirements.txt requirements_dev.txt
99+
pip install -r requirements.txt -e .
100+
pip freeze --exclude-editable > requirements.txt
101+
pip install -r requirements_dev.txt -e .[dev]
102+
pip freeze --exclude-editable > requirements_dev.txt
103+
104+
- name: Install with latest dependencies
105+
if: ${{ ! matrix.lock }}
106+
run: pip install -e .[dev]
107+
108+
- name: Run tests
109+
run: pytest tests
110+
111+
- name: Create requirements_dev.txt
112+
run: |
113+
pip freeze --exclude-editable > requirements_dev.txt
92114
93115
- name: Upload coverage to Codecov
94116
uses: codecov/codecov-action@v2
95117
with:
96-
name: ${{ matrix.python }}/${{ matrix.os }}/${{ matrix.pipenv }}
118+
name: ${{ matrix.python }}/${{ matrix.os }}/${{ matrix.lock }}
97119
files: cov.xml
98120

121+
- name: Upload build files
122+
if: matrix.lock
123+
uses: actions/upload-artifact@v2
124+
with:
125+
name: buildfiles
126+
path: |
127+
requirements.txt
128+
requirements_dev.txt
129+
99130
release:
100131
needs: [lint, wheel, test]
101132
runs-on: ubuntu-latest
@@ -104,15 +135,16 @@ jobs:
104135
steps:
105136
- uses: actions/download-artifact@v2
106137
with:
107-
name: dist
108-
path: dist
138+
path: artifacts
109139

110140
- name: Github Release
111141
# We pin to the SHA, not the tag, for security reasons.
112142
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
113143
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
114144
with:
115-
files: dist/*
145+
files: |
146+
artifacts/dist/*
147+
artifacts/buildfiles/*
116148
generate_release_notes: true
117149
env:
118150
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -121,4 +153,62 @@ jobs:
121153
env:
122154
TWINE_USERNAME: __token__
123155
TWINE_PASSWORD: ${{ secrets.pypi_token }}
124-
run: pipx run twine upload dist/*
156+
run: pipx run twine upload artifacts/dist/*
157+
158+
make-container:
159+
needs: [lint, wheel, test]
160+
runs-on: ubuntu-latest
161+
permissions:
162+
contents: read
163+
packages: write
164+
165+
steps:
166+
- name: Checkout
167+
uses: actions/checkout@v2
168+
169+
- uses: actions/download-artifact@v2
170+
with:
171+
name: dist
172+
path: dist
173+
174+
- name: Cache Docker layers
175+
uses: actions/cache@v2
176+
with:
177+
path: /tmp/.buildx-cache
178+
key: ${{ runner.os }}-buildx-${{ github.sha }}
179+
restore-keys: |
180+
${{ runner.os }}-buildx-
181+
182+
- name: Log in to GitHub Docker Registry
183+
if: github.event_name != 'pull_request'
184+
uses: docker/login-action@v1
185+
with:
186+
registry: ghcr.io
187+
username: ${{ github.actor }}
188+
password: ${{ secrets.GITHUB_TOKEN }}
189+
190+
- name: Docker meta
191+
id: meta
192+
uses: docker/metadata-action@v4
193+
with:
194+
images: ghcr.io/${{ github.repository }}
195+
tags: |
196+
type=ref,event=branch
197+
type=ref,event=tag
198+
type=raw,value=latest
199+
200+
- name: Set up Docker Buildx
201+
id: buildx
202+
uses: docker/setup-buildx-action@v1
203+
204+
- name: Build runtime image
205+
uses: docker/build-push-action@v2
206+
with:
207+
file: .devcontainer/Dockerfile
208+
context: .
209+
push: ${{ github.event_name != 'pull_request' }}
210+
build-args: BASE=python:3.10-slim
211+
tags: ${{ steps.meta.outputs.tags }}
212+
labels: ${{ steps.meta.outputs.labels }}
213+
cache-from: type=local,src=/tmp/.buildx-cache
214+
cache-to: type=local,dest=/tmp/.buildx-cache

.github/workflows/docs.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,47 @@ on:
1212

1313
jobs:
1414
docs:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: ["ubuntu-latest"]
19+
python: ["3.10"]
20+
1521
runs-on: ubuntu-latest
1622

1723
steps:
1824
- name: Avoid git conflicts when tag and branch pushed at same time
1925
if: startsWith(github.ref, 'refs/tags')
2026
run: sleep 60
2127

28+
- name: Install python version
29+
uses: actions/setup-python@v2
30+
with:
31+
python-version: ${{ matrix.python }}
32+
2233
- name: Install Packages
2334
# Can delete this if you don't use graphviz in your docs
2435
run: sudo apt-get install graphviz
2536

26-
- name: Build docs
27-
uses: dls-controls/pipenv-run-action@v1
37+
- name: checkout
38+
uses: actions/checkout@v2
2839
with:
29-
pipenv-run: docs
40+
fetch-depth: 0
41+
42+
- name: Install dependencies
43+
run: |
44+
touch requirements_dev.txt
45+
pip install -r requirements_dev.txt -e .[dev]
46+
47+
- name: Build docs
48+
run: tox -e docs
3049

3150
- name: Move to versioned directory
32-
# e.g. main or 0.1.2
51+
# e.g. master or 0.1.2
3352
run: mv build/html ".github/pages/${GITHUB_REF##*/}"
3453

3554
- name: Write versions.txt
36-
run: pipenv run sphinx_rtd_theme_github_versions .github/pages
55+
run: sphinx_rtd_theme_github_versions .github/pages
3756

3857
- name: Publish Docs to gh-pages
3958
if: github.event_name == 'push'

.github/workflows/linkcheck.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,33 @@ on:
77

88
jobs:
99
docs:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: ["ubuntu-latest"]
14+
python: ["3.10"]
15+
1016
runs-on: ubuntu-latest
1117

1218
steps:
13-
- name: Build docs
14-
uses: dls-controls/pipenv-run-action@v1
19+
- name: Avoid git conflicts when tag and branch pushed at same time
20+
if: startsWith(github.ref, 'refs/tags')
21+
run: sleep 60
22+
23+
- name: Checkout
24+
uses: actions/checkout@v2
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Install python version
29+
uses: actions/setup-python@v2
1530
with:
16-
pipenv-run: docs -b linkcheck
31+
python-version: ${{ matrix.python }}
32+
33+
- name: Install dependencies
34+
run: |
35+
touch requirements_dev.txt
36+
pip install -r requirements_dev.txt -e .[dev]
37+
38+
- name: Check links
39+
run: tox -e docs -- -b linkcheck

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ __pycache__/
88
# Distribution / packaging
99
.Python
1010
env/
11+
.venv
1112
build/
1213
develop-eggs/
1314
dist/
@@ -22,6 +23,7 @@ var/
2223
*.egg-info/
2324
.installed.cfg
2425
*.egg
26+
**/_version.py
2527

2628
# PyInstaller
2729
# Usually these files are written by a python script from a template

.gitremotes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github [email protected]:dls-controls/dls-python3-skeleton.git
1+
github [email protected]:epics-containers/python3-pip-skeleton.git

.pre-commit-config.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,12 @@ repos:
1212
name: Run black
1313
stages: [commit]
1414
language: system
15-
entry: pipenv run black --check --diff
15+
entry: black --check --diff
1616
types: [python]
1717

1818
- id: flake8
1919
name: Run flake8
2020
stages: [commit]
2121
language: system
22-
entry: pipenv run flake8
22+
entry: flake8
2323
types: [python]
24-
25-
- id: mypy
26-
name: Run mypy
27-
stages: [commit]
28-
language: system
29-
entry: pipenv run mypy src tests
30-
pass_filenames: false

0 commit comments

Comments
 (0)