summaryrefslogtreecommitdiff
path: root/.github/workflows/dependencies.yml
blob: 6490553f7541ec34fe26449ac6811abeab603bb1 (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
107
108
109
name: Dependencies

on:
  schedule:
    # View https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule
    - cron: '0 12 * * *'
  workflow_dispatch:

jobs:
  build:
    if: github.repository == 'rq/rq'
    name: Python${{ matrix.python-version }}/Redis${{ matrix.redis-version }}/redis-py${{ matrix.redis-py-version }}
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        python-version: ["3.6", "3.7", "3.8.3", "3.9", "3.10"]
        redis-version: [3, 4, 5, 6, 7]
        redis-py-version: [3.5.0]

    steps:
    - uses: actions/checkout@v3

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4.5.0
      with:
        python-version: ${{ matrix.python-version }}

    - name: Start Redis
      uses: supercharge/redis-github-action@1.4.0
      with:
        redis-version: ${{ matrix.redis-version }}

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install redis==${{ matrix.redis-py-version }}
        pip install -r requirements.txt -r dev-requirements.txt
        pip install -e .

    - name: Test with pytest
      run: |
        RUN_SLOW_TESTS_TOO=1 pytest --durations=5

  dependency-build:
    name: Check development branches of dependencies
    runs-on: ubuntu-latest
    needs: build
    if: success()

    strategy:
      matrix:
        python-version: ["3.6", "3.7", "3.8.3", "3.9", "3.10"]
        redis-version: [3, 4, 5, 6, 7]

    steps:
    - uses: actions/checkout@v3

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4.5.0
      with:
        python-version: ${{ matrix.python-version }}

    - name: Start Redis
      uses: supercharge/redis-github-action@1.4.0
      with:
        redis-version: ${{ matrix.redis-version }}

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install git+https://github.com/redis/redis-py
        pip install git+https://github.com/pallets/click
        pip install -r dev-requirements.txt
        pip install -e .

    - name: Test with pytest
      run: RUN_SLOW_TESTS_TOO=1 pytest --durations=5 > log.txt 2>&1

    - uses: actions/upload-artifact@v3
      with:
        name: dependencies-error
        path: log.txt
      if: failure()

  issue:
    name: Create failure issue
    runs-on: ubuntu-latest

    if: failure()
    needs: dependency-build

    steps:
    - uses: actions/download-artifact@v3
      with:
        name: dependencies-error
        path: .

    - name: Create failure issue
      run: |
        if [[ "$(curl --url https://api.github.com/repos/${{ github.repository }}/issues?creator=github-actions --request GET)" != *"\""* ]]
          then curl --request POST \
                    --url https://api.github.com/repos/${{ github.repository }}/issues \
                    --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
                    --header 'content-type: application/json' \
                    --data "{
                        \"title\": \"RQ maybe may not work with dependencies in the future\",
                        \"body\": \"This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \n\n View log: \n\n \`\`\` \n $(cat log.txt | while read line; do echo -n "$line\n"; done | sed -r 's/"/\\"/g') \n \`\`\`\"
                      }"
        fi