Skip to contentSkip to conversation

Add GitHub Actions CI running the test suite in Docker

PATCH New Tim Orling 1 participant 1 message Oct 17

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

PATCH 1/1 Add GitHub Actions CI running the test suite in Docker

docker/run-tests.sh builds the production image, starts a throwaway MariaDB 10.11 on a private network and runs the full test suite inside the image, so tests/test_update.py can run bitbake on Linux. Test data comes only from migrations and public git repositories; the database password is the public default from docker/settings.py. The script can also be run locally from the repository root.

A separate Safety workflow runs 'safety scan' on 'pip freeze' output from the image, so version ranges in requirements.txt (e.g. Django) cannot hide vulnerable releases. It runs on push, weekly and on demand, so newly published vulnerabilities are reported without a code change, and is skipped when SAFETY_API_KEY is not available.

Also keep local keys, logs, patches and virtualenvs out of the Docker build context.

AI-Generated: Claude Opus 5.5

---
 .dockerignore                |  7 ++++++
 .github/workflows/ci.yml     | 22 +++++++++++++++++++
 .github/workflows/safety.yml | 40 +++++++++++++++++++++++++++++++++++
 .safety-project.ini          |  5 +++++
 docker/run-tests.sh          | 41 ++++++++++++++++++++++++++++++++++++
 5 files changed, 115 insertions(+)
 create mode 100644 .github/workflows/ci.yml
 create mode 100644 .github/workflows/safety.yml
 create mode 100644 .safety-project.ini
 create mode 100755 docker/run-tests.sh
.dockerignore +7 -0
index b9ab463..3b82016 100644
@@ -12,3 +12,10 @@ Dockerfile
 Dockerfile.web
 docker-compose.yml
 dockersetup.py
+*.pem
+*.log
+*.patch
+*.zst
+.venv
+.idea
+.DS_Store
.github/workflows/ci.yml new file +22 -0
new file mode 100644
index 0000000..74405ac
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: MIT
+
+name: CI
+
+on:
+  push:
+    branches: [master,master-next]
+  pull_request:
+    branches: [master]
+
+permissions:
+  contents: read
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    timeout-minutes: 30
+    steps:
+      - uses: actions/checkout@v5
+
+      - name: Build image and run tests
+        run: docker/run-tests.sh
.github/workflows/safety.yml new file +40 -0
new file mode 100644
index 0000000..4840a08
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: MIT
+
+name: Safety
+
+on:
+  push:
+    branches: [master,master-next]
+  schedule:
+    - cron: '0 6 * * 1'
+  workflow_dispatch:
+
+permissions:
+  contents: read
+
+jobs:
+  scan:
+    runs-on: ubuntu-latest
+    timeout-minutes: 15
+    env:
+      SAFETY_API_KEY: ${{ secrets.SAFETY_API_KEY }}
+    # Steps are skipped where the secret isn't set, e.g. other forks.
+    steps:
+      - uses: actions/checkout@v5
+
+      - name: Build image
+        if: env.SAFETY_API_KEY != ''
+        run: docker build -t layerindex-test .
+
+      # Scans the versions actually installed in the image, so ranges in
+      # requirements.txt (e.g. Django) can't hide vulnerable releases.
+      - name: Safety scan
+        if: env.SAFETY_API_KEY != ''
+        run: |
+          mkdir safety-scan
+          cp .safety-project.ini safety-scan/
+          docker run --rm layerindex-test pip3 freeze > safety-scan/requirements.txt
+          # typer pinned: newer releases break safety 3.7.0 ("no active click context")
+          python3 -m venv /tmp/safety
+          /tmp/safety/bin/pip install -q safety==3.7.0 typer==0.23.0
+          /tmp/safety/bin/safety scan --target safety-scan --detailed-output
.safety-project.ini new file +5 -0
new file mode 100644
index 0000000..e7ae822
@@ -0,0 +1,5 @@
+[project]
+id = layerindex-web
+url = /codebases/layerindex-web/findings
+name = layerindex-web
+
docker/run-tests.sh new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.56.0