|
1 | | -name: Pylint |
| 1 | +name: CI |
2 | 2 |
|
3 | | -on: [push] |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
4 | 12 |
|
5 | 13 | jobs: |
6 | | - build: |
| 14 | + lint: |
| 15 | + name: pre-commit |
7 | 16 | runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: '3.13' |
| 26 | + cache: 'pip' |
| 27 | + |
| 28 | + - name: Install Poetry |
| 29 | + run: | |
| 30 | + python -m pip install --upgrade pip |
| 31 | + python -m pip install pipx |
| 32 | + pipx install poetry |
| 33 | + poetry --version |
| 34 | +
|
| 35 | + - name: Enable in-project venv for better caching |
| 36 | + run: poetry config virtualenvs.in-project true |
| 37 | + |
| 38 | + - name: Cache virtualenv |
| 39 | + uses: actions/cache@v4 |
| 40 | + with: |
| 41 | + path: .venv |
| 42 | + key: venv-${{ runner.os }}-py${{ hashFiles('**/poetry.lock') }} |
| 43 | + restore-keys: | |
| 44 | + venv-${{ runner.os }}- |
| 45 | +
|
| 46 | + - name: Install deps (incl. dev) |
| 47 | + run: poetry install --no-interaction --no-ansi |
| 48 | + |
| 49 | + - name: Run pre-commit on all files |
| 50 | + run: poetry run pre-commit run --all-files |
| 51 | + |
| 52 | + tests: |
| 53 | + name: pytest (matrix) |
| 54 | + runs-on: ubuntu-latest |
| 55 | + needs: lint |
8 | 56 | strategy: |
| 57 | + fail-fast: false |
9 | 58 | matrix: |
10 | | - python-version: ["3.9", "3.x"] |
| 59 | + python-version: ['3.10', '3.x'] |
| 60 | + |
11 | 61 | steps: |
12 | | - - uses: actions/checkout@v4 |
13 | | - - name: Set up Python ${{ matrix.python-version }} |
14 | | - uses: actions/setup-python@v3 |
15 | | - with: |
16 | | - python-version: ${{ matrix.python-version }} |
17 | | - - name: Install dependencies |
18 | | - run: | |
19 | | - python -m pip install --upgrade pip |
20 | | - pip install pylint |
21 | | - - name: Analysing the code with pylint |
22 | | - run: | |
23 | | - pylint $(git ls-files '*.py') |
| 62 | + - name: Checkout |
| 63 | + uses: actions/checkout@v4 |
| 64 | + |
| 65 | + - name: Set up Python ${{ matrix.python-version }} |
| 66 | + uses: actions/setup-python@v5 |
| 67 | + with: |
| 68 | + python-version: ${{ matrix.python-version }} |
| 69 | + cache: 'pip' |
| 70 | + |
| 71 | + - name: Install Poetry |
| 72 | + run: | |
| 73 | + python -m pip install --upgrade pip |
| 74 | + python -m pip install pipx |
| 75 | + pipx install poetry |
| 76 | + poetry --version |
| 77 | +
|
| 78 | + - name: Enable in-project venv for better caching |
| 79 | + run: poetry config virtualenvs.in-project true |
| 80 | + |
| 81 | + - name: Cache virtualenv |
| 82 | + uses: actions/cache@v4 |
| 83 | + with: |
| 84 | + path: .venv |
| 85 | + key: venv-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 86 | + restore-keys: | |
| 87 | + venv-${{ runner.os }}-py${{ matrix.python-version }}- |
| 88 | + venv-${{ runner.os }}- |
| 89 | +
|
| 90 | + - name: Install deps (incl. dev) |
| 91 | + run: poetry install --no-interaction --no-ansi |
| 92 | + |
| 93 | + # If your tests need environment variables, set them here (example): |
| 94 | + # - name: Set test env |
| 95 | + # run: echo "CMIP7_PREP_TEST=1" >> $GITHUB_ENV |
| 96 | + |
| 97 | + - name: Run pytest |
| 98 | + run: poetry run pytest -q |
0 commit comments