-
Notifications
You must be signed in to change notification settings - Fork 6
Improved CICD flow #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
8ecc4b4
Apply formatting
mjvogelsong 53a21f5
Add linter github action
mjvogelsong f44bd16
Add poetry.lock
mjvogelsong 407da2d
ignore import-error pylint
mjvogelsong 267ea68
Add pre-commit
mjvogelsong 4b78d37
Improve documentation
mjvogelsong 69aa0e6
Add more comments
mjvogelsong 41e30cd
Developer improvements
mjvogelsong 0081b99
Linter section of DEVELOPING.md
mjvogelsong 58b9079
Final cleanup
mjvogelsong 0e385b3
Improve makefile
mjvogelsong 30fc54a
Try fixing bot
mjvogelsong 3bdbe9a
Single cicd.yaml
mjvogelsong 6ec9ec5
Fix runs-on
mjvogelsong 3730211
Debug no-op flow
mjvogelsong af3af94
poetry-prep
mjvogelsong 501a991
Fix path
mjvogelsong c27858a
move get code
mjvogelsong e3ae3b2
Move back to cicd
mjvogelsong fd3d283
Fix typo
mjvogelsong 8e7f37d
Real flow
mjvogelsong f8a922a
Add comments
mjvogelsong cff53cd
Simplify
mjvogelsong a156d75
Simplify
mjvogelsong 8983ddf
Merge branch 'linting-improvements' into improved-cicd-flow
mjvogelsong 153601e
extras
mjvogelsong 3627793
Merge branch 'main' into linting-improvements
mjvogelsong 7b5ee2c
Fix linter errors
mjvogelsong 710e38c
Merge branch 'linting-improvements' into improved-cicd-flow
mjvogelsong 8481d55
Update .pylintrc
mjvogelsong 625c278
Merge branch 'linting-improvements' into improved-cicd-flow
mjvogelsong 580da18
Single workflow
mjvogelsong b0349b1
Typo
mjvogelsong 5c41a43
Try "not main"
mjvogelsong 91e09a2
Add note
mjvogelsong 31aa259
Merge branch 'main' into linting-improvements
mjvogelsong a87e7cd
Fix linter errors
mjvogelsong e6105a4
Formatter on md
mjvogelsong 2870d60
Merge branch 'linting-improvements' into improved-cicd-flow
mjvogelsong f3dcc09
Small markdown
mjvogelsong 02b0bd4
Merge branch 'main' into improved-cicd-flow
mjvogelsong 9da3a6b
Remove extra file
mjvogelsong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.