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

Commit 5fa4798

Browse files
garryodgilesknap
authored andcommitted
Code Review Changes
Added the remote containers extension (`ms-vscode-remote.remote-containers`) to the recommended extensions json for VSCode Bump actions/setup-python from 2 to 4 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v2...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Updates from code review. updates from review system python for lint better release files final review changes add test of runtime container make docs CI always run improve container_tests simplifying CI fix broken links adding docs delete action adding docs delete action fix remote repo action firing fix remote repo action firing
1 parent cdc93da commit 5fa4798

26 files changed

+172
-123
lines changed

.containerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist/
44
.mypy_cache
55
.tox
66
.venv*
7+
venv*

.devcontainer.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
// Set *default* container specific settings.json values on container create.
1414
"settings": {
15-
"python.defaultInterpreterPath": "/usr/local/bin/python",
15+
"python.defaultInterpreterPath": "/venv/bin/python",
1616
"python.linting.enabled": true
1717
},
1818
// Add the IDs of extensions you want installed when the container is created.
@@ -21,12 +21,10 @@
2121
"ms-python.vscode-pylance"
2222
],
2323
// Make sure the files we are mapping into the container exist on the host
24-
"initializeCommand": "bash -c 'for i in $HOME/.inputrc $HOME/.bashrc_dev; do [ -f $i ] || touch $i; done'",
24+
"initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
2525
"runArgs": [
26-
"--privileged",
2726
"--net=host",
2827
"-v=${localEnv:HOME}/.ssh:/root/.ssh",
29-
"-v=${localEnv:HOME}/.bashrc_dev:/root/.bashrc",
3028
"-v=${localEnv:HOME}/.inputrc:/root/.inputrc"
3129
],
3230
"mounts": [

.gitattributes

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

.github/workflows/code.yml

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ on:
55
pull_request:
66
schedule:
77
# Run every Monday at 8am to check latest versions of dependencies
8-
- cron: "0 8 * * MON"
8+
- cron: "0 8 * * WED"
99

1010
jobs:
1111
lint:
1212
# 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.repository == github.repository
13+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
1414
runs-on: ubuntu-latest
1515

1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v2
1919

20-
- uses: actions/setup-python@v2
20+
- name: Setup python
21+
uses: actions/setup-python@v4
2122
with:
2223
python-version: "3.10"
2324

2425
- name: Lint
2526
run: |
26-
touch requirements_dev.txt
27-
python -m pip install --upgrade pip
28-
python -m pip install -r requirements_dev.txt -e .[dev]
27+
touch requirements_dev.txt requirements.txt
28+
pip install -r requirements.txt -r requirements_dev.txt -e .[dev]
2929
tox -e pre-commit,mypy
3030
3131
test:
32-
if: github.event_name != 'pull_request' || github.event.pull_request.repository == github.repository
32+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
3333
strategy:
3434
fail-fast: false
3535
matrix:
@@ -59,13 +59,13 @@ jobs:
5959
run: pytest tests
6060

6161
- name: Upload coverage to Codecov
62-
uses: codecov/codecov-action@v2
62+
uses: codecov/codecov-action@v3
6363
with:
6464
name: ${{ matrix.python }}/${{ matrix.os }}
6565
files: cov.xml
6666

6767
container:
68-
if: github.event_name != 'pull_request' || github.event.pull_request.repository == github.repository
68+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
6969
runs-on: ubuntu-latest
7070
permissions:
7171
contents: read
@@ -77,14 +77,6 @@ jobs:
7777
with:
7878
fetch-depth: 0
7979

80-
- name: Cache Docker layers
81-
uses: actions/cache@v3
82-
with:
83-
path: /tmp/.buildx-cache
84-
key: ${{ runner.os }}-buildx-${{ github.sha }}
85-
restore-keys: |
86-
${{ runner.os }}-buildx-
87-
8880
- name: Log in to GitHub Docker Registry
8981
if: github.event_name != 'pull_request'
9082
uses: docker/login-action@v2
@@ -112,16 +104,19 @@ jobs:
112104
tags: build:latest
113105
context: .
114106
target: build
115-
cache-from: type=local,src=/tmp/.buildx-cache
116-
cache-to: type=local,dest=/tmp/.buildx-cache
117107
load: true
118108

119109
- name: Run tests in the container locked with requirements_dev.txt
120110
run: |
121-
docker run --name test build bash /project/tests/container_tests.sh
111+
docker run --name test build bash /project/.github/workflows/container_tests.sh
122112
docker cp test:/project/dist .
123-
docker cp test:/project/requirements.txt .
124-
docker cp test:/project/requirements_dev.txt .
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
125120

126121
- name: Build runtime image
127122
uses: docker/build-push-action@v3
@@ -130,44 +125,34 @@ jobs:
130125
tags: ${{ steps.meta.outputs.tags }}
131126
context: .
132127
labels: ${{ steps.meta.outputs.labels }}
133-
cache-from: type=local,src=/tmp/.buildx-cache
134-
cache-to: type=local,dest=/tmp/.buildx-cache
128+
129+
- name: Check runtime
130+
run: for i in ${{ steps.meta.outputs.tags }}; do docker run ${i} --version; done
135131

136132
- name: Upload build files
137133
uses: actions/upload-artifact@v3
138134
with:
139-
name: build_files
140-
path: |
141-
dist
142-
requirements.txt
143-
requirements_dev.txt
135+
name: dist
136+
path: dist/*
144137

145138
sdist:
146139
needs: container
147140
runs-on: ubuntu-latest
148141

149142
steps:
150-
- name: Checkout
151-
uses: actions/checkout@v2
152-
153-
- uses: actions/setup-python@v2
154-
with:
155-
python-version: "3.10"
156-
157143
- uses: actions/download-artifact@v3
158144

159145
- name: Install sdist in a venv and check cli works
160146
# ${GITHUB_REPOSITORY##*/} is the repo name without org
161147
# Replace this with the cli command if different to the repo name
162148
run: |
163-
python -m pip install --upgrade pip
164-
python -m pip install build_files/dist/*.gz
149+
pip install dist/*.gz
165150
${GITHUB_REPOSITORY##*/} --version
166151
167152
release:
168153
# upload to PyPI and make a release on every tag
169154
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
170-
needs: [lint, container]
155+
needs: container
171156
runs-on: ubuntu-latest
172157

173158
steps:
@@ -179,13 +164,13 @@ jobs:
179164
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
180165
with:
181166
files: |
182-
build_files/*
167+
dist/*
183168
generate_release_notes: true
184169
env:
185170
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
186171

187172
- name: Publish to PyPI
188173
env:
189174
TWINE_USERNAME: __token__
190-
TWINE_PASSWORD: ${{ secrets.pypi_token }}
191-
run: pipx run twine upload artifacts/dist/*
175+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
176+
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

.github/workflows/docs.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@ name: Docs CI
22

33
on:
44
push:
5-
tags:
6-
- "*"
75
pull_request:
86

97
jobs:
108
docs:
9+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
1110
strategy:
1211
fail-fast: false
1312
matrix:
14-
os: ["ubuntu-latest"]
1513
python: ["3.10"]
1614

1715
runs-on: ubuntu-latest
1816

1917
steps:
18+
- name: Dump github context
19+
run: echo "$GITHUB_CONTEXT"
20+
shell: bash
21+
env:
22+
GITHUB_CONTEXT: ${{ toJson(github) }}
23+
2024
- name: Avoid git conflicts when tag and branch pushed at same time
2125
if: startsWith(github.ref, 'refs/tags')
2226
run: sleep 60
@@ -44,7 +48,7 @@ jobs:
4448
run: tox -e docs
4549

4650
- name: Move to versioned directory
47-
# e.g. master or 0.1.2
51+
# e.g. main or 0.1.2
4852
run: mv build/html ".github/pages/${GITHUB_REF##*/}"
4953

5054
- name: Write versions.txt

.github/workflows/docs_clean.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Docs Cleanup CI
2+
3+
# delete branch documentation when a branch is deleted
4+
# also allow manually deleting a documentation version
5+
on:
6+
delete:
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "documentation version to DELETE"
11+
required: true
12+
type: string
13+
14+
jobs:
15+
remove:
16+
if: github.event.ref_type == 'branch' || github.event_name == 'workflow_dispatch'
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: checkout
21+
uses: actions/checkout@v2
22+
with:
23+
ref: gh-pages
24+
25+
- name: removing documentation for branch ${{ github.event.ref }}
26+
if: ${{ github.event_name != 'workflow_dispatch' }}
27+
run: echo "remove_me=${{ github.event.ref }}" >> $GITHUB_ENV
28+
29+
- name: manually removing documentation version ${{ github.event.inputs.version }}
30+
if: ${{ github.event_name == 'workflow_dispatch' }}
31+
run: echo "remove_me=${{ github.event.inputs.version }}" >> $GITHUB_ENV
32+
33+
- name: update index and push changes
34+
run: |
35+
echo removing redundant documentation version ${{ env.remove_me }}
36+
rm -r ${{ env.remove_me }}
37+
sed -i /${{ env.remove_me }}/d versions.txt
38+
git config --global user.name 'GitHub Actions Docs Cleanup CI'
39+
git config --global user.email '[email protected]'
40+
git commit -am"removing redundant docs version ${{ env.remove_me }}"
41+
git push

.github/workflows/linkcheck.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,18 @@ name: Link Check
33
on:
44
schedule:
55
# Run every Monday at 8am to check URL links still resolve
6-
- cron: "0 8 * * MON"
6+
- cron: "0 8 * * WED"
77

88
jobs:
99
docs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
os: ["ubuntu-latest"]
1413
python: ["3.10"]
1514

1615
runs-on: ubuntu-latest
1716

1817
steps:
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-
2318
- name: Checkout
2419
uses: actions/checkout@v2
2520
with:

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ docs/_build/
6060
# PyBuilder
6161
target/
6262

63-
# DLS build dir and virtual environment
64-
/prefix/
65-
/venv/
66-
/lightweight-venv/
67-
/installed.files
63+
# likely venv names
6864
.venv*
65+
venv*
66+
6967

.gitremotes

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

0 commit comments

Comments
 (0)