Skip to content
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

TSPS-348 part two: remove teaspoons-cli dir and contents #150

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cf8c902
wip GHAs
mmorgantaylor Oct 30, 2024
65bdaad
remove main branch specification for python client release, change py…
mmorgantaylor Oct 30, 2024
78d6ba3
add environment and permissions specs to gha
mmorgantaylor Oct 30, 2024
e902817
fix projectName
mmorgantaylor Oct 30, 2024
814e835
temporarly add feature branch and remove java stuff from tag-publish
mmorgantaylor Oct 30, 2024
ec247da
cleanup
mmorgantaylor Oct 30, 2024
86f7987
remove paths-ignore .github/**
mmorgantaylor Oct 30, 2024
3f7282f
comment to trigger another push
mmorgantaylor Oct 30, 2024
aaac8db
ughh
mmorgantaylor Oct 30, 2024
ecb6801
remove github environment
mmorgantaylor Oct 30, 2024
efc1969
remove unused secret input
mmorgantaylor Oct 30, 2024
c103308
revert changes to tag-publish gh workflow
mmorgantaylor Oct 30, 2024
3d49b88
clean up tag-publish
mmorgantaylor Oct 31, 2024
73e7841
change project name for thin client to terra-scientific-pipelines-ser…
mmorgantaylor Oct 31, 2024
c856c27
add to README, fixes to tag-publish
mmorgantaylor Oct 31, 2024
ca9f822
update bumper gha version
mmorgantaylor Oct 31, 2024
02e254e
should use new_tag output of tag-job
mmorgantaylor Oct 31, 2024
c6e2153
more updates to tag-publish
mmorgantaylor Oct 31, 2024
05a49fe
ugh another tag vs new_tag fix
mmorgantaylor Oct 31, 2024
fab6693
hacky extract of semver for python package version
mmorgantaylor Oct 31, 2024
3a7411c
try pypi release with attestations false
mmorgantaylor Oct 31, 2024
5fa6944
updates to GHAs
mmorgantaylor Nov 1, 2024
1f1f67c
properly reference gha job output
mmorgantaylor Nov 1, 2024
30a3839
don't try to overwrite pypi versions
mmorgantaylor Nov 1, 2024
7771e37
remove teaspoons-cli dir and contents
mmorgantaylor Oct 31, 2024
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
76 changes: 76 additions & 0 deletions .github/workflows/release-python-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and publish Python client to PyPI

on:
pull_request:
workflow_call:
inputs:
new-tag:
required: true
type: string
jobs:
params-gen:
runs-on: ubuntu-latest
outputs:
new-tag: ${{ steps.generate-params.outputs.new-tag }}
steps:
- name: Get inputs or use defaults
id: generate-params
run: |
if [ -z ${{ inputs.new-tag }} ]; then
echo "No new tag provided; will run through tasks, but ultimately will not overwrite PyPi version '0.0.0'"
echo "new-tag='0.0.0'" >> $GITHUB_OUTPUT
else
echo "New tag provided: ${{ inputs.new-tag }}"
echo "new-tag=${{ inputs.new-tag }}" >> $GITHUB_OUTPUT
fi

build-n-publish:
name: Build and publish Python client to PyPI
needs: [ params-gen ]
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing (OIDC)
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install openapi-generator-cli
run: npm install @openapitools/openapi-generator-cli -g

- name: set version to 7.9.0
run: openapi-generator-cli version-manager set 7.9.0

- name: Generate Python client
run: |
echo "Generating Python client for version ${{ needs.params-gen.outputs.new-tag }}"
openapi-generator-cli generate \
-i common/openapi.yml \
-g python \
-o teaspoons-client \
--additional-properties=projectName=terra-scientific-pipelines-service-api-client,packageName=teaspoons_client,packageVersion=${{ needs.params-gen.outputs.new-tag }},httpUserAgent=terra-scientific-pipelines-service-api-client/${{ needs.params-gen.outputs.new-tag }}/python

- name: Install pypa/build
working-directory: ./teaspoons-client
run: >-
python -m pip install build --user

- name: Build a binary wheel and a source tarball
working-directory: ./teaspoons-client
run: >-
python -m build --sdist --wheel --outdir dist/ .

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages_dir: ./teaspoons-client/dist
skip_existing: true
attestations: false # https://github.com/pypa/gh-action-pypi-publish/discussions/255
57 changes: 39 additions & 18 deletions .github/workflows/tag-publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Bump, Tag, Publish, and Deploy
# The purpose of the workflow is to:
# 1. Bump the version number and tag the release
# 2. Build and publish the client to Artifactory
# 3. Build docker image and publish to GCR
# 4. Trigger deployment to the dev environment
# 2. Build and publish the python client to PyPi
# 3. Build and publish the client to Artifactory
# 4. Build docker image and publish to GCR
# 5. Trigger deployment to the dev environment
#
# When run on merge to main, it tags and bumps the patch version by default. You can
# bump other parts of the version by putting #major, #minor, or #patch in your commit
Expand Down Expand Up @@ -66,15 +67,12 @@ jobs:
with:
event-name: ${{ github.event_name }}

tag-publish-docker-deploy:
tag-job:
needs: [ bump-check ]
runs-on: ubuntu-latest
permissions:
contents: 'write'
id-token: 'write'
if: needs.bump-check.outputs.is-bump == 'no'
outputs:
tag: ${{ steps.tag.outputs.tag }}
tag: ${{ steps.tag.outputs.new_tag }}
steps:
- name: Set part of semantic version to bump
id: controls
Expand All @@ -97,7 +95,8 @@ jobs:
token: ${{ secrets.BROADBOT_TOKEN }}

- name: Bump the tag to a new version
uses: databiosphere/github-actions/actions/[email protected]
# https://github.com/DataBiosphere/github-actions/tree/master/actions/bumper
uses: databiosphere/github-actions/actions/[email protected]
id: tag
env:
DEFAULT_BUMP: patch
Expand All @@ -109,12 +108,34 @@ jobs:
VERSION_LINE_MATCH: "^gradle.ext.releaseVersion\\s*=\\s*\".*\""
VERSION_SUFFIX: SNAPSHOT

# Publish Python client to PyPI
python-client-job:
needs: [ tag-job ]
uses: ./.github/workflows/release-python-client.yml
if: ${{ github.event_name != 'pull_request' }}
with:
new-tag: ${{ needs.tag-job.outputs.tag }}

# Publish the Java client to Artifactory and deploy the docker image to GCR
publish-docker-deploy:
needs: [ tag-job ]
runs-on: ubuntu-latest
permissions:
contents: 'write'
id-token: 'write'
steps:
- name: Set up AdoptOpenJDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 17

- name: Checkout current code
uses: actions/checkout@v2
with:
ref: ${{ steps.controls.outputs.checkout-branch }}
token: ${{ secrets.BROADBOT_TOKEN }}

- name: Cache Gradle packages
uses: actions/cache@v2
with:
Expand All @@ -127,8 +148,8 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

# Publish client to artifactory
- name: Publish to Artifactory
# Publish Java client to artifactory
- name: Publish Java client to Artifactory
if: ${{ github.event_name != 'pull_request' }}
run: ./gradlew :client:artifactoryPublish --scan
env:
Expand All @@ -153,7 +174,7 @@ jobs:

- name: Construct docker image name and tag
id: image-name
run: echo ::set-output name=name::${GOOGLE_DOCKER_REPOSITORY}/${GOOGLE_PROJECT}/${SERVICE_NAME}/${IMAGE_NAME}:${{ steps.tag.outputs.tag }}
run: echo ::set-output name=name::${GOOGLE_DOCKER_REPOSITORY}/${GOOGLE_PROJECT}/${SERVICE_NAME}/${IMAGE_NAME}:${{ needs.tag-job.outputs.tag }}

- name: Build image locally with jib
run: |
Expand All @@ -169,7 +190,7 @@ jobs:
uses: ncipollo/release-action@v1
id: create_release
with:
tag: ${{ steps.tag.outputs.tag }}
tag: ${{ needs.tag-job.outputs.tag }}

- name: Notify slack on failure
uses: broadinstitute/[email protected]
Expand All @@ -187,22 +208,22 @@ jobs:
report-to-sherlock:
# Report new Teaspoons version to Broad DevOps
uses: broadinstitute/sherlock/.github/workflows/client-report-app-version.yaml@main
needs: [ bump-check, tag-publish-docker-deploy ]
needs: [ bump-check, tag-job, publish-docker-deploy ]
if: ${{ needs.bump-check.outputs.is-bump == 'no' }}
with:
new-version: ${{ needs.tag-publish-docker-deploy.outputs.tag }}
new-version: ${{ needs.tag-job.outputs.tag }}
chart-name: 'tsps'
permissions:
contents: 'read'
id-token: 'write'

set-version-in-dev:
# Put new Teaspoons version in Broad dev environment
uses: broadinstitute/sherlock/.github/workflows/client-set-environment-app-version.yaml@main
needs: [ bump-check, tag-publish-docker-deploy, report-to-sherlock ]
needs: [ bump-check, tag-job, report-to-sherlock ]
if: ${{ needs.bump-check.outputs.is-bump == 'no' && github.event_name != 'pull_request' }}
with:
new-version: ${{ needs.tag-publish-docker-deploy.outputs.tag }}
new-version: ${{ needs.tag-job.outputs.tag }}
chart-name: 'tsps'
environment-name: 'dev'
secrets:
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ GOOGLE_APPLICATION_CREDENTIALS=config/tsps-sa.json in the Run/Debug configuratio
- Run `./gradlew spotlessCheck` to run linter checks
- Run `./gradlew :service:spotlessApply` to apply fix any issues the linter finds

## (Optional) Install pre-commit hooks
### (Optional) Install pre-commit hooks
1. [scripts/git-hooks/pre-commit] has been provided to help ensure all submitted changes are formatted correctly. To install all hooks in [scripts/git-hooks], run:
```bash
git config core.hooksPath scripts/git-hooks
Expand Down Expand Up @@ -146,3 +146,14 @@ To run the test against a specific feature branch:
- If you've updated the end-to-end test in the dsp-resuable-workflows repo, enter either a commit hash or your git
branch name. If you don't need to change the test, leave the default as main.
4. Click the green "Run workflow" button.

## Python clients
We publish a "thin", auto-generated Python client that wraps the Teaspoons APIs. This client is published to
[PyPi](https://pypi.org/project/terra-scientific-pipelines-service-api-client/) and can be installed with
`pip install teaspoons_client`, although this is not meant to be user-facing. The thin api client is generated from
the OpenAPI spec in the `openapi` directory.

Publishing occurs automatically when a new version of the service is deployed, via the
[release-python-client GHA](https://github.com/DataBiosphere/terra-scientific-pipelines-service/blob/main/.github/workflows/release-python-client.yml).

We also have a user-facing, "thick" CLI whose code lives in a separate repository: [DataBiosphere/terra-scientific-pipelines-service-cli](https://github.com/DataBiosphere/terra-scientific-pipelines-service-cli).
13 changes: 0 additions & 13 deletions teaspoons-cli/.env

This file was deleted.

29 changes: 0 additions & 29 deletions teaspoons-cli/LICENSE

This file was deleted.

82 changes: 0 additions & 82 deletions teaspoons-cli/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions teaspoons-cli/build.gradle

This file was deleted.

Loading
Loading