Skip to content

Commit

Permalink
Merge branch 'main' into add-pagination
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Rodrigues dos Santos <[email protected]>
  • Loading branch information
Bruno Rodrigues dos Santos authored Oct 10, 2024
2 parents 4c0a864 + d4d207e commit f6e6593
Show file tree
Hide file tree
Showing 24 changed files with 230 additions and 319 deletions.
141 changes: 136 additions & 5 deletions .github/workflows/container-build-push.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Container Build and Push

on:
Expand All @@ -8,15 +9,145 @@ on:
- v*
pull_request:

defaults:
run:
shell: bash

permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio.
# This is used to complete the identity challenge with sigstore/fulcio.
id-token: write

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build-push:
uses: darbiadev/.github/.github/workflows/docker-build-push.yaml@142663fca1c211af6a7dccf3a57cac48cfc3c017 # v13.0.5
with:
file-name: Dockerfile
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64

runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Install cosign
uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
with:
platforms: ${{ matrix.platform }}

- name: Log in to container registry (${{ env.REGISTRY }})
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: docker_meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=edge
# FIXME: Remove explicit `latest` tag once we start tagging releases
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=sha,format=long
- name: Build and push Docker image
id: docker_build_push
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
builder: ${{ steps.buildx.outputs.name }}
build-args: |
git_sha=${{ github.sha }}
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: ${{ matrix.platform }}
push: ${{ github.ref == 'refs/heads/main' || startswith(github.event.ref, 'refs/tags/v') }}
tags: ${{ steps.docker_meta.outputs.tags }}

# Sign the resulting Docker image digest.
# This will only write to the public Rekor transparency log when the Docker repository is public to avoid leaking
# data. If you would like to publish transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.ref == 'refs/heads/main' || startswith(github.event.ref, 'refs/tags/v') }}
# This step uses the identity token to provision an ephemeral certificate against the sigstore community Fulcio
# instance.
run: cosign sign --yes ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.docker_build_push.outputs.digest }}

- name: Export digest
if: ${{ github.ref == 'refs/heads/main' || startswith(github.event.ref, 'refs/tags/v') }}
run: |
mkdir -p /tmp/digests
digest='${{ steps.docker_build_push.outputs.digest }}'
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
if: ${{ github.ref == 'refs/heads/main' || startswith(github.event.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
if-no-files-found: error
name: digests
path: /tmp/digests/*
retention-days: 1

merge:
if: ${{ github.ref == 'refs/heads/main' || startswith(github.event.ref, 'refs/tags/v') }}
needs:
- build-push

runs-on: ubuntu-24.04
steps:
- name: Download digests
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: digests
path: /tmp/digests

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1

- name: Log in to container registry (${{ env.REGISTRY }})
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: docker_meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=edge
# FIXME: Remove explicit `latest` tag once we start tagging releases
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=sha,format=long
- name: Create manifest list and push
working-directory: /tmp/digests
run: >
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "${DOCKER_METADATA_OUTPUT_JSON}") \
$(printf ' ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: >-
docker buildx imagetools inspect \
'${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.docker_meta.outputs.version }}'
4 changes: 2 additions & 2 deletions .github/workflows/generate-migration-sql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: Checkout (base)
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ github.event.pull_request.base.sha }}

Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
echo "BASE_MIGRATION_REVISION=${base_head}" >>"${GITHUB_ENV}"
- name: Checkout (HEAD)
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
clean: false
ref: ${{ github.event.pull_request.head.sha }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: "Setup PDM"
uses: pdm-project/setup-pdm@568ddd69406b30de1774ec0044b73ae06e716aa4 # v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: "Checkout repository"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: "Setup PDM"
uses: pdm-project/setup-pdm@568ddd69406b30de1774ec0044b73ae06e716aa4 # v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sentry-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: "Checkout repository"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: "Create Sentry release"
uses: getsentry/action-release@e769183448303de84c5a06aaaddf9da7be26d6c7 # v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12-slim@sha256:740d94a19218c8dd584b92f804b1158f85b0d241e5215ea26ed2dcade2b9d138 as builder
FROM python:3.12-slim@sha256:af4e85f1cac90dd3771e47292ea7c8a9830abfabbe4faa5c53f158854c2e819d as builder

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-push (linux/amd64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

RUN pip install -U pip setuptools wheel
RUN pip install pdm
Expand All @@ -22,7 +22,7 @@ ENV GIT_SHA="testing"

CMD ["pdm", "run", "coverage"]

FROM python:3.12-slim@sha256:740d94a19218c8dd584b92f804b1158f85b0d241e5215ea26ed2dcade2b9d138 as prod
FROM python:3.12-slim@sha256:af4e85f1cac90dd3771e47292ea7c8a9830abfabbe4faa5c53f158854c2e819d as prod

Check warning on line 25 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-push (linux/amd64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

# Define Git SHA build argument for sentry
ARG git_sha="development"
Expand Down
29 changes: 0 additions & 29 deletions alembic/versions/587c186d91ee_better_match_information.py

This file was deleted.

23 changes: 0 additions & 23 deletions alembic/versions/a62a93704798_add_distributions.py

This file was deleted.

3 changes: 1 addition & 2 deletions docs/source/database_schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ Database Schema
pending_by text,
finished_by text,
commit_hash text,
fail_reason text,
files jsonb
fail_reason text
);
ALTER TABLE ONLY public.download_urls
Expand Down
4 changes: 2 additions & 2 deletions logging/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ propagate = true
[loggers."sqlalchemy.engine"]
handlers = ["default"]
level = "INFO"
propagate = true
propagate = false

[loggers."sqlalchemy.pool"]
handlers = ["default"]
level = "DEBUG"
propagate = true
propagate = false
25 changes: 25 additions & 0 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ dependencies = [
"structlog-sentry==2.1.0",
"structlog==24.4.0",
"uvicorn[standard]==0.30.3",
"prometheus-client>=0.21.0",
"prometheus-fastapi-instrumentator>=7.0.0",
]
dynamic = ["version"]

Expand Down Expand Up @@ -133,4 +135,3 @@ omit = [

[tool.coverage.report]
fail_under = 100
exclude_also = ["if TYPE_CHECKING:"]
4 changes: 4 additions & 0 deletions src/mainframe/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def get_pypi_client() -> PyPIServices:
return PyPIServices(http_client)


def get_httpx_client(request: Request) -> httpx.Client:
return request.app.state.http_session


def get_rules(request: Request) -> Rules:
return request.app.state.rules

Expand Down
Loading

0 comments on commit f6e6593

Please sign in to comment.