From 4e54a34d87056067c0110c00282f6a3248dc5f6f Mon Sep 17 00:00:00 2001 From: Astounds Date: Sat, 30 May 2026 00:34:34 -0500 Subject: feat: update README and HACKING, lock deps via pip-compile in Docker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use pip-compile --generate-hashes in the Docker build stage so that the runtime stage installs pinned dependencies with verified integrity, ensuring fully reproducible container builds. - Add Docker section to README - Fix Python badge (3.7+ → 3.11+) and outdated docs links - Upgrade pip, setuptools, and wheel in Dockerfile to fix grype findings --- .forgejo/workflows/ci.yaml | 67 +++++++++++++++++++++++++++++++------- .forgejo/workflows/schedule.yaml | 70 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 .forgejo/workflows/schedule.yaml (limited to '.forgejo/workflows') diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index c19e1fc..af1af5a 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -5,6 +5,7 @@ on: branches: [master] pull_request: branches: [master] + workflow_dispatch: env: IMAGE_NAME: rusian/yt-local @@ -12,7 +13,35 @@ env: PLATFORMS: linux/amd64,linux/arm64 jobs: + lock-check: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: "3.11" + + - name: Install pip-tools + run: pip install pip-tools + + - name: Verify lock files are in sync + run: | + pip-compile --generate-hashes pyproject.toml -o /tmp/requirements.lock + diff -qI '^#' requirements.lock /tmp/requirements.lock || { + echo "ERROR: requirements.lock is out of sync. Run: make lock" + exit 1 + } + pip-compile --generate-hashes --extra dev pyproject.toml -o /tmp/requirements-dev.lock + diff -qI '^#' requirements-dev.lock /tmp/requirements-dev.lock || { + echo "ERROR: requirements-dev.lock is out of sync. Run: make lock" + exit 1 + } + test: + needs: lock-check runs-on: ubuntu-latest steps: - name: Checkout code @@ -23,10 +52,16 @@ jobs: with: python-version: "3.11" - - name: Install dependencies + - name: Install pip-tools + run: pip install pip-tools + + - name: Compile lock files run: | - pip install --upgrade pip - pip install -r requirements-dev.txt + pip-compile --generate-hashes pyproject.toml -o requirements.lock + pip-compile --generate-hashes --extra dev pyproject.toml -o requirements-dev.lock + + - name: Install dependencies (pinned) + run: pip-sync requirements-dev.lock - name: Run tests run: pytest -v @@ -34,7 +69,9 @@ jobs: docker: needs: test runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/master' + if: >- + forgejo.event_name == 'workflow_dispatch' || + (forgejo.event_name == 'push' && forgejo.ref == 'refs/heads/master') steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -69,16 +106,24 @@ jobs: - name: Install Grype run: | - curl -sSfL -o grype.tar.gz \ - "https://github.com/anchore/grype/releases/download/v${GRYPE_VERSION}/grype_${GRYPE_VERSION}_linux_amd64.tar.gz" - curl -sSfL -o checksums.txt \ - "https://github.com/anchore/grype/releases/download/v${GRYPE_VERSION}/grype_${GRYPE_VERSION}_checksums.txt" - sha256sum --check --ignore-missing checksums.txt - tar -xzf grype.tar.gz -C /usr/local/bin grype + tarball="grype_${GRYPE_VERSION}_linux_amd64.tar.gz" + base="https://github.com/anchore/grype/releases/download/v${GRYPE_VERSION}" + curl -sSfL -o "$tarball" "$base/$tarball" + curl -sSfL -o checksums.txt "$base/grype_${GRYPE_VERSION}_checksums.txt" + # Verify only the file we downloaded; fail if it isn't checked. + grep " $tarball\$" checksums.txt | sha256sum --check --strict - + tar -xzf "$tarball" -C /usr/local/bin grype grype version - name: Scan image for vulnerabilities - run: grype ${{ env.IMAGE_NAME }}:scan --fail-on critical --output table + run: | + # Full report for visibility (informational, never fails the build). + grype "${IMAGE_NAME}:scan" --output table + # Gate: only fail on vulnerabilities that HAVE a fix available. + # Unfixable base-image CVEs (e.g. the python binary) can't be + # remediated here, so blocking on them would just stall every + # deploy with no action to take. + grype "${IMAGE_NAME}:scan" --only-fixed --fail-on critical -q - name: Build and push (multi-platform) uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 diff --git a/.forgejo/workflows/schedule.yaml b/.forgejo/workflows/schedule.yaml new file mode 100644 index 0000000..37d3e6f --- /dev/null +++ b/.forgejo/workflows/schedule.yaml @@ -0,0 +1,70 @@ +name: Weekly rebuild + +on: + schedule: + - cron: '0 4 * * 1' + workflow_dispatch: + +env: + IMAGE_NAME: rusian/yt-local + GRYPE_VERSION: "0.112.0" + PLATFORMS: linux/amd64,linux/arm64 + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 + + - name: Set up Buildx + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 + + - name: Login to Docker Hub + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 + with: + username: ${{ secrets.DOCKER_REGISTRY_USER }} + password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 + with: + images: ${{ env.IMAGE_NAME }} + tags: | + type=sha,prefix= + type=raw,value=latest + + - name: Build image for scan (amd64 only) + uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 + with: + context: . + load: true + tags: ${{ env.IMAGE_NAME }}:scan + + - name: Install Grype + run: | + tarball="grype_${GRYPE_VERSION}_linux_amd64.tar.gz" + base="https://github.com/anchore/grype/releases/download/v${GRYPE_VERSION}" + curl -sSfL -o "$tarball" "$base/$tarball" + curl -sSfL -o checksums.txt "$base/grype_${GRYPE_VERSION}_checksums.txt" + grep " $tarball\$" checksums.txt | sha256sum --check --strict - + tar -xzf "$tarball" -C /usr/local/bin grype + grype version + + - name: Scan image for vulnerabilities + run: | + grype "${IMAGE_NAME}:scan" --output table + grype "${IMAGE_NAME}:scan" --only-fixed --fail-on critical -q + + - name: Build and push (multi-platform) + uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 + with: + context: . + platforms: ${{ env.PLATFORMS }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} -- cgit v1.2.3