This repository has been archived by the owner on Jun 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Mypy Static Type Checking to SDK & Pull latest bentobox-engine im…
…age as build cache (#61) * feat(build): Add mypy to project makefile to lint types when linting SDK * build(sdk): Update requirements-dev.txt to include mypy * refactor(sdk): Fix or ignore errors flagged by mypy. * repo: Add secrets, end of file, trailing whitespace, merge confict and secrets pre commit checks * refactor(ci/cd): Replace docker image caching in favor of just pulling the previous docker image * feat(cd): Also push bentobox-engine to the latest tag on publish-engine job * refactor(build): Execute mypy standalone instead of via python -m * fix(ci): Fix typos causing pull image for cache step to fail, temporary run CD in PR for testing * fix(sdk): Fix failing mypy due by removing unneeded typing-protobuf package * chore(sdk): Remove uneeded type: ignores and clean up types * fix(build): Fix project makefile's lint-sdk failing due to mypy missing type annoatations for protobuf bindings * fix(build): Fix missing cache metadata when required to use pulled images as cache * fix(ci): Fix missing protoc required to run make lint-sdk * refactor(ci): Run lint-sdk as a seperate job from build-test-sdk Simplifies as we do not need to support linting on all OSes. linting only looks for the problems in the codebase which is OS-independent, so linting on one OS should be sufficient * fix(ci): Fix build-test-sdk still install protoc and protoc-gen-mypy not in PATH * fix(cd): Fix missing docker tag bentobox-engine image as latest * chore(ci): Add name to to lint-sdk CI job * fix(ci): Move GITHUB_PATH setting to previous action in job as PATH is only updated for subsequent jobs * refactor(sdk): Bump numpy to 1.20.1 to get builtin type annotations * fix(ci/cd): Use docker buildkit as docker cache from pulled images only works for buildkit images * Revert "refactor(sdk): Bump numpy to 1.20.1 to get builtin type annotations" This reverts commit 95462e1. * fix(ci): Use setup-python to setup python in lint-sdk instead of using runner python * feat(ci/cd): Add cache-from flag to use cached latest image as build cache * fix(build): Fix mypy unable to find generated stubs for Python protobuf bindings * fix(build): Fix mypy unable to find generated stubs for Python protobuf bindings by installing sdk before lint * fix(build): Fix missing dep dependencies when using make install-sdk * chore(cd): Remove temporary on: section used for testing CD pipeline
- Loading branch information
Showing
17 changed files
with
169 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -4,10 +4,13 @@ | |
# | ||
|
||
name: "CD Pipeline" | ||
on: | ||
on: | ||
push: | ||
branches: | ||
- master | ||
env: | ||
DOCKER_REPO: ghcr.io/bentobox-dev/bentobox-engine | ||
DOCKER_BUILDKIT: 1 | ||
jobs: | ||
# builds & publishes docs for the sdk component to Github | ||
publish-docs-sdk: | ||
|
@@ -71,7 +74,7 @@ jobs: | |
- id: resolve-tag | ||
name: "Resolve bentobox-engine container tag" | ||
run: | | ||
DOCKER_TAG=ghcr.io/bentobox-dev/bentobox-engine:$(git describe --long --always) | ||
DOCKER_TAG=$DOCKER_REPO:$(git describe --long --always) | ||
echo $DOCKER_TAG | ||
echo "::set-output name=container-tag::${DOCKER_TAG}" | ||
- name: "Build bentobox-engine" | ||
|
@@ -81,6 +84,7 @@ jobs: | |
make \ | ||
SIM_BUILD_TYPE=Release \ | ||
SIM_DOCKER_STAGE=release \ | ||
SIM_DOCKER_CACHE_FROM="${DOCKER_REPO}:latest" \ | ||
SIM_DOCKER=${DOCKER_TAG} \ | ||
build-sim-docker | ||
- name: "Authenticate with Github Container Registry" | ||
|
@@ -91,8 +95,11 @@ jobs: | |
echo $GHCR_TOKEN | docker login ghcr.io --username $GHCR_USER --password-stdin | ||
- name: "Push bentobox-engine container to Github Container Registry" | ||
run: | | ||
# push with both latest and versioned tag | ||
DOCKER_TAG=${{ steps.resolve-tag.outputs.container-tag }} | ||
docker push $DOCKER_TAG | ||
docker tag $DOCKER_TAG "${DOCKER_REPO}:latest" | ||
docker push "${DOCKER_REPO}:latest" | ||
# deploy the engine component on GKE using the currently built image | ||
deploy-engine: | ||
|
@@ -102,7 +109,7 @@ jobs: | |
env: | ||
PROJECT_ID: ${{ secrets.GKE_PROJECT }} | ||
GKE_CLUSTER: k8s-bentobox-demo | ||
GKE_ZONE: asia-southeast1-c | ||
GKE_ZONE: asia-southeast1-c | ||
steps: | ||
- uses: actions/checkout@v2 | ||
# init gcloud CLI | ||
|
@@ -132,7 +139,7 @@ jobs: | |
git diff | ||
# deploy using kubectl | ||
./kustomize build . | kubectl apply -f - | ||
# build and publish the engine component on github container registry | ||
publish-sdk: | ||
runs-on: ubuntu-20.04 | ||
|
@@ -152,7 +159,7 @@ jobs: | |
# display built artifacts | ||
ls sdk/dist/ | ||
- name: Publish bentobox-sdk to Test PyPI | ||
uses: pypa/[email protected] | ||
uses: pypa/[email protected] | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
packages_dir: sdk/dist/ |
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -341,3 +341,4 @@ sdk/ChangeLog | |
sdk/AUTHORS | ||
sdk/bento/protos/ | ||
sdk/docs/ | ||
sdk/grpc/ |
This file contains 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,17 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: check-merge-conflict | ||
- repo: https://github.com/Yelp/detect-secrets | ||
rev: v0.14.3 | ||
hooks: | ||
- id: detect-secrets | ||
args: ['--baseline', '.secrets.baseline'] | ||
exclude: package.lock.json | ||
- repo: https://github.com/psf/black | ||
rev: 20.8b1 | ||
hooks: | ||
- id: black |
This file contains 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,67 @@ | ||
{ | ||
"custom_plugin_paths": [], | ||
"exclude": { | ||
"files": null, | ||
"lines": null | ||
}, | ||
"generated_at": "2021-02-18T06:17:25Z", | ||
"plugins_used": [ | ||
{ | ||
"name": "AWSKeyDetector" | ||
}, | ||
{ | ||
"name": "ArtifactoryDetector" | ||
}, | ||
{ | ||
"base64_limit": 4.5, | ||
"name": "Base64HighEntropyString" | ||
}, | ||
{ | ||
"name": "BasicAuthDetector" | ||
}, | ||
{ | ||
"name": "CloudantDetector" | ||
}, | ||
{ | ||
"hex_limit": 3, | ||
"name": "HexHighEntropyString" | ||
}, | ||
{ | ||
"name": "IbmCloudIamDetector" | ||
}, | ||
{ | ||
"name": "IbmCosHmacDetector" | ||
}, | ||
{ | ||
"name": "JwtTokenDetector" | ||
}, | ||
{ | ||
"keyword_exclude": null, | ||
"name": "KeywordDetector" | ||
}, | ||
{ | ||
"name": "MailchimpDetector" | ||
}, | ||
{ | ||
"name": "PrivateKeyDetector" | ||
}, | ||
{ | ||
"name": "SlackDetector" | ||
}, | ||
{ | ||
"name": "SoftlayerDetector" | ||
}, | ||
{ | ||
"name": "StripeDetector" | ||
}, | ||
{ | ||
"name": "TwilioKeyDetector" | ||
} | ||
], | ||
"results": {}, | ||
"version": "0.14.3", | ||
"word_list": { | ||
"file": null, | ||
"hash": null | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# | ||
# bentobox engine | ||
# k8s deployment | ||
# | ||
# | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.