-
Notifications
You must be signed in to change notification settings - Fork 2
Revive project #71
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
Revive project #71
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5b0e735
build: repair k8s build and switch to tilt for local setup
cl3m0 76d1fcd
feat: update project with changes from bettermarks licencing
cl3m0 5817370
fix: adapt documentation
cl3m0 ce0b09a
refactor: remove bettermarks specific test
cl3m0 d50f549
test: add workflow to test cdk8s and tilt
cl3m0 59c5db3
build: move namespace creation to tiltfile
cl3m0 005fd6f
build: remove duplicated dockerfile
cl3m0 f15f008
refactor: ergonomic way of defining Optional
cl3m0 df49dae
docs: removed irrelevant docs
cl3m0 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 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,15 @@ | ||
| # ignore all | ||
| * | ||
|
|
||
| # unignore image-related | ||
| !src/ | ||
| !tests/ | ||
| !alembic.ini | ||
| !SHA.txt | ||
| !LICENSE | ||
| !pytest.ini | ||
| !pyproject.toml | ||
| !README.md | ||
| !uv.lock | ||
| !uvicorn_disable_logging.json | ||
| !VERSION |
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,11 @@ | ||
| [flake8] | ||
| ignore = E203, E266, W503 | ||
| exclude = | ||
| docs | ||
| k8s | ||
| max-line-length = 88 | ||
| max-complexity = 18 | ||
| select = B,C,E,F,W,T4,B9 | ||
| per-file-ignores = | ||
| tests/**.py: E501, F401 | ||
| src/alembic/env.py: F401, E402 |
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,52 @@ | ||
| name: "Python tests" | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: ["main"] | ||
|
|
||
| env: | ||
| SEGMENT: loc00 | ||
| DB_HOST: localhost | ||
| DB_PORT: 5432 | ||
| DB_USER: postgres | ||
| DB_PASSWORD: postgres | ||
| DB_NAME: test_licensing | ||
|
|
||
| jobs: | ||
| pytest: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| services: | ||
| postgres: | ||
| image: postgres:17 | ||
| env: | ||
| POSTGRES_USER: postgres | ||
| POSTGRES_PASSWORD: postgres | ||
| POSTGRES_DB: test_licensing | ||
| ports: ["5432:5432"] | ||
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| with: | ||
| # Install a specific version of uv. | ||
| version: "0.6.3" | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version-file: ".python-version" | ||
|
|
||
| - run: uv sync --dev --frozen | ||
| - run: uv run pytest --cov bm.ucm | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: coverage | ||
| path: htmlcov |
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,58 @@ | ||
| name: Tests k8s | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - k8s/** | ||
| - Tiltfile | ||
| branches: [master] | ||
| push: | ||
| paths: | ||
| - k8s/** | ||
| - Tiltfile | ||
| branches: [master] | ||
|
|
||
| jobs: | ||
| cdk8s-tests: | ||
| runs-on: buildjet-4vcpu-ubuntu-2204 | ||
| defaults: | ||
| run: | ||
| working-directory: ./k8s | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
| - name: Setup node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: k8s/.nvmrc | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| # Build command also run synth, tests to ensure that stack can be build | ||
| - name: Run build | ||
| run: npm run build | ||
|
|
||
| tilt-check: | ||
| runs-on: buildjet-4vcpu-ubuntu-2204 | ||
| needs: | ||
| - cdk8s-tests | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
| - name: Setup node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: k8s/.nvmrc | ||
| - name: Install tilt | ||
| shell: bash | ||
| run: | | ||
| curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash | ||
| - name: Create k8s cluster | ||
| uses: helm/kind-action@v1 | ||
| - name: Check Tilt | ||
| shell: bash | ||
| run: | | ||
| tilt ci |
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
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 @@ | ||
| 3.12.9 |
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 |
|---|---|---|
| @@ -1,62 +1,21 @@ | ||
| SHELL := /bin/bash | ||
|
|
||
| .PHONY: k8s_synth | ||
| k8s_synth: | ||
| .PHONY: synth | ||
| synth: | ||
| (cd k8s && source ${HOME}/.nvm/nvm.sh && nvm use && npm run synth) | ||
|
|
||
| .PHONY: k8s_install | ||
| k8s_install: | ||
| .PHONY: cdk_install | ||
| cdk_install: | ||
| (cd k8s && source ${HOME}/.nvm/nvm.sh && nvm use && npm ci) | ||
|
|
||
| .PHONY: k8s_test | ||
| k8s_test: | ||
| .PHONY: cdk_test | ||
| cdk_test: | ||
| (cd k8s && source ${HOME}/.nvm/nvm.sh && nvm use && npm run test) | ||
|
|
||
| .PHONY: k8s_test_update | ||
| k8s_test_update: | ||
| .PHONY: update_snapshots | ||
| update_snapshots: | ||
| (cd k8s && source ${HOME}/.nvm/nvm.sh && nvm use && npm run test -- -u) | ||
|
|
||
| .PHONY: k8s_pretty | ||
| k8s_pretty: | ||
| .PHONY: cdk_pretty | ||
| cdk_pretty: | ||
| (cd k8s && source ${HOME}/.nvm/nvm.sh && nvm use && npm run prettier) | ||
|
|
||
| .PHONY: init | ||
| init: | ||
| kubectl create namespace licensing || true | ||
| skaffold run --cleanup=false --profile init | ||
|
|
||
| .PHONY: run-api | ||
| run-api: | ||
| skaffold dev --profile run-api | ||
|
|
||
| .PHONY: create-db | ||
| create-db: | ||
| skaffold run --cleanup=false --profile create-db | ||
|
|
||
| .PHONY: pg-port-forward | ||
| pg-port-forward: | ||
| kubectl port-forward service/licensing-db 5433:5432 -n licensing | ||
|
|
||
| .PHONY: run-migration | ||
| run-migration: | ||
| skaffold run --cleanup=false --profile run-migration | ||
|
|
||
| .PHONY: run-event-export | ||
| run-event-export: | ||
| skaffold run --cleanup=false --profile run-event-export | ||
|
|
||
| .PHONY: start | ||
| start: | ||
| make init | ||
| make create-db | ||
| make run-migration | ||
| kubectl wait --for=condition=complete --timeout=120s --namespace=licensing job/licensing-migration | ||
| make run-event-export | ||
| make run-api | ||
|
|
||
| .PHONY: delete | ||
| delete: | ||
| skaffold delete -p init | ||
| skaffold delete -p run-api | ||
| skaffold delete -p create-db | ||
| skaffold delete -p run-event-export |
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
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,73 @@ | ||
| local("make dist", dir="k8s") | ||
|
|
||
| k8s_yaml("k8s/dist/namespace.k8s.yaml") | ||
| k8s_yaml([f for f in listdir(os.path.join("k8s", "dist")) if not "namespace" in f]) | ||
|
|
||
| k8s_resource( | ||
| objects=[ | ||
| "licensing:namespace", | ||
| "licensing:serviceaccount:licensing", | ||
| "licensing:role:licensing", | ||
| "licensing:rolebinding:licensing", | ||
| "licensing-config:configmap:licensing", | ||
| "licensing-db-init-db-script:configmap:licensing", | ||
| "licensing:secret:licensing", | ||
| "event-export:secret:licensing", | ||
| "licensing-ingress:ingress:licensing", | ||
| ], | ||
| new_name="licensing:k8s", | ||
| labels="licensing", | ||
| ) | ||
| k8s_resource( | ||
| "licensing-db", | ||
| labels="licensing", | ||
| resource_deps=["licensing:k8s"], | ||
| port_forwards=["15432:5432"], | ||
| ) | ||
| k8s_resource("licensing-migration", labels="licensing", resource_deps=["licensing-db"]) | ||
| # k8s_resource("licensing-api", labels="licensing", resource_deps=["licensing-migration"], port_forwards=['8000:8000']) | ||
| k8s_resource("licensing-api", labels="licensing", resource_deps=["licensing-migration"]) | ||
| k8s_resource( | ||
| "licensing-event-export", | ||
| labels="licensing", | ||
| resource_deps=["licensing-migration"], | ||
| auto_init=False, | ||
| trigger_mode=TRIGGER_MODE_MANUAL, | ||
| ) | ||
|
|
||
|
|
||
| def build_local(): | ||
| python_version = str(read_file(".python-version")).strip("\n") | ||
| docker_build( | ||
| "licensing", | ||
| ".", | ||
| dockerfile=os.path.join("k8s", "Dockerfile.dev"), | ||
| build_args={"python_version": python_version}, | ||
| ) | ||
|
|
||
|
|
||
| def build_remote(): | ||
| build_info = decode_json( | ||
| local( | ||
| "curl -s https://licensing-{}.bettermarks.com/version".format(SEGMENT), | ||
| quiet=True, | ||
| ) | ||
| ) | ||
| version = build_info["version"] | ||
| print("Use remote version {}".format(version)) | ||
| docker_build( | ||
| "licensing", | ||
| ".", | ||
| dockerfile_contents="FROM 676249682729.dkr.ecr.eu-central-1.amazonaws.com/licensing:{}".format( | ||
| version | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| SEGMENT = os.getenv("OPAL_SEGMENT", "loc00") | ||
| BUILD_LOCAL = SEGMENT.startswith("loc") | ||
|
|
||
| if BUILD_LOCAL: | ||
| build_local() | ||
| else: | ||
| build_remote() | ||
File renamed without changes.
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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| 18.20.4 | ||
| v20 |
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,8 @@ | ||
| dist | ||
| imports | ||
| loc00 | ||
| node_modules | ||
| tests/__snapshots__ | ||
| jest.config.js | ||
| *.yaml | ||
| *.json |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering, if this an opensource project, how/if this is accessible... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed build_remote just before your review