diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 48d20b8e..9cbd80e9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -6,6 +6,11 @@ FROM ghcr.io/astral-sh/uv:$UV_VERSION AS uv FROM mcr.microsoft.com/vscode/devcontainers/base:debian LABEL maintainer="a5chin " +LABEL org.opencontainers.image.description="Dev Container for Python development with uv-based dependency management and environment configuration." + +ENV PYTHONDONTWRITEBYTECODE=True \ + PYTHONUNBUFFERED=True \ + UV_LINK_MODE=copy # hadolint ignore=DL3008 RUN apt-get update \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9648b96f..4ad01954 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,8 +29,6 @@ }, "containerEnv": { "DISPLAY": "dummy", - "PYTHONUNBUFFERED": "True", - "UV_LINK_MODE": "copy", "UV_PROJECT_ENVIRONMENT": "/home/vscode/.venv" }, "postCreateCommand": "uv sync --frozen", diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml new file mode 100644 index 00000000..712e69cc --- /dev/null +++ b/.github/workflows/devcontainer.yml @@ -0,0 +1,65 @@ +name: Devcontainer + +on: + push: + branches: [main] + paths: + - ".devcontainer/docker-compose.yml" + - ".devcontainer/Dockerfile" + - ".github/workflows/devcontainer.yml" + - ".python-version" + + pull_request: + branches: [main] + paths: + - ".devcontainer/docker-compose.yml" + - ".devcontainer/Dockerfile" + - ".github/workflows/devcontainer.yml" + - ".python-version" + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Lint Dockerfile + uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: .devcontainer/Dockerfile + + build: + runs-on: ubuntu-latest + + needs: lint + if: ${{ success() }} + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker Meta + id: meta + uses: docker/metadata-action@v5 + with: + images: vscode + tags: | + latest + + - name: Build Image for VSCode + uses: docker/build-push-action@v6 + with: + context: . + file: .devcontainer/Dockerfile + push: false + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Compose up vscode + run: docker compose -f '.devcontainer/docker-compose.yml' up -d --build 'vscode' diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3f27c8f5..0400906a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,8 +3,23 @@ name: Docker on: push: branches: [main] + paths: + - ".github/workflows/docker.yml" + - "**.py" + - ".dockerignore" + - ".python-version" + - "pyproject.toml" + - "uv.lock" + pull_request: branches: [main] + paths: + - ".github/workflows/docker.yml" + - "**.py" + - ".dockerignore" + - ".python-version" + - "pyproject.toml" + - "uv.lock" jobs: lint: @@ -19,18 +34,6 @@ jobs: with: dockerfile: Dockerfile - lint-devcontainer: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Lint Dockerfile - uses: hadolint/hadolint-action@v3.1.0 - with: - dockerfile: .devcontainer/Dockerfile - build: runs-on: ubuntu-latest @@ -44,48 +47,20 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push - uses: docker/build-push-action@v6 + - name: Docker Meta + id: meta + uses: docker/metadata-action@v5 with: - context: . - file: Dockerfile - push: false - tags: latest - cache-from: type=gha - cache-to: type=gha,mode=max - - build-devcontainer: - runs-on: ubuntu-latest + images: vscode + tags: | + latest - needs: lint-devcontainer - if: ${{ success() }} - - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push + - name: Build Image uses: docker/build-push-action@v6 with: context: . - file: .devcontainer/Dockerfile + file: Dockerfile push: false - tags: latest + tags: ${{ steps.meta.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max - - compose-devcontainer: - runs-on: ubuntu-latest - - needs: build-devcontainer - if: ${{ success() }} - - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Compose up vscode - run: docker compose -f '.devcontainer/docker-compose.yml' up -d --build 'vscode' diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 599a68bc..3cbb27ce 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -3,8 +3,23 @@ name: Format on: push: branches: [main] + paths: + - ".github/workflows/format.yml" + - "**.py" + - ".python-version" + - "pyproject.toml" + - "ruff.toml" + - "uv.lock" + pull_request: branches: [main] + paths: + - ".github/workflows/format.yml" + - "**.py" + - ".python-version" + - "pyproject.toml" + - "ruff.toml" + - "uv.lock" jobs: ruff: diff --git a/.github/workflows/gh-deploy.yml b/.github/workflows/gh-deploy.yml index 26887e7c..e849d2f0 100644 --- a/.github/workflows/gh-deploy.yml +++ b/.github/workflows/gh-deploy.yml @@ -3,8 +3,23 @@ name: Docs on: push: branches: [main] + paths: + - ".github/workflows/gh-deploy.yml" + - "docs" + - ".python-version" + - "mkdocs.yml" + - "pyproject.toml" + - "uv.lock" + pull_request: branches: [main] + paths: + - ".github/workflows/gh-deploy.yml" + - "docs" + - ".python-version" + - "mkdocs.yml" + - "pyproject.toml" + - "uv.lock" permissions: contents: write diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9060793f..b56521de 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,8 +3,25 @@ name: Lint on: push: branches: [main] + paths: + - ".github/workflows/lint.yml" + - "**.py" + - ".python-version" + - "pyproject.toml" + - "pyrightconfig.json" + - "ruff.toml" + - "uv.lock" + pull_request: branches: [main] + paths: + - ".github/workflows/lint.yml" + - "**.py" + - ".python-version" + - "pyproject.toml" + - "pyrightconfig.json" + - "ruff.toml" + - "uv.lock" jobs: pyright: diff --git a/.github/workflows/publish-devcontainer.yml b/.github/workflows/publish-devcontainer.yml index 3bcbbf9e..0be9f43b 100644 --- a/.github/workflows/publish-devcontainer.yml +++ b/.github/workflows/publish-devcontainer.yml @@ -6,6 +6,8 @@ on: paths: - ".devcontainer/Dockerfile" - ".github/workflows/publish-devcontainer.yml" + - ".python-version" + workflow_dispatch: env: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a974d465..65609603 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,8 +3,29 @@ name: Test on: push: branches: [main] + paths: + - ".github/workflows/test.yml" + - "**.py" + - ".coveragerc" + - ".env**" + - ".python-version" + - "tests" + - "pyproject.toml" + - "pytest.ini" + - "uv.lock" + pull_request: branches: [main] + paths: + - ".github/workflows/test.yml" + - "**.py" + - ".coveragerc" + - ".env**" + - ".python-version" + - "tests" + - "pyproject.toml" + - "pytest.ini" + - "uv.lock" jobs: coverage: diff --git a/Dockerfile b/Dockerfile index a0f26eb7..90da29c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,9 @@ WORKDIR /app COPY --from=uv /uv /uvx /bin/ COPY pyproject.toml uv.lock ./ -ENV PYTHONDONTWRITEBYTECODE=True -ENV PYTHONUNBUFFERED=True -ENV UV_LINK_MODE=copy +ENV PYTHONDONTWRITEBYTECODE=True \ + PYTHONUNBUFFERED=True \ + UV_LINK_MODE=copy # hadolint ignore=DL3008 RUN apt-get update \