Files
Server-scripts/.gitea/workflows/torrent_api.yaml
T

100 lines
2.7 KiB
YAML

name: Torrent API CI
permissions:
contents: read
on:
push:
branches:
- dev
- main
paths:
- "torrent_api/**"
- ".gitea/workflows/torrent_api.yaml"
pull_request:
branches:
- dev
paths:
- "torrent_api/**"
- ".gitea/workflows/torrent_api.yaml"
jobs:
test:
runs-on: ubuntu-latest
container:
image: nikolaik/python-nodejs:python3.12-nodejs20
steps:
- name: Check out the tested commit
uses: actions/checkout@v4
- name: Install torrent-api
working-directory: torrent_api
run: python -m pip install .
- name: Run tests
working-directory: torrent_api
run: python run_tests.py
lint:
runs-on: ubuntu-latest
container:
image: nikolaik/python-nodejs:python3.12-nodejs20
steps:
- name: Check out the tested commit
uses: actions/checkout@v4
- name: Install lint dependencies
working-directory: torrent_api
run: python -m pip install '.[lint]'
- name: Lint torrent-api
working-directory: torrent_api
run: ruff check src tests main.py run_tests.py
build:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs: [test, lint]
runs-on: ubuntu-latest
container:
image: nikolaik/python-nodejs:python3.12-nodejs20
steps:
- name: Check out the tested commit
uses: actions/checkout@v4
- name: Install build dependencies
working-directory: torrent_api
run: python -m pip install '.[build]'
- name: Build one-file executable
working-directory: torrent_api
run: python -m PyInstaller --noconfirm torrent_api.spec
- name: Verify executable
working-directory: torrent_api
run: |
test -x dist/torrent_api
dist/torrent_api --help
- name: Upload executable
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
with:
name: torrent-api-build
path: torrent_api/dist/torrent_api
if-no-files-found: error
install:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs: build
strategy:
fail-fast: false
matrix:
runner:
- vivohost
- quiethost
- serverhost
- mediahost
runs-on: ${{ matrix.runner }}
steps:
- name: Download executable
uses: https://github.com/christopherHX/gitea-download-artifact@v4
with:
name: torrent-api-build
path: dist/
- name: Install torrent_api
run: |
set -euo pipefail
install -d -m 755 "$HOME/tools"
install -m 755 dist/torrent_api "$HOME/tools/torrent_api"