Skip to content

Commit fae7ced

Browse files
authored
Merge pull request #20 from NHSDigital/mm-mesh-1478-mesh-code-splitting
mesh-1478: publish to pypi
2 parents 9be1e8b + 739d157 commit fae7ced

File tree

3 files changed

+99
-8
lines changed

3 files changed

+99
-8
lines changed

.github/workflows/merge-develop.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ jobs:
5757
thresholdAll: 0.54
5858

5959
- name: setup java
60-
if: github.actor!= 'dependabot[bot]' && (success() || failure())
60+
if: github.actor != 'dependabot[bot]' && (success() || failure())
6161
uses: actions/setup-java@v3
6262
with:
6363
distribution: "corretto"
6464
java-version: "17"
6565

6666
- name: provision sonar-scanner
67-
if: github.actor!= 'dependabot[bot]' && (success() || failure())
67+
if: github.actor != 'dependabot[bot]' && (success() || failure())
6868
run: |
6969
export SONAR_VERSION="4.7.0.2747"
7070
wget -q "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_VERSION}.zip" -O sonar-scanner.zip
@@ -73,7 +73,7 @@ jobs:
7373
scripts/sonar_tests.py
7474
7575
- name: run sonar scan
76-
if: github.actor!= 'dependabot[bot]' && (success() || failure())
76+
if: github.actor != 'dependabot[bot]' && (success() || failure())
7777
run: |
7878
PATH="$PWD/sonar-scanner/bin:$PATH"
7979
sonar-scanner
@@ -95,7 +95,7 @@ jobs:
9595

9696
publish:
9797
runs-on: ubuntu-latest
98-
if: github.repository == 'NHSDigital/nhs-aws-helpers' && github.actor!= 'dependabot[bot]' && !contains(github.event.head_commit.message, 'tag release version:')
98+
if: github.repository == 'NHSDigital/nhs-aws-helpers' && github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, 'tag release version:')
9999
steps:
100100
- name: checkout
101101
uses: actions/checkout@v3
@@ -140,6 +140,13 @@ jobs:
140140
tag_name: ${{ env.RELEASE_VERSION }}
141141
release_name: ${{ env.RELEASE_VERSION }}
142142

143+
- name: poetry config
144+
run: |
145+
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
146+
147+
- name: poetry publish
148+
run: poetry publish
149+
143150
- name: upload wheel
144151
uses: actions/upload-release-asset@v1
145152
env:

.github/workflows/pull-request.yml

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ jobs:
137137
thresholdAll: 0.54
138138

139139
- name: setup java
140-
if: github.actor!= 'dependabot[bot]' && (success() || failure())
140+
if: github.actor != 'dependabot[bot]' && (success() || failure())
141141
uses: actions/setup-java@v3
142142
with:
143143
distribution: "corretto"
144144
java-version: "17"
145145

146146
- name: provision sonar-scanner
147-
if: github.actor!= 'dependabot[bot]' && (success() || failure())
147+
if: github.actor != 'dependabot[bot]' && (success() || failure())
148148
run: |
149149
export SONAR_VERSION="4.7.0.2747"
150150
wget -q "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_VERSION}.zip" -O sonar-scanner.zip
@@ -153,7 +153,7 @@ jobs:
153153
scripts/sonar_tests.py
154154
155155
# - name: run sonar scan
156-
# if: github.actor!= 'dependabot[bot]' && (success() || failure())
156+
# if: github.actor != 'dependabot[bot]' && (success() || failure())
157157
# run: |
158158
# PATH="$PWD/sonar-scanner/bin:$PATH"
159159
# if [[ "${{ github.event_name }}" == "pull_request" ]]; then
@@ -168,7 +168,7 @@ jobs:
168168

169169

170170
- name: archive reports
171-
if: github.actor!= 'dependabot[bot]' && (success() || failure())
171+
if: github.actor != 'dependabot[bot]' && (success() || failure())
172172
uses: actions/upload-artifact@v3
173173
with:
174174
name: reports
@@ -263,3 +263,63 @@ jobs:
263263
echo "RELEASE_VERSION=$version" >> $GITHUB_ENV
264264
echo "${version}"
265265
266+
267+
publish:
268+
runs-on: ubuntu-latest
269+
if: github.repository == 'NHSDigital/nhs-aws-helpers' && github.actor != 'dependabot[bot]'
270+
needs:
271+
- coverage
272+
- lint
273+
- tox
274+
steps:
275+
- name: checkout
276+
uses: actions/checkout@v3
277+
with:
278+
fetch-depth: 0
279+
280+
- name: print branch info
281+
run: |
282+
git branch
283+
echo "GITHUB_HEAD_REF=${GITHUB_HEAD_REF}"
284+
echo "GITHUB_BASE_REF=${GITHUB_BASE_REF}"
285+
git log --oneline -n 10
286+
287+
- name: clean
288+
run: |
289+
git clean -fdx
290+
find . -type f | xargs chmod g+w
291+
292+
- name: merge into base_branch
293+
if: ${{ github.event_name == 'pull_request' }}
294+
run: |
295+
echo base branch "${{ github.base_ref }}"
296+
echo pr branch "${{ github.head_ref }}"
297+
git checkout "${{ github.base_ref }}"
298+
git checkout -b "merging-${{ github.event.number }}"
299+
git merge --ff-only "${{ github.event.pull_request.head.sha }}"
300+
301+
- name: setup python
302+
uses: actions/setup-python@v3
303+
with:
304+
python-version: "3.8"
305+
306+
- name: setup poetry
307+
uses: abatilo/actions-poetry@v2
308+
with:
309+
poetry-version: 1.5.1
310+
311+
- name: add poetry plugins
312+
run: |
313+
poetry self add "poetry-dynamic-versioning[plugin]"
314+
315+
- name: poetry build
316+
run: |
317+
poetry build --format=wheel
318+
319+
- name: poetry config
320+
run: |
321+
poetry config repositories.testpypi https://test.pypi.org/legacy/
322+
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }}
323+
324+
- name: poetry test publish
325+
run: poetry publish -r testpypi

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,27 @@ see [releases](https://github.com/NHSDigital/nhs-aws-helpers/releases) for the l
1313
```shell
1414
pip install https://github.com/NHSDigital/nhs-aws-helpers/releases/download/v0.0.12/nhs_aws_helpers-0.0.12-py3-none-any.whl
1515
```
16+
17+
## testing
18+
19+
the library comes with a some pytest fixtures ... [nhs_aws_helpers/fixtures.py](nhs_aws_helpers/fixtures.py)
20+
21+
22+
```python
23+
# conftest.py
24+
from nhs_aws_helpers.fixtures import *
25+
26+
# mytest.py
27+
import pytest
28+
from mypy_boto3_dynamodb.service_resource import Table
29+
30+
@pytest.fixture(scope="function")
31+
def my_temp_table() -> Table:
32+
yield from temp_dynamodb_table("my-source-table-to-clone")
33+
34+
35+
def my_test(my_temp_ddb_table: Table):
36+
# do things with table
37+
pass
38+
39+
```

0 commit comments

Comments
 (0)