Skip to content

Commit e9e7a57

Browse files
Initial CI/CD work.
1 parent fadef18 commit e9e7a57

14 files changed

Lines changed: 319 additions & 25 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 'Common Python job setup'
2+
description: 'Perform build environment setup steps common to all Python jobs.'
3+
4+
inputs:
5+
python-version:
6+
description: 'Python version to use'
7+
required: true
8+
default: 3.13
9+
10+
# outputs:
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ inputs.python-version }}
19+
allow-prereleases: true
20+
21+
- name: Pip cache
22+
uses: actions/cache@v4
23+
with:
24+
path: ~/.cache/pip
25+
key: ${{ runner.os }}-pip
26+
restore-keys: |
27+
${{ runner.os }}-pip
28+
29+
- name: "Install tools : nox"
30+
shell: bash
31+
run: |
32+
pip install --upgrade nox

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: Release
2+
3+
# TODO: publish to pypi
4+
# TODO: publish to readthedocs
5+
# TODO: publish to github?
6+

.github/workflows/test.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
# permissions: {}
6+
7+
env:
8+
PYTHON_VERSION: "3.13"
9+
10+
jobs:
11+
black_formatting:
12+
name: Black Format Linting
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Prepare common Python build environment
18+
uses: ./.github/actions/python-common-setup
19+
with:
20+
python-version: ${{ env.PYTHON_VERSION }}
21+
- name: 'Nox: Python Black'
22+
run: |
23+
nox -s black-lint
24+
25+
pytest_all:
26+
name: Test Python ${{ matrix.python-version }}
27+
runs-on: ubuntu-latest
28+
strategy:
29+
matrix:
30+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
- name: Prepare common Python build environment
35+
uses: ./.github/actions/python-common-setup
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
- name: "Nox: Pytest ${{ matrix.python-version }}"
39+
run: |
40+
nox -s pytest-${{ matrix.python-version }}
41+
42+
semgrep_src:
43+
name: Semgrep Security Scanning
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v4
48+
- name: Prepare common Python build environment
49+
uses: ./.github/actions/python-common-setup
50+
with:
51+
python-version: ${{ env.PYTHON_VERSION }}
52+
- name: 'Nox: Semgrep - src'
53+
run: |
54+
nox -s semgrep_src
55+
56+
mypy_all:
57+
name: MyPy - All
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout code
61+
uses: actions/checkout@v4
62+
- name: Prepare common Python build environment
63+
uses: ./.github/actions/python-common-setup
64+
with:
65+
python-version: ${{ env.PYTHON_VERSION }}
66+
- name: "Nox: MyPy"
67+
run: |
68+
nox -s mypy
69+
70+
pyflakes_src:
71+
name: Pyflakes - src
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v4
76+
- name: Prepare common Python build environment
77+
uses: ./.github/actions/python-common-setup
78+
with:
79+
python-version: ${{ env.PYTHON_VERSION }}
80+
- name: "Nox: Pyflakes - src"
81+
run: |
82+
nox -s pyflakes_src
83+
84+
pyflakes_examples:
85+
name: Pyflakes - examples
86+
runs-on: ubuntu-latest
87+
steps:
88+
- name: Checkout code
89+
uses: actions/checkout@v4
90+
- name: Prepare common Python build environment
91+
uses: ./.github/actions/python-common-setup
92+
with:
93+
python-version: ${{ env.PYTHON_VERSION }}
94+
- name: "Nox: Pyflakes - examples"
95+
run: |
96+
nox -s pyflakes_examples
97+
98+
pyflakes_test:
99+
name: Pyflakes - tests
100+
runs-on: ubuntu-latest
101+
steps:
102+
- name: Checkout code
103+
uses: actions/checkout@v4
104+
- name: Prepare common Python build environment
105+
uses: ./.github/actions/python-common-setup
106+
with:
107+
python-version: ${{ env.PYTHON_VERSION }}
108+
- name: "Nox: Pyflakes - tests"
109+
run: |
110+
nox -s pyflakes_tests
111+
112+
pylint_src:
113+
name: Pylint - src
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Checkout code
117+
uses: actions/checkout@v4
118+
- name: Prepare common Python build environment
119+
uses: ./.github/actions/python-common-setup
120+
with:
121+
python-version: ${{ env.PYTHON_VERSION }}
122+
- name: "Nox: Pylint - src"
123+
run: |
124+
nox -s pylint_src
125+
126+
pylint_examples:
127+
name: Pylint - examples
128+
runs-on: ubuntu-latest
129+
steps:
130+
- name: Checkout code
131+
uses: actions/checkout@v4
132+
- name: Prepare common Python build environment
133+
uses: ./.github/actions/python-common-setup
134+
with:
135+
python-version: ${{ env.PYTHON_VERSION }}
136+
- name: "Nox: Pylint - examples"
137+
run: |
138+
nox -s pylint_examples
139+
140+
pylint_test:
141+
name: Pylint - tests
142+
runs-on: ubuntu-latest
143+
steps:
144+
- name: Checkout code
145+
uses: actions/checkout@v4
146+
- name: Prepare common Python build environment
147+
uses: ./.github/actions/python-common-setup
148+
with:
149+
python-version: ${{ env.PYTHON_VERSION }}
150+
- name: "Nox: Pylint - tests"
151+
run: |
152+
nox -s pylint_tests

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*.build*
22
.coverage*
33
coverage.xml
4-
coverage-dist.xml
4+
coverage-*.xml
55
dist
66
.DS_Store
77
*.egg-info
@@ -11,6 +11,7 @@ mypy.xml
1111
pip-wheel-metadata
1212
pytest.xml
1313
pytest-*.xml
14+
semgrep-*.xml
1415
site
1516
*.venv
1617
venv*

docs/examples/auth-client/planet-legacy/make-legacy-authenticated-requests-request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import planet_auth_config
2-
31
import requests
2+
43
from planet_auth import Auth
4+
import planet_auth_config # type: ignore
55

66

77
def main():

docs/examples/auth-client/planet-legacy/perform-legacy-initial-login.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from planet_auth import Auth
2-
import planet_auth_config
2+
import planet_auth_config # type: ignore
33

44

55
def main():

docs/examples/service/flask--oidc-multi-issuer--local-only-validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import List, Optional
88

99
import planet_auth
10-
import planet_auth_config
10+
import planet_auth_config # type: ignore
1111

1212
#############################################################################
1313
# Logging Configuration

noxfile.py

Lines changed: 105 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55

66
nox.options.sessions = ["test", "lint"]
77

8+
_DEFAULT_PYTHON = "3.13"
9+
_ALL_PYTHON = ["3.9", "3.10", "3.11", "3.12", "3.13"]
810

9-
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
10-
def test(session):
11-
session.install("-e", ".[test]")
11+
12+
@nox.session(python=_ALL_PYTHON)
13+
def pytest(session):
14+
session.install("-e", ".[tests]")
1215

1316
options = session.posargs
1417
if "-k" in options:
@@ -17,10 +20,102 @@ def test(session):
1720
session.run("pytest", "-v", *options)
1821

1922

20-
@nox.session
21-
def lint(session):
22-
session.install("-e", ".[test]")
23-
session.run("black", "--check", "--diff", "--color", ".")
24-
# This represents Devrel's copy-and-paste linting.
25-
# session.run("flake8", *source_files)
26-
# session.run('yapf', '--diff', '-r', *source_files)
23+
@nox.session(python=_DEFAULT_PYTHON)
24+
def semgrep_src(session):
25+
session.install("-e", ".[tests]")
26+
# session.run("semgrep", "scan", "--strict", "--verbose", "--error", "--junit-xml", "--junit-xml-output=semgrep-src.xml", "src")
27+
session.run("semgrep", "scan", "--strict", "--verbose", "--error", "src")
28+
29+
30+
@nox.session(name="black-lint", python=_DEFAULT_PYTHON)
31+
def black_lint(session):
32+
session.install("-e", ".[tests]")
33+
session.run("black", "--verbose", "--check", "--diff", "--color", ".")
34+
35+
36+
@nox.session(python=_DEFAULT_PYTHON)
37+
def black_format(session):
38+
session.install("-e", ".[tests]")
39+
session.run("black", "--verbose", ".")
40+
41+
42+
@nox.session(python=_DEFAULT_PYTHON)
43+
def mypy(session):
44+
session.install("-e", ".[tests, examples]")
45+
session.run("mypy", "--install-type", "--non-interactive", "--junit-xml", "mypy.xml")
46+
47+
48+
@nox.session(python=_DEFAULT_PYTHON)
49+
def pyflakes_src(session):
50+
session.install("-e", ".[tests]")
51+
session.run("pyflakes", "src")
52+
53+
54+
@nox.session(python=_DEFAULT_PYTHON)
55+
def pyflakes_examples(session):
56+
session.install("-e", ".[tests, examples]")
57+
session.run("pyflakes", "docs/examples")
58+
59+
60+
@nox.session(python=_DEFAULT_PYTHON)
61+
def pyflakes_tests(session):
62+
session.install("-e", ".[tests]")
63+
session.run("pyflakes", "tests")
64+
65+
66+
@nox.session(python=_DEFAULT_PYTHON)
67+
def pylint_src(session):
68+
session.install("-e", ".[tests]")
69+
session.run("pylint", "src")
70+
71+
72+
@nox.session(python=_DEFAULT_PYTHON)
73+
def pylint_examples(session):
74+
session.install("-e", ".[tests, examples]")
75+
session.run("pylint", "docs/examples")
76+
77+
78+
@nox.session(python=_DEFAULT_PYTHON)
79+
def pylint_tests(session):
80+
session.install("-e", ".[tests]")
81+
session.run("pylint", "--disable", "protected-access", "--disable", "unused-variable", "tests")
82+
83+
84+
@nox.session(python=_DEFAULT_PYTHON)
85+
def build_wheel(session):
86+
session.install("-e", ".[build]")
87+
session.run("pyproject-build")
88+
# session.run("simple503", "-B", "dist", "dist")
89+
90+
91+
@nox.session(python=_DEFAULT_PYTHON)
92+
def build_local_dist(session):
93+
session.install("-e", ".[build]")
94+
session.run("pyproject-build")
95+
session.run("simple503", "-B", "dist", "dist")
96+
97+
98+
@nox.session(python=_DEFAULT_PYTHON)
99+
def mkdocs_build(session):
100+
session.install("-e", ".[docs]")
101+
session.run("mkdocs", "-v", "build")
102+
103+
104+
@nox.session(python=_DEFAULT_PYTHON)
105+
def mkdocs_serve(session):
106+
session.install("-e", ".[docs]")
107+
session.run("mkdocs", "-v", "serve")
108+
109+
110+
@nox.session(python=_DEFAULT_PYTHON)
111+
def pyblish_pypi(session):
112+
session.install("-e", ".[build]")
113+
# TODO
114+
assert False
115+
116+
117+
@nox.session(python=_DEFAULT_PYTHON)
118+
def pyblish_readthedocs(session):
119+
session.install("-e", ".[build, docs]")
120+
# TODO
121+
assert False

0 commit comments

Comments
 (0)