Skip to content

Commit 2e2d97d

Browse files
committed
fix(deps): remove safety==2.3.5 to resolve packaging dependency conflict
Root cause: safety==2.3.5 pins packaging<22.0 while black==23.12.1 requires packaging>=22.0. pip cannot satisfy both constraints simultaneously. This caused ResolutionImpossible across ALL environments: - GitHub CI test job (pip install -r requirements.txt failed) - GitHub Docker build job (Dockerfile RUN pip install failed) - Docker Hub push job (image failed to build) Fix: Removed safety from requirements.txt entirely. safety is a security audit CLI tool β€” it belongs in a separate audit step, not in app deps. To audit manually: pip install safety && safety check fix(ci): rewrite docker-publish.yml to eliminate invalid tag format Root cause: docker/metadata-action with type=sha,prefix={{branch}}- generated tag credify:-<sha> (leading hyphen) on PR events where the branch context is empty, causing: invalid tag: invalid reference format. Fix: Replaced metadata-action with hardcoded clean tags for push events and a separate build-only (push: false) step for PRs. PRs now validate the image builds without attempting any registry operations.
1 parent 28fe85d commit 2e2d97d

3 files changed

Lines changed: 23 additions & 29 deletions

File tree

β€Ž.github/workflows/ci.ymlβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
test:
1111
name: Run Tests
1212
runs-on: ubuntu-latest
13-
continue-on-error: true # Job-level: allows downstream jobs to run even if tests fail
1413

1514
steps:
1615
- name: Checkout code
@@ -33,7 +32,6 @@ jobs:
3332
run: |
3433
python -m pip install --upgrade pip
3534
pip install -r requirements.txt
36-
pip install pytest pytest-cov
3735
3836
- name: Run tests
3937
run: |
@@ -43,7 +41,7 @@ jobs:
4341
name: Build Docker Image
4442
needs: test
4543
runs-on: ubuntu-latest
46-
if: always() # Always run build even if tests had failures
44+
if: always()
4745

4846
steps:
4947
- name: Checkout code
@@ -56,7 +54,7 @@ jobs:
5654
run: |
5755
docker build -t credify:${{ github.sha }} .
5856
59-
- name: Test Docker image
57+
- name: Test Docker image starts correctly
6058
run: |
6159
docker run -d -p 5000:5000 --name test-app \
6260
-e DATABASE_URL=sqlite:////tmp/credify.db \

β€Ž.github/workflows/docker-publish.ymlβ€Ž

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,35 @@ jobs:
1919
uses: docker/setup-buildx-action@v3
2020

2121
- name: Login to Docker Hub
22-
# Only login and push when triggered by a push event (not pull_request).
23-
# Secrets are not available to pull_request workflows from forks,
24-
# and push-to-registry is unsafe from unreviewed PR branches.
22+
# Secrets are NOT available on pull_request events β€” skip login on PRs
2523
if: github.event_name == 'push'
2624
uses: docker/login-action@v3
2725
with:
2826
username: ${{ secrets.DOCKER_USERNAME }}
2927
password: ${{ secrets.DOCKER_TOKEN }}
3028

31-
- name: Extract metadata
32-
id: meta
33-
uses: docker/metadata-action@v5
29+
- name: Build and push Docker image (push event)
30+
# On push: build + push to Docker Hub with clean, valid tags
31+
if: github.event_name == 'push'
32+
uses: docker/build-push-action@v5
3433
with:
35-
images: ${{ secrets.DOCKER_USERNAME }}/credify
34+
context: .
35+
push: true
3636
tags: |
37-
type=ref,event=branch
38-
type=sha,prefix={{branch}}-
39-
type=raw,value=latest,enable={{is_default_branch}}
40-
type=semver,pattern={{version}}
41-
type=semver,pattern={{major}}.{{minor}}
42-
type=raw,value=v2.1.0,enable={{is_default_branch}}
43-
flavor: |
44-
latest=auto
45-
46-
- name: Build and push Docker image
37+
${{ secrets.DOCKER_USERNAME }}/credify:latest
38+
${{ secrets.DOCKER_USERNAME }}/credify:v2.1.0
39+
${{ secrets.DOCKER_USERNAME }}/credify:sha-${{ github.sha }}
40+
cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/credify:buildcache
41+
cache-to: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/credify:buildcache,mode=max
42+
43+
- name: Build only (pull_request validation β€” no push)
44+
# On PR: just validate the image builds cleanly β€” no login, no push
45+
if: github.event_name == 'pull_request'
4746
uses: docker/build-push-action@v5
4847
with:
4948
context: .
50-
# Only push on actual push events β€” NOT on pull_request
51-
push: ${{ github.event_name == 'push' }}
52-
tags: ${{ steps.meta.outputs.tags }}
53-
labels: ${{ steps.meta.outputs.labels }}
54-
cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/credify:buildcache
55-
cache-to: ${{ github.event_name == 'push' && format('type=registry,ref={0}/credify:buildcache,mode=max', secrets.DOCKER_USERNAME) || '' }}
49+
push: false
50+
tags: credify:pr-validate
5651

5752
- name: Image digest
58-
run: echo "βœ… Docker build completed successfully!"
53+
run: echo "βœ… Docker build step completed."

β€Žrequirements.txtβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ flake8==7.0.0
4343
isort==5.13.2
4444
mypy==1.8.0
4545
pre-commit==3.6.0
46-
safety==2.3.5
46+
# safety removed: safety==2.3.5 conflicts with black>=23 (packaging<22 vs packaging>=22)
47+
# Run safety audits separately: pip install safety && safety check

0 commit comments

Comments
Β (0)