File: ci.yaml

package info (click to toggle)
pyseventeentrack 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 296 kB
  • sloc: python: 996; sh: 59; makefile: 2
file content (182 lines) | stat: -rw-r--r-- 5,285 bytes parent folder | download
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
name: CI

on:
  pull_request:
    branches:
      - dev
      - master

  push:
    branches:
      - dev
      - master

env:
  CACHE_VERSION: 1
  DEFAULT_PYTHON: "3.12"
  PRE_COMMIT_CACHE: ~/.cache/pre-commit
  UV_CACHE_DIR: /tmp/uv-cache

jobs:
  info:
    name: Collect information & changes data
    outputs:
      pre-commit_cache_key: ${{ steps.generate_pre-commit_cache_key.outputs.key }}
      python_cache_key: ${{ steps.generate_python_cache_key.outputs.key }}
      requirements: ${{ steps.core.outputs.requirements }}
      python_versions: ${{ steps.info.outputs.python_versions }}
    runs-on: ubuntu-22.04
    steps:
      - name: Check out code from GitHub
        uses: actions/checkout@v4.1.7
      - name: Generate partial Python venv restore key
        id: generate_python_cache_key
        run: |
          echo key=venv-${{ env.CACHE_VERSION }}-${{
            hashFiles('requirements_test.txt') }} >> $GITHUB_OUTPUT
      - name: Generate partial pre-commit restore key
        id: generate_pre-commit_cache_key
        run: >-
          echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{
            hashFiles('.pre-commit-config.yaml') }}"  >> $GITHUB_OUTPUT

  pre-commit:
    name: Prepare pre-commit base
    runs-on: ubuntu-22.04
    needs:
      - info
    steps:
      - name: Check out code from GitHub
        uses: actions/checkout@v4.1.7
      - name: Set up Python ${{ env.DEFAULT_PYTHON }}
        id: python
        uses: actions/setup-python@v5.1.1
        with:
          python-version: ${{ env.DEFAULT_PYTHON }}
          check-latest: true
      - name: Restore base Python virtual environment
        id: cache-venv
        uses: actions/cache@v4.2.3
        with:
          path: venv
          key: >-
            ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{
              needs.info.outputs.pre-commit_cache_key }}
      - name: Create Python virtual environment
        if: steps.cache-venv.outputs.cache-hit != 'true'
        run: |
          python -m venv venv
          . venv/bin/activate
          python --version
          pip install "$(grep '^uv' < requirements_test.txt)"
          uv pip install "$(cat requirements_test.txt | grep pre-commit)"
      - name: Restore pre-commit environment from cache
        id: cache-precommit
        uses: actions/cache@v4.2.3
        with:
          path: ${{ env.PRE_COMMIT_CACHE }}
          lookup-only: true
          key: >-
            ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
              needs.info.outputs.pre-commit_cache_key }}
      - name: Install pre-commit dependencies
        if: steps.cache-precommit.outputs.cache-hit != 'true'
        run: |
          . venv/bin/activate
          pre-commit install-hooks

  lint-ruff-format:
    name: Check ruff-format
    runs-on: ubuntu-22.04
    needs:
      - info
      - pre-commit
    steps:
      - name: Check out code from GitHub
        uses: actions/checkout@v4.1.7
      - name: Set up Python ${{ env.DEFAULT_PYTHON }}
        uses: actions/setup-python@v5.1.1
        id: python
        with:
          python-version: ${{ env.DEFAULT_PYTHON }}
          check-latest: true
      - name: Restore base Python virtual environment
        id: cache-venv
        uses: actions/cache/restore@v4.2.3
        with:
          path: venv
          fail-on-cache-miss: true
          key: >-
            ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{
              needs.info.outputs.pre-commit_cache_key }}
      - name: Restore pre-commit environment from cache
        id: cache-precommit
        uses: actions/cache/restore@v4.2.3
        with:
          path: ${{ env.PRE_COMMIT_CACHE }}
          fail-on-cache-miss: true
          key: >-
            ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
              needs.info.outputs.pre-commit_cache_key }}
      - name: Run ruff-format
        run: |
          . venv/bin/activate
          pre-commit run --hook-stage manual ruff-format --all-files --show-diff-on-failure
        env:
          RUFF_OUTPUT_FORMAT: github
  test:
    name: Tests

    runs-on: ubuntu-latest
    needs:
      - lint-ruff-format

    strategy:
      matrix:
        python-version:
          - "3.11"
          - "3.12"

    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
          architecture: x64

      - run: |
          python -m venv venv
          venv/bin/pip install -r requirements_test.txt
          venv/bin/py.test tests/

  coverage:

    name: Test Coverage

    runs-on: ubuntu-latest
    needs:
      - test

    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-python@v4
        with:
          python-version: ${{ env.DEFAULT_PYTHON }}
          architecture: x64

      - run: |
          python -m venv venv
          venv/bin/pip install -r requirements_test.txt
          venv/bin/py.test \
            -s \
            --verbose \
            --cov-report term-missing \
            --cov-report xml \
            --cov=pyseventeentrack tests

      - uses: codecov/codecov-action@v4.0.1
        with:
          token: ${{ secrets.CODECOV_TOKEN }}