summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: 1f0675c2c10d7b8d3f945717aae033ed01ab8c16 (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
name: CI

on:
  push:
  pull_request:

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
    inputs:
      core-dump:
        description: "Set to 1 to enable retrieving core dump from crashes"
        default: "0"
jobs:
  test-linux:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        python-version: ["3.7", "3.10"]

    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
          cache: "pip"
          cache-dependency-path: "requirements*.txt"

      - name: Sets env var for security
        if: (github.event_name == 'pull_request' && contains(github.event.pull_request.body, 'security_test')) || (github.event_name == 'push' && contains(github.event.head_commit.message, 'security_test'))
        run: echo "SECURITY_TESTS=True" >> $GITHUB_ENV

      - name: Install dependencies
        run: |
          pip install --upgrade pip wheel setuptools
          pip install -r requirements-ci.txt
          pip install -e .

      - name: Install security dependencies
        if: contains(env.SECURITY_TESTS, 'True')
        run: |
          wget -O- $TESTSSL_URL$TESTSSL_VER | tar xz
          mv -t deluge/tests/data testssl.sh-$TESTSSL_VER/testssl.sh testssl.sh-$TESTSSL_VER/etc/;
        env:
          TESTSSL_VER: 3.0.6
          TESTSSL_URL: https://codeload.github.com/drwetter/testssl.sh/tar.gz/refs/tags/v

      - name: Setup core dump catch and store
        if: github.event.inputs.core-dump == '1'
        run: |
          sudo mkdir /cores/ && sudo chmod 777 /cores/
          echo "/cores/%E.%p" | sudo tee /proc/sys/kernel/core_pattern
          ulimit -c unlimited
          sudo apt install glibc-tools
          echo "DEBUG_PREFIX=catchsegv python -X dev -m" >> $GITHUB_ENV

      - name: Test with pytest
        run: |
          python -c 'from deluge._libtorrent import lt; print(lt.__version__)';
          $DEBUG_PREFIX pytest -v -m "not (todo or gtkui)" deluge

      - uses: actions/upload-artifact@v3
        # capture all crashes as build artifacts
        if: failure()
        with:
          name: crashes
          path: /cores

  test-windows:
    runs-on: windows-2022
    strategy:
      matrix:
        python-version: ["3.7", "3.10"]

    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
          cache: "pip"
          cache-dependency-path: "requirements*.txt"

      - name: Install dependencies
        run: |
          pip install --upgrade pip wheel setuptools
          pip install -r requirements-ci.txt
          pip install -e .

      - name: Test with pytest
        run: |
          python -c 'import libtorrent as lt; print(lt.__version__)';
          pytest -v -m "not (todo or gtkui or security)" deluge