Debian Codegraph @

.github/workflows/tests.yml

raw
1 name: Tests
2
3 on:
4 push:
5 branches:
6 - main
7 tags:
8 - "*"
9 pull_request:
10
11 jobs:
12 tests:
13 runs-on: ${{ matrix.os }}
14 strategy:
15 fail-fast: false
16 matrix:
17 os: ["ubuntu-latest"]
18 python-version: ["3.9", "3.10", "3.11"]
19 nox-session: ["tests"]
20 include:
21 - os: macos-latest
22 python-version: "3.10"
23 nox-session: "tests"
24 - os: ubuntu-latest
25 python-version: "3.10"
26 nox-session: "lint"
27
28 steps:
29 - name: Checkout
30 uses: actions/checkout@v3
31 with:
32 submodules: true
33 fetch-depth: 0
34 - name: Configure Python
35 uses: actions/setup-python@v4
36 with:
37 python-version: ${{ matrix.python-version }}
38 - name: Cache pre-commit environments
39 if: ${{ matrix.nox-session == 'lint' }}
40 uses: actions/cache@v3
41 with:
42 path: ~/.cache/pre-commit
43 key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
44 restore-keys: |
45 ${{ runner.os }}-pre-commit-
46 - name: Install nox
47 run: |
48 python -m pip install -U pip
49 python -m pip install -U nox
50 - name: Run tests
51 run: python -m nox --non-interactive -s ${{ matrix.nox-session }}
52 - name: Upload generated images on failure
53 uses: actions/upload-artifact@v3
54 if: ${{ failure() && matrix.nox-session == 'tests' }}
55 with:
56 name: images-${{ matrix.os }}-${{ matrix.python-version }}
57 path: ./result_images
58
59 build:
60 runs-on: ubuntu-latest
61 steps:
62 - uses: actions/checkout@v3
63 with:
64 fetch-depth: 0
65 - uses: actions/setup-python@v4
66 name: Install Python
67 with:
68 python-version: "3.10"
69 - name: Build sdist and wheel
70 run: |
71 python -m pip install -U pip
72 python -m pip install -U build
73 python -m build .
74 - uses: actions/upload-artifact@v3
75 with:
76 path: dist/*
77
78 upload_pypi:
79 needs: [tests, build]
80 runs-on: ubuntu-latest
81 if: startsWith(github.ref, 'refs/tags/')
82 steps:
83 - uses: actions/download-artifact@v3
84 with:
85 name: artifact
86 path: dist
87
88 - uses: pypa/[email protected]
89 with:
90 user: __token__
91 password: ${{ secrets.pypi_password }}