Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8ecc4b4
Apply formatting
mjvogelsong Apr 13, 2023
53a21f5
Add linter github action
mjvogelsong Apr 13, 2023
f44bd16
Add poetry.lock
mjvogelsong Apr 13, 2023
407da2d
ignore import-error pylint
mjvogelsong Apr 13, 2023
267ea68
Add pre-commit
mjvogelsong Apr 13, 2023
4b78d37
Improve documentation
mjvogelsong Apr 13, 2023
69aa0e6
Add more comments
mjvogelsong Apr 13, 2023
41e30cd
Developer improvements
mjvogelsong Apr 13, 2023
0081b99
Linter section of DEVELOPING.md
mjvogelsong Apr 14, 2023
58b9079
Final cleanup
mjvogelsong Apr 14, 2023
0e385b3
Improve makefile
mjvogelsong Apr 14, 2023
30fc54a
Try fixing bot
mjvogelsong Apr 14, 2023
3bdbe9a
Single cicd.yaml
mjvogelsong Apr 14, 2023
6ec9ec5
Fix runs-on
mjvogelsong Apr 14, 2023
3730211
Debug no-op flow
mjvogelsong Apr 14, 2023
af3af94
poetry-prep
mjvogelsong Apr 14, 2023
501a991
Fix path
mjvogelsong Apr 14, 2023
c27858a
move get code
mjvogelsong Apr 14, 2023
e3ae3b2
Move back to cicd
mjvogelsong Apr 14, 2023
fd3d283
Fix typo
mjvogelsong Apr 14, 2023
8e7f37d
Real flow
mjvogelsong Apr 14, 2023
f8a922a
Add comments
mjvogelsong Apr 14, 2023
cff53cd
Simplify
mjvogelsong Apr 14, 2023
a156d75
Simplify
mjvogelsong Apr 14, 2023
8983ddf
Merge branch 'linting-improvements' into improved-cicd-flow
mjvogelsong Apr 14, 2023
153601e
extras
mjvogelsong Apr 14, 2023
3627793
Merge branch 'main' into linting-improvements
mjvogelsong Apr 14, 2023
7b5ee2c
Fix linter errors
mjvogelsong Apr 14, 2023
710e38c
Merge branch 'linting-improvements' into improved-cicd-flow
mjvogelsong Apr 14, 2023
8481d55
Update .pylintrc
mjvogelsong Apr 14, 2023
625c278
Merge branch 'linting-improvements' into improved-cicd-flow
mjvogelsong Apr 14, 2023
580da18
Single workflow
mjvogelsong Apr 14, 2023
b0349b1
Typo
mjvogelsong Apr 14, 2023
5c41a43
Try "not main"
mjvogelsong Apr 14, 2023
91e09a2
Add note
mjvogelsong Apr 14, 2023
31aa259
Merge branch 'main' into linting-improvements
mjvogelsong Apr 14, 2023
a87e7cd
Fix linter errors
mjvogelsong Apr 14, 2023
e6105a4
Formatter on md
mjvogelsong Apr 14, 2023
2870d60
Merge branch 'linting-improvements' into improved-cicd-flow
mjvogelsong Apr 14, 2023
f3dcc09
Small markdown
mjvogelsong Apr 14, 2023
02b0bd4
Merge branch 'main' into improved-cicd-flow
mjvogelsong Apr 14, 2023
9da3a6b
Remove extra file
mjvogelsong Apr 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions .github/workflows/auto-format.yaml

This file was deleted.

250 changes: 250 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
# CI/CD workflow for the groundlight-sdk-python repository. We lint, test, deploy docs, and publish
# to pypi.
name: cicd
on: [push]

env:
PYTHON_VERSION: "3.10"
POETRY_VERSION: "1.4.0"
jobs:
# Run our linter on every push to the repository.
lint:
runs-on: ubuntu-latest
steps:
- name: get code
uses: actions/checkout@v3
- name: install python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
- name: show python version ${{ env.PYTHON_VERSION }}
run: |
poetry run python --version
- name: install linter dependencies
run: |
make install-lint
- name: lint
run: |
make lint

# Run integration tests against the API. For efficiency, we only run one version of python on
# non-main branches.
test-simple:
runs-on: ubuntu-latest
steps:
- name: get code
uses: actions/checkout@v3
- name: install python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
- name: show python version ${{ env.PYTHON_VERSION }}
run: |
poetry run python --version
- name: install dependencies (without extras)
run: make install
# TODO: Should we run all tests against the prod API?
- name: run tests
env:
# This is associated with the "sdk-integ-test" user, credentials on 1password
GROUNDLIGHT_API_TOKEN: ${{ secrets.GROUNDLIGHT_API_TOKEN }}
run: make test-integ
- name: run docs tests
run: make test-docs
env:
# This is associated with the "sdk-test-prod" user, credentials on 1password
GROUNDLIGHT_API_TOKEN: ${{ secrets.GROUNDLIGHT_API_TOKEN_PROD }}

# Run integration tests against the API (only on the main branch, though). The comprehensive
# version runs a matrix of python versions for better coverage.
test-comprehensive:
if: github.ref == 'refs/heads/main'
needs:
- test-simple
runs-on: ubuntu-latest
strategy:
# It's totally debatable which is better here: fail-fast or not.
# Failing fast will use fewer cloud resources, in theory.
# But if the tests are slightly flaky (fail to pip install something)
# Then one flaky install kills lots of jobs that need to be redone.
# So the efficiency argument has its limits
# Failing slow is clearer about what's going on.
# This is pretty unambiguous, so we're going with it for now.
fail-fast: false
matrix:
python-version: [
#"3.6", # Default on Ubuntu18.04 but openapi-generator fails
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
]
install_extras: [true, false]
steps:
- name: get code
uses: actions/checkout@v3
- name: install python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
- name: show python version ${{ matrix.python-version }}
run: |
poetry run python --version
- name: install dependencies
run: make install
- name: install extras
if: matrix.install_extras
run: make install-extras
# TODO: Should we run all tests against the prod API?
- name: run tests
env:
# This is associated with the "sdk-integ-test" user, credentials on 1password
GROUNDLIGHT_API_TOKEN: ${{ secrets.GROUNDLIGHT_API_TOKEN }}
run: make test-integ
- name: run docs tests
run: make test-docs
env:
# This is associated with the "sdk-test-prod" user, credentials on 1password
GROUNDLIGHT_API_TOKEN: ${{ secrets.GROUNDLIGHT_API_TOKEN_PROD }}

# Run the auto-formatter when we're not on the main branch. This will push a new commit to the PR
# branch if needed.
format:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: get code
uses: actions/checkout@v1
with:
ref: ${{ github.head_ref }}
- name: install python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
- name: show python version ${{ env.PYTHON_VERSION }}
run: |
poetry run python --version
- name: install linter dependencies
run: |
make install-lint
- name: run formatter
run: |
make format
- name: check for modified files
id: git-check
run: |
git status
echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: push changes (if needed)
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Auto-format Bot'
git config --global user.email 'autoformatbot@groundlight.ai'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git commit -am "Automatically reformatting code"
git push

# Check if we have changes in the docs directory, and if so, set a `changed` flag.
check-docs-changes:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.changes.outputs.changed }}
steps:
- name: get code
uses: actions/checkout@v3
- name: check for docs changes
id: changes
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep '^docs/'; then
echo "Changes detected in 'docs'"
echo "::set-output name=changed::true"
else
echo "No changes detected in 'docs'"
echo "::set-output name=changed::false"
fi

# Try to build the docs if there are changes in the docs directory, and deploy to github pages if
# we're on the main branch and tests passed. Note that we don't require a code release -- we don't
# want to couple documentation updates with code releases.
deploy-docs:
if: needs.check-docs-changes.outputs.changed == 'true' && github.ref == 'refs/heads/main'
needs:
- check-docs-changes
- test-comprehensive
runs-on: ubuntu-latest
steps:
- name: Get code
uses: actions/checkout@v3
- name: Setup npm
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm install
- name: Build website
run: npm run build
- name: Deploy website (if on main branch)
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
uses: peaceiris/actions-gh-pages@v3
# Only deploy on pushes to the `main` branch
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
#TODO: setup a staging directory when doing a PR
#destination_dir: staging
# The following lines assign commit authorship to the official
# GH-Actions bot for deploys to `gh-pages` branch:
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
# The GH actions bot is used by default if you didn't specify the two fields.
# You can swap them out with your own user credentials.
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com

# When a release is created on github (and comprehensive tests passed), publish the groundlight
# package to public pypi.
publish-python-package:
if: github.ref == 'refs/heads/main' && github.event_name == 'release'
runs-on: ubuntu-latest
needs:
- test-comprehensive
# For now, we'll require the comprehensive tests to succeed, but not the linter checks.
# - lint
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_PUBLISH_TOKEN }}
steps:
- name: get code
uses: actions/checkout@v3
- name: install python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
- name: show python version ${{ env.PYTHON_VERSION }}
run: |
poetry run python --version
- name: build package
run: poetry build
- name: configure poetry and publish
run: poetry publish
27 changes: 0 additions & 27 deletions .github/workflows/lint.yaml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/publish-docs.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/publish-pypi.yaml

This file was deleted.

Loading