summaryrefslogtreecommitdiff
path: root/.github/workflows/tests.yml
blob: 52eb0723b91ab11e7c48c93ef0414d50f7af4378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: 'Tests'


on:
  push:
    branches: [ '**' ]
  pull_request:
    branches: [ '**' ]


defaults:
  run:
    shell: bash


jobs:
  test-linux:
    runs-on: ubuntu-latest
    name: 'Linux - Python'
    strategy:
      matrix:
        python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
      fail-fast: false
    env:
      DISPLAY: :0
      PY_MPV_SKIP_TESTS: >-
        test_wait_for_property_event_overflow
    steps:
      - uses: actions/checkout@v4
      - name: 'Install Python'
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: 'Update Packages'
        run: |
          function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }

          execute sudo apt update -y 
          execute sudo apt upgrade -y
      - name: 'Install Dependencies'
        run: |
          function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }

          execute sudo apt install -y libmpv1 xvfb
      - name: 'Start Xvfb'
        run: |
          echo -e "\033[0;34msudo /usr/bin/Xvfb $DISPLAY -screen 0 1920x1080x24 &\033[0m";
          sudo /usr/bin/Xvfb $DISPLAY -screen 0 1920x1080x24 &
      - name: 'Setup Test Environment'
        run: |
          function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
          
          execute python -m venv venv
          execute source venv/bin/activate
          execute python -m pip install --upgrade pip
          execute python -m pip install wheel
          execute python -m pip install -r tests/requirements.txt
      - name: 'Run Python Tests'
        run: |
          function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
          
          execute source venv/bin/activate
          execute xvfb-run python -m unittest

  test-windows:
    runs-on: windows-latest
    name: 'Windows - Python'
    strategy:
      matrix:
        python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
      fail-fast: false
    steps:
      - uses: actions/checkout@v4
      - name: 'Install Python'
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: 'Provide libmpv'
        run: |
          function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }
          
          ARTIFACT="mpv-dev-x86_64-v3-20240121-git-a39f9b6.7z"
          SHA1="0764a4b899a7ebb1476e5b491897c5e2eed8a07f"
          URL="https://sourceforge.net/projects/mpv-player-windows/files/libmpv/$ARTIFACT"
          
          execute curl -L -O "$URL"
          echo -e "\033[0;34mecho -n $SHA1 $ARTIFACT > $ARTIFACT.sha1\033[0m"
          echo -n "$SHA1 $ARTIFACT" > "$ARTIFACT.sha1"
          execute sha1sum --check "$ARTIFACT.sha1"
          execute 7z x "$ARTIFACT"
          execute mv libmpv-2.dll tests
      - name: 'Setup Test Environment'
        run: |
          function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }

          execute python -m venv venv
          execute source venv/Scripts/activate
          execute python -m pip install --upgrade pip
          execute python -m pip install wheel
          execute python -m pip install -r tests/requirements.txt
      - name: 'Run Python Tests'
        run: |
          function execute() { echo -e "\033[0;34m$*\033[0m"; "$@"; }

          execute source venv/Scripts/activate
          execute python -m unittest