From bbbc31c32cd7e9c9cd0c4061388d236247704f00 Mon Sep 17 00:00:00 2001 From: Teagan Glenn Date: Sat, 31 Jan 2026 06:40:25 -0700 Subject: [PATCH] Caching dev container --- .github/workflows/pull_request.yml | 54 ++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index c4d8aa7a0..4b6c4c545 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -10,6 +10,8 @@ on: env: DEFAULT_PYTHON: 3.11 + REGISTRY: ghcr.io + DEV_IMAGE_NAME: ${{ github.repository }}-dev jobs: web_lint: @@ -70,6 +72,27 @@ jobs: run: | ruff check frigate migrations docker *.py + devcontainer: + runs_on: ubuntu-latest + name: Build devcontainer + steps: + - name: Check out code + uses: actions/checkout@v6 + with: + persist-credentials: false + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Pre-build devcontainer image + uses: devcontainers/ci@v0.3 + with: + imageName: ${{ env.REGISTRY }}/${{ env.DEV_IMAGE_NAME }}:latest + cacheFrom: ${{ env.REGISTRY }}/${{ env.DEV_IMAGE_NAME }}:latest + push: always + python_tests: runs-on: ubuntu-latest name: Python Tests @@ -78,18 +101,21 @@ jobs: uses: actions/checkout@v6 with: persist-credentials: false - - uses: actions/setup-node@v6 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 with: - node-version: 20.x - - name: Install devcontainer cli - run: npm install --global @devcontainers/cli - - name: Build devcontainer - env: - DOCKER_BUILDKIT: "1" - run: devcontainer build --workspace-folder . - - name: Start devcontainer - run: devcontainer up --workspace-folder . - - name: Run mypy in devcontainer - run: devcontainer exec --workspace-folder . bash -lc "python3 -u -m mypy --config-file frigate/mypy.ini frigate" - - name: Run unit tests in devcontainer - run: devcontainer exec --workspace-folder . bash -lc "python3 -u -m unittest" + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Pre-Run mypy in devcontainer + uses: devcontainers/ci@v0.3 + with: + cacheFrom: ${{ env.REGISTRY }}/${{ env.DEV_IMAGE_NAME }}:latest + push: never + runCmd: python3 -u -m mypy --config-file frigate/mypy.ini frigate + - name: Pre-Run mypy in devcontainer + uses: devcontainers/ci@v0.3 + with: + cacheFrom: ${{ env.REGISTRY }}/${{ env.DEV_IMAGE_NAME }}:latest + push: never + runCmd: python3 -u -m unittest