Skip to content

Commit 3d060e9

Browse files
authored
Merge pull request #51 from GNS-Science/chore/50-migrate-to-serverless-v4
CHORE: migrate to serverless v4 - update to latest nzshm-model; - python 3.12 - serverless V4 - pyproject PEP508 - add DEVELOPMENT.md - update lock files
2 parents 1df0905 + 36f6996 commit 3d060e9

File tree

16 files changed

+4033
-889
lines changed

16 files changed

+4033
-889
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.3.1
2+
current_version = 0.4.0
33
commit = True
44
tag = False
55

.github/workflows/deploy-to-aws.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
needs: call-test-workflow
1919
uses: GNS-Science/nshm-github-actions/.github/workflows/deploy-to-aws.yml@main
2020
with:
21-
python-version: '3.10'
22-
smoketest-query: "query {about, current_model_version}"
21+
python-version: '3.12'
22+
node-version: '22'
23+
node-pkg-manager: 'yarn2'
24+
smoketest-query: 'query QueryRoot{about}'
2325
secrets: inherit
26+

.github/workflows/dev.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
uses: GNS-Science/nshm-github-actions/.github/workflows/python-run-tests.yml@main
1717
with:
1818
operating-systems: "['ubuntu-latest']"
19-
python-versions: "['3.10']"
19+
python-versions: "['3.12']"
2020
delete-poetry-lock: ${{ github.event_name == 'schedule' }} # the scheduled build tests against newer dependencies
21+
optional-dependency-groups: dev
2122
secrets: inherit

.github/workflows/release.yml

Lines changed: 15 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,28 @@
11
# Publish package on main branch if it's tagged with 'v*'
22

3-
name: release & publish workflow
3+
name: Release & publish workflow
44

55
# Controls when the action will run.
66
on:
77
# Triggers the workflow on push events but only for the master branch
88
push:
9-
tags:
10-
- 'v*'
9+
tags: 'v*'
1110

1211
# Allows you to run this workflow manually from the Actions tab
1312
workflow_dispatch:
1413

15-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1614
jobs:
17-
# This workflow contains a single job called "release"
18-
release:
19-
name: Create Release
20-
runs-on: ubuntu-20.04
2115

22-
strategy:
23-
matrix:
24-
python-versions: [3.8]
25-
26-
# Steps represent a sequence of tasks that will be executed as part of the job
27-
steps:
28-
- name: Get version from tag
29-
id: tag_name
30-
run: |
31-
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
32-
shell: bash
33-
34-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
35-
- uses: actions/checkout@v2
36-
37-
- name: Get Changelog Entry
38-
id: changelog_reader
39-
uses: mindsers/changelog-reader-action@v2
40-
with:
41-
validation_depth: 10
42-
version: ${{ steps.tag_name.outputs.current_version }}
43-
path: ./CHANGELOG.md
44-
45-
- uses: actions/setup-python@v2
46-
with:
47-
python-version: ${{ matrix.python-versions }}
48-
49-
- name: Install dependencies
50-
run: |
51-
python -m pip install --upgrade pip
52-
pip install poetry
53-
54-
- name: build documentation
55-
run: |
56-
poetry install -E doc
57-
poetry run mkdocs build
58-
59-
- name: publish documentation
60-
uses: peaceiris/actions-gh-pages@v3
61-
with:
62-
github_token: ${{ secrets.GITHUB_TOKEN }}
63-
publish_dir: ./site
64-
65-
# - name: Build wheels and source tarball
66-
# run: >-
67-
# poetry build
68-
69-
# - name: show temporary files
70-
# run: >-
71-
# ls -l
72-
73-
# - name: create github release
74-
# id: create_release
75-
# uses: softprops/action-gh-release@v1
76-
# env:
77-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
# with:
79-
# body: ${{ steps.changelog_reader.outputs.changes }}
80-
# files: dist/*.whl
81-
# draft: false
82-
# prerelease: false
83-
84-
# - name: publish to PyPI
85-
# uses: pypa/gh-action-pypi-publish@release/v1
86-
# with:
87-
# user: __token__
88-
# password: ${{ secrets.PYPI_API_TOKEN }}
89-
# skip_existing: true
16+
release-and-distribute:
17+
uses: GNS-Science/nshm-github-actions/.github/workflows/python-release.yml@main
18+
with:
19+
python-version: '3.12'
20+
pypi-publish: false
21+
secrets: inherit
22+
23+
# deploy-docs:
24+
# uses: GNS-Science/nshm-github-actions/.github/workflows/python-deploy-docs.yml@main
25+
# with:
26+
# python-version: '3.12'
27+
# optional-dependency-groups: 'doc'
28+
# secrets: inherit

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ wheels/
2929
*.egg-info/
3030
.installed.cfg
3131
*.egg
32+
requirements.txt
33+
audit.txt
3234

3335
# PyInstaller
3436
# Usually these files are written by a python script from a template

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
# Changelog
22

3+
4+
## [0.4.0] - 2025-10-20
5+
6+
### Changed
7+
- migrate to serverless 4
8+
- use python 3.12
9+
- migrate pyproject.toml to PEP508
10+
- ensureCI/CD workflows use minimum install footprints
11+
- update to `nzshm-model 0.14.0`
12+
13+
### Added
14+
- tox audit step
15+
316
## [0.3.1] - 2025-09-15
417

518
### Changed
619
- graphql-server pinned
720
- dev dependencies updated
821

9-
1022
## [0.3.0] - 2025-07-29
1123

1224
### Changed

DEVELOPMENT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# DEVELOPMENT
2+
3+
### Environment setup
4+
5+
- clone the repo
6+
- check/install a recent node version >=22
7+
`nvm use 22`
8+
9+
- setup python env
10+
```
11+
pyenv local 3.12
12+
poetry env use 3.12
13+
```
14+
15+
setup yarn 2 ...
16+
```
17+
18+
19+
yarn install
20+
```
21+
22+
Now `yarn sls info` should print something like ...
23+
24+
```
25+
$ sls info
26+
Running "serverless" from node_modules
27+
Environment: darwin, node 22.16.0, framework 3.40.0 (local), plugin 7.2.3, SDK 4.5.1
28+
Credentials: Local, "default" profile
29+
Docs: docs.serverless.com
30+
Support: forum.serverless.com
31+
Bugs: github.com/serverless/serverless/issue
32+
33+
```
34+
You'll problably see an error, if your AWS credentials are not those required for SLS.
35+
36+
## TESTING
37+
38+
### Run API locally
39+
```
40+
ENABLE_METRICS=0 poetry run yarn sls wsgi serve
41+
```
42+
43+
## Auditing requirements packages
44+
45+
NB this is now included in tox:audit step
46+
47+
```
48+
poetry export --all-groups --output audit.txt
49+
poetry run pip-audit -r audit.txt -s pypi --require-hashes
50+
poetry run pip-audit -r audit.txt -s osv --require-hashes
51+
52+
poetry show {package-name}
53+
```
54+
55+
### `safety` requires user login registration, but seems closer to dependabot in detections.
56+
```
57+
poetry run safety scan
58+
```
59+
60+
### Node
61+
```
62+
yarn npm audit -R
63+
yarn why {package-name}
64+
yarn upgrade-interactive
65+
```
66+
67+
## DEPLOY DEV service
68+
69+
```
70+
AWS_PROFILE=**** poetry run yarn sls deploy --region ap-southeast-2 --stage dev
71+
```
72+
73+
### API Feature tests
74+
`$>poetry run pytest` should just work.
75+
76+

nshm_model_graphql_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__author__ = """GNS Science"""
44
__email__ = "nshm@gns.cri.nz"
5-
__version__ = "0.3.1"
5+
__version__ = "0.4.0"

nshm_model_graphql_api/schema/nshm_model_sources_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import graphene
77
import nzshm_model as nm
88
from graphene import relay
9-
from nzshm_model.logic_tree.source_logic_tree.version2 import logic_tree
9+
from nzshm_model.logic_tree.source_logic_tree import logic_tree
1010

1111
log = logging.getLogger(__name__)
1212

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nshm-model-graphql-api",
3-
"version": "0.3.1",
3+
"version": "0.4.0",
44
"description": "A graphql API for NSHM seismic models",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1",
@@ -15,16 +15,15 @@
1515
"url": "git+https://github.com/GNS-Science/nshm-tosh-api.git"
1616
},
1717
"keywords": [],
18-
"author": "",
19-
"license": "",
2018
"bugs": {
2119
"url": "https://github.com/GNS-Science/nshm-toshi-api/issues"
2220
},
2321
"homepage": "https://github.com/GNS-Science/nshm-toshi-api#readme",
2422
"dependencies": {
25-
"serverless": "^3.40.0",
26-
"serverless-plugin-warmup": "^8.2.1",
27-
"serverless-python-requirements": "^6.1.0",
28-
"serverless-wsgi": "^3.0.2"
29-
}
23+
"serverless": "^4.21.1",
24+
"serverless-plugin-warmup": "^8.3.0",
25+
"serverless-python-requirements": "^6.1.2",
26+
"serverless-wsgi": "^3.1.0"
27+
},
28+
"packageManager": "yarn@4.10.3"
3029
}

0 commit comments

Comments
 (0)