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

Commit de6d5f1

Browse files
coretlgilesknap
authored andcommitted
Squash all into new skeleton base commit
1 parent ededf00 commit de6d5f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+667
-480
lines changed

.containerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dockerfile
2+
build/
3+
dist/
4+
.mypy_cache
5+
.tox
6+
.venv*
7+
venv*

.devcontainer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// For format details, see https://aka.ms/devcontainer.json
2+
{
3+
"name": "Python 3 Developer Container",
4+
"build": {
5+
"dockerfile": "Dockerfile",
6+
"target": "build",
7+
"context": ".",
8+
"args": {}
9+
},
10+
"remoteEnv": {
11+
"DISPLAY": "${localEnv:DISPLAY}"
12+
},
13+
// Set *default* container specific settings.json values on container create.
14+
"settings": {
15+
"python.defaultInterpreterPath": "/venv/bin/python",
16+
"python.linting.enabled": true
17+
},
18+
// Add the IDs of extensions you want installed when the container is created.
19+
"extensions": [
20+
"ms-python.python",
21+
"ms-python.vscode-pylance"
22+
],
23+
// Make sure the files we are mapping into the container exist on the host
24+
"initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
25+
"runArgs": [
26+
"--net=host",
27+
"-v=${localEnv:HOME}/.ssh:/root/.ssh",
28+
"-v=${localEnv:HOME}/.inputrc:/root/.inputrc"
29+
],
30+
"mounts": [
31+
// map in home directory - not strictly necessary but useful
32+
"source=${localEnv:HOME},target=${localEnv:HOME},type=bind,consistency=cached"
33+
],
34+
// make the workspace folder the same inside and outside of the container
35+
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
36+
"workspaceFolder": "${localWorkspaceFolder}",
37+
// After the container is created, install the python project in editable form
38+
"postCreateCommand": "pip install $([ -f requirements_dev.txt ] && echo -r requirements_dev.txt ) -e .[dev]"
39+
}

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
13+
- package-ecosystem: "pip"
14+
directory: "/"
15+
schedule:
16+
interval: "weekly"

.github/pages/index.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<title>Redirecting to master branch</title>
3+
4+
<head>
5+
<title>Redirecting to main branch</title>
56
<meta charset="utf-8">
6-
<meta http-equiv="refresh" content="0; url=./master/index.html">
7-
<link rel="canonical" href="master/index.html">
8-
</head>
9-
</html>
7+
<meta http-equiv="refresh" content="0; url=./main/index.html">
8+
<link rel="canonical" href="main/index.html">
9+
</head>
10+
11+
</html>

.github/workflows/code.yml

Lines changed: 127 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,111 +2,176 @@ name: Code CI
22

33
on:
44
push:
5-
branches:
6-
# Restricting to these branches and tags stops duplicate jobs on internal
7-
# PRs but stops CI running on internal branches without a PR. Delete the
8-
# next 5 lines to restore the original behaviour
9-
- master
10-
- main
11-
tags:
12-
- "*"
135
pull_request:
146
schedule:
157
# Run every Monday at 8am to check latest versions of dependencies
16-
- cron: '0 8 * * MON'
8+
- cron: "0 8 * * WED"
179

1810
jobs:
1911
lint:
20-
runs-on: "ubuntu-latest"
21-
steps:
22-
- name: Run black, flake8, mypy
23-
uses: dls-controls/pipenv-run-action@v1
24-
with:
25-
pipenv-run: lint
12+
# pull requests are a duplicate of a branch push if within the same repo.
13+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
14+
runs-on: ubuntu-latest
2615

27-
wheel:
28-
runs-on: "ubuntu-latest"
2916
steps:
30-
- uses: actions/checkout@v2
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Setup python
21+
uses: actions/setup-python@v4
3122
with:
32-
fetch-depth: 0
23+
python-version: "3.10"
3324

34-
- name: Create Sdist and Wheel
35-
# Set SOURCE_DATE_EPOCH from git commit for reproducible build
36-
# https://reproducible-builds.org/
37-
# Set group writable and umask to do the same to match inside DLS
25+
- name: Lint
3826
run: |
39-
chmod -R g+w .
40-
umask 0002
41-
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) pipx run build --sdist --wheel
42-
43-
- name: Test cli works from the installed wheel
44-
# Can remove the repository reference after https://github.com/pypa/pipx/pull/733
45-
run: pipx run --spec dist/*.whl ${GITHUB_REPOSITORY##*/} --version
46-
47-
- name: Upload Wheel and Sdist as artifacts
48-
uses: actions/upload-artifact@v2
49-
with:
50-
name: dist
51-
path: dist/*
27+
touch requirements_dev.txt requirements.txt
28+
pip install -r requirements.txt -r requirements_dev.txt -e .[dev]
29+
tox -e pre-commit,mypy
5230
5331
test:
32+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
5433
strategy:
5534
fail-fast: false
5635
matrix:
57-
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
58-
python: ["3.7", "3.8", "3.9"]
59-
pipenv: ["skip-lock"]
60-
61-
include:
62-
# Add an extra Python3.7 runner to use the lockfile
63-
- os: "ubuntu-latest"
64-
python: "3.7"
65-
pipenv: "deploy"
36+
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
37+
python: ["3.8", "3.9", "3.10"]
6638

6739
runs-on: ${{ matrix.os }}
6840
env:
6941
# https://github.com/pytest-dev/pytest/issues/2042
7042
PY_IGNORE_IMPORTMISMATCH: "1"
7143

7244
steps:
73-
- name: Setup repo and test
74-
uses: dls-controls/pipenv-run-action@v1
45+
- name: Checkout
46+
uses: actions/checkout@v2
47+
with:
48+
fetch-depth: 0
49+
50+
- name: Setup python ${{ matrix.python }}
51+
uses: actions/setup-python@v4
7552
with:
7653
python-version: ${{ matrix.python }}
77-
pipenv-install: --dev --${{ matrix.pipenv }}
78-
allow-editable-installs: ${{ matrix.pipenv == 'deploy' }}
79-
pipenv-run: tests
54+
55+
- name: Install with latest dependencies
56+
run: pip install .[dev]
57+
58+
- name: Run tests
59+
run: pytest tests
8060

8161
- name: Upload coverage to Codecov
82-
uses: codecov/codecov-action@v2
62+
uses: codecov/codecov-action@v3
8363
with:
84-
name: ${{ matrix.python }}/${{ matrix.os }}/${{ matrix.pipenv }}
64+
name: ${{ matrix.python }}/${{ matrix.os }}
8565
files: cov.xml
8666

87-
release:
88-
needs: [lint, wheel, test]
67+
container:
68+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
8969
runs-on: ubuntu-latest
90-
# upload to PyPI and make a release on every tag
91-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
70+
permissions:
71+
contents: read
72+
packages: write
73+
9274
steps:
93-
- uses: actions/download-artifact@v2
75+
- name: Checkout
76+
uses: actions/checkout@v2
77+
with:
78+
fetch-depth: 0
79+
80+
- name: Log in to GitHub Docker Registry
81+
if: github.event_name != 'pull_request'
82+
uses: docker/login-action@v2
83+
with:
84+
registry: ghcr.io
85+
username: ${{ github.actor }}
86+
password: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Docker meta
89+
id: meta
90+
uses: docker/metadata-action@v4
91+
with:
92+
images: ghcr.io/${{ github.repository }}
93+
tags: |
94+
type=ref,event=branch
95+
type=ref,event=tag
96+
97+
- name: Set up Docker Buildx
98+
id: buildx
99+
uses: docker/setup-buildx-action@v2
100+
101+
- name: Build developer image for testing
102+
uses: docker/build-push-action@v3
103+
with:
104+
tags: build:latest
105+
context: .
106+
target: build
107+
load: true
108+
109+
- name: Run tests in the container locked with requirements_dev.txt
110+
run: |
111+
docker run --name test build bash /project/.github/workflows/container_tests.sh
112+
docker cp test:/project/dist .
113+
docker cp test:/project/cov.xml .
114+
115+
- name: Upload coverage to Codecov
116+
uses: codecov/codecov-action@v3
117+
with:
118+
name: 3.10-locked/ubuntu-latest
119+
files: cov.xml
120+
121+
- name: Build runtime image
122+
uses: docker/build-push-action@v3
123+
with:
124+
push: ${{ github.event_name != 'pull_request' }}
125+
tags: ${{ steps.meta.outputs.tags }}
126+
context: .
127+
labels: ${{ steps.meta.outputs.labels }}
128+
129+
- name: Check runtime
130+
run: for i in ${{ steps.meta.outputs.tags }}; do docker run ${i} --version; done
131+
132+
- name: Upload build files
133+
uses: actions/upload-artifact@v3
94134
with:
95135
name: dist
96-
path: dist
136+
path: dist/*
137+
138+
sdist:
139+
needs: container
140+
runs-on: ubuntu-latest
141+
142+
steps:
143+
- uses: actions/download-artifact@v3
144+
145+
- name: Install sdist in a venv and check cli works
146+
# ${GITHUB_REPOSITORY##*/} is the repo name without org
147+
# Replace this with the cli command if different to the repo name
148+
run: |
149+
pip install dist/*.gz
150+
${GITHUB_REPOSITORY##*/} --version
151+
152+
release:
153+
# upload to PyPI and make a release on every tag
154+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
155+
needs: container
156+
runs-on: ubuntu-latest
157+
158+
steps:
159+
- uses: actions/download-artifact@v3
97160

98161
- name: Github Release
99162
# We pin to the SHA, not the tag, for security reasons.
100163
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
101-
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
164+
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
102165
with:
103-
files: dist/*
166+
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
167+
files: |
168+
dist/*
104169
generate_release_notes: true
105170
env:
106171
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107172

108173
- name: Publish to PyPI
109174
env:
110175
TWINE_USERNAME: __token__
111-
TWINE_PASSWORD: ${{ secrets.pypi_token }}
112-
run: pipx run twine upload dist/*
176+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
177+
run: pipx run twine upload dist/*/whl dist/*.tar.gz
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -x
3+
4+
cd /project
5+
source /venv/bin/activate
6+
7+
touch requirements_dev.txt
8+
pip install -r requirements_dev.txt -e .[dev]
9+
pip freeze --exclude-editable > dist/requirements_dev.txt
10+
11+
pipdeptree
12+
13+
pytest tests

0 commit comments

Comments
 (0)