DEV Community

Bidut Sharkar Shemanto
Bidut Sharkar Shemanto

Posted on

GitHub Action CI/CD using UV Package Manager (requirements.txt not required)

I was working in django backend project and wanted to setup github action using uv package manager because I have shifted from pip to uv.

The default template of Django github action is using pip and need requirements.txt file.

The problem is that after add new packages you have to add dependencies each time in requirements.txt file. uv solve this problem.

But I did not find any blog that shows how to write the yml file only using uv. This blog solve this problem, enjoy!:

name: Backend CI/CD Pipeline on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version-file: backend/.python-version - name: Install uv uses: astral-sh/setup-uv@v5 - name: Create virtual environment working-directory: ./backend run: uv venv .venv - name: Install dependencies with uv working-directory: ./backend run: uv sync - name: Run Django tests working-directory: ./backend run: uv run python manage.py test 
Enter fullscreen mode Exit fullscreen mode

uv sync command install the dependencies using the uv.lock file

you have to add uv run in every command related to django, because we are not activating the virtual environment

Top comments (0)