From 8335d25dbb6279368d6dc650af731e920de5b2ee Mon Sep 17 00:00:00 2001 From: Kevin Blues Date: Thu, 21 Aug 2025 15:54:27 -0700 Subject: [PATCH 1/7] chore: add asdf and just configs --- .tool-versions | 1 + justfile | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .tool-versions create mode 100644 justfile diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..722467c --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +python 3.12.11 diff --git a/justfile b/justfile new file mode 100644 index 0000000..71c0687 --- /dev/null +++ b/justfile @@ -0,0 +1,29 @@ +# https://just.systems + +_default: + @just --list + +HOST := '0.0.0.0' +PORT := '8000' +LOG_CONFIG := 'logging.yaml' + +run: + uv run uvicorn main:api --host {{HOST}} --port {{PORT}} --log-config {{LOG_CONFIG}} + +[group('docker')] +build: + docker build -t kbluescode/dumbkv . + +[group('docker')] +run-image: + docker run --rm -it -p {{PORT}}:{{PORT}} kbluescode/dumbkv + +[group('testing')] +test: + uv run python -m pytest + +DATABASE_URI := 'postgres://postgres:postgres@127.0.0.1/postgres' + +[group('testing')] +test-pg: + uv run python -m pytest -v --database-location={{DATABASE_URI}} From 40985fea4a03f5d18cacb391626e73b3ac48cbcb Mon Sep 17 00:00:00 2001 From: Kevin Blues Date: Thu, 21 Aug 2025 15:55:05 -0700 Subject: [PATCH 2/7] feat(Dockerfile): Install dependencies and run app --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 82f7938..f83bfbb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,9 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-reco RUN uv python install 3.12 -# TODO: Install the python packages and run uvicorn \ No newline at end of file +COPY . /app + +RUN uv sync + +ENV HOST="0.0.0.0" PORT="8000" LOG_CONFIG="logging.yaml" +CMD uv run uvicorn main:api --host $HOST --port $PORT --log-config $LOG_CONFIG From 4094be3b65baf8a56a9c763d650dcd6b87f2d33e Mon Sep 17 00:00:00 2001 From: Kevin Blues Date: Thu, 21 Aug 2025 16:00:10 -0700 Subject: [PATCH 3/7] ci(build.yaml): attempt to build docker image --- .github/workflows/build.yaml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 22d9e9a..d9147dc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -11,7 +11,7 @@ concurrency: env: REGISTRY: ghcr.io # Only used for labeling, if you want to push it make sure you have permissions to push. - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME: kbluescode/dumbkv jobs: build-image: @@ -20,8 +20,12 @@ jobs: permissions: contents: read + # https://github.com/marketplace/actions/build-and-push-docker-images steps: - - name: Checkout - uses: actions/checkout@v4 - - # TODO: Maybe there's an action that does this for us. \ No newline at end of file + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: false + tags: ${{ env.IMAGE_NAME }} From 6db39f0b601bc4e445135af697459ecf17525640 Mon Sep 17 00:00:00 2001 From: Kevin Blues Date: Thu, 21 Aug 2025 16:13:56 -0700 Subject: [PATCH 4/7] ci(build.yaml): temporarily disable build.yaml --- .github/workflows/build.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d9147dc..6107258 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,10 +1,7 @@ name: Build image on: - push: - branches: - - main - pull_request: + workflow_call: # temporarily disable concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 5e7e2ffb6e6581476a654cc347f0974453699f7a Mon Sep 17 00:00:00 2001 From: Kevin Blues Date: Thu, 21 Aug 2025 16:14:15 -0700 Subject: [PATCH 5/7] ci(cicd.yaml): use single file for all CICD on pull requests --- .github/workflows/cicd.yaml | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/cicd.yaml diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml new file mode 100644 index 0000000..eeb6989 --- /dev/null +++ b/.github/workflows/cicd.yaml @@ -0,0 +1,40 @@ +name: CICD + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + +env: + REGISTRY: ghcr.io # Only used for labeling, if you want to push it make sure you have permissions to push. + IMAGE_NAME: kbluescode/dumbkv + +jobs: + build-image: + runs-on: ubuntu-latest + + permissions: + contents: read + + # https://github.com/marketplace/actions/build-and-push-docker-images + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: false + tags: ${{ env.IMAGE_NAME }} + - name: Run tests + + test-image: + needs: build-image + runs-on: ubuntu-latest + permissions: + contents: read + + if: github.event_name == 'pull_request' + steps: + - name: Run pytest + run: docker run --rm -it kbluescode/dumbkv:latest uv run python -m pytest From e5000de177179d2f1431a00323ef5537e3145ac0 Mon Sep 17 00:00:00 2001 From: Kevin Blues Date: Thu, 21 Aug 2025 16:14:58 -0700 Subject: [PATCH 6/7] ci(cicd.yaml): remove leftover step --- .github/workflows/cicd.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index eeb6989..badb5c1 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -26,7 +26,6 @@ jobs: with: push: false tags: ${{ env.IMAGE_NAME }} - - name: Run tests test-image: needs: build-image From 5456b9c8c7a714a9203c01176a5c90e2330fa035 Mon Sep 17 00:00:00 2001 From: Kevin Blues Date: Thu, 21 Aug 2025 16:16:18 -0700 Subject: [PATCH 7/7] test: force CI run for PR --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c193d10..b591174 100644 --- a/README.md +++ b/README.md @@ -110,4 +110,4 @@ The manifests can be saved in a `manifests` directory. ## Monitoring - [ ] Create a service monitor objects for prometheus to scrape the metrics -- [ ] Create a markdown document describing what SLO you would set for this application \ No newline at end of file +- [ ] Create a markdown document describing what SLO you would set for this applicationhi