diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6636a81 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,71 @@ +name: Test workflow + +on: + pull_request: + branches: [ "master" ] + +jobs: + set-up-env: + strategy: + matrix: + python-version: [ "3.12" ] # TODO: Add other Python versions + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install dpkg-dev + - name: Set up venv + run: | + python3 -m venv venv + ./venv/bin/activate + pip install pyinotify pyasyncore + - name: Upload venv artifact + uses: actions/upload-artifact@v4 + with: + name: venv-${{ matrix.python-version }} + path: venv + + test-repo: + strategy: + matrix: + python-version: [ "3.12" ] # TODO: Add other Python versions + runs-on: ubuntu-24.04 + needs: [ set-up-env ] + steps: + - uses: actions/checkout@v4 + - name: Download venv artifact + uses: actions/download-artifact@v4 + with: + name: venv-${{ matrix.python-version }} + path: venv + - name: Create and populate config.json + run: | + echo '{ + "architectures": ["amd64", "armhf", "arm64"], + "dists": ["jammy", "noble"], + "short_name": "test_repo", + "description": "Local test repository", + "email": "your_email@domain.com", + "name": "Admin User", + "port": 8645, + "auth": "none" + }' > config.json + - name: Run repo + run: | + chmod -R +xr venv + ./venv/bin/activate + nohup python3 debianrepo -c config.json & + sleep 10 + - name: Test repo usage + run: | + sudo apt-get update && sudo apt-get install wget + wget -qO- http://127.0.0.1:8645/publickey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/local_test.gpg >/dev/null + echo "deb [arch=amd64, signed-by=/usr/share/keyrings/local_test.gpg] http://127.0.0.1:8645/debian noble stable" | sudo tee /etc/apt/sources.list.d/local_test.list + sudo apt-get update + - name: Stop repo + run: kill $(lsof -t -i:8645) +