Gitea Actions with Python

Hello, I use actions to test the project on python, I used to do it through github, but when I transferred to gitea and add to actions:

uses: https:/github.com/actions/setup-python@v4
      with:
        python-version: "3.11"

I have a mistake:

The version ‘3.11’ with architecture ‘x64’ was not found for this operating system. %0AThe list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/mainversions-manifest.json

Whole YML file:

name: Lint and check types

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-20.04
    
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python 3.11
      uses: https://github.com/actions/setup-python@v4
      with:
        python-version: "3.11"
  
    - name: Install poetry
      run: |
        pip install pipx
        pipx install poetry        

    - name: Validate the structure of the pyproject.toml
      run: |
        poetry check        

    - name: Verify that poetry.lock is consistent with pyproject.toml
      run: |
        poetry lock --check        
    
    - name: Install dependencies
      run: |
        poetry install        

    - name: Check code formatting by black
      run: |
        poetry run black . --check
                
    - name: Lint code by ruff
      run: |
        poetry run ruff .
                
    - name: Check types by pyright
      run: |
        poetry run pyright        

1 Like

I got the same error with “setup-python@v4”.
A local build with: “act” runs without problems!

act -j build
[build/build]   ✅  Success - Main Test sphinx-build
[build/build] ⭐ Run Post Set up Python 3.11
[build/build]   🐳  docker exec cmd=[node /var/run/act/actions/actions-setup-python@v4/dist/cache-save/index.js] user= workdir=
[build/build]   ✅  Success - Post Set up Python 3.11
[build/build] 🏁  Job succeeded

Did you figure this out? I have the exact same problem.

name: Django CI

on:
  push:
    branches: ["dev"]

jobs:
  ProjectTest:
    runs-on: ubuntu-latest
    container: catthehacker/ubuntu:act-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python 3.10
        uses: actions/setup-python@v3
        with:
          python-version: "3.10.12"

As shown above, add container: catthehacker/ubuntu:act-latest and try again. This works for me.

„Just use another image“ is a pragmatic solution but I’d like to understand the issue behind it. What goes on there?

2 Likes

i’m setting up Gitea and having the same issue when using setup-python.
simply switching to use the catthehacker image does work. but i’m unsatisfied not knowing why. i’ve tried a large variety of variants attempting to replicate creating it but have failed every time.

could someone please help explain how this catthehacker image is provisioned to make it work?

You can also install the python via Alpine package manager. This method works for me.

name: Gitea CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: practice-runner
    steps:
      - uses: actions/checkout@v4
      
      - name: Set up Python and run all tests
        run: |
          # Set up Python and venv
          apk add --no-cache python3 py3-pip
          python3 -m venv /tmp/venv
          . /tmp/venv/bin/activate
          
          # Install dependencies
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install -r requirements-dev.txt
          
          # Run linting
          flake8 .
          
          # Run tests
          pytest