-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (77 loc) · 2.25 KB
/
ci.yml
File metadata and controls
96 lines (77 loc) · 2.25 KB
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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run tests
run: pytest
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run Black formatter
run: black --check --diff .
- name: Run isort
run: isort --check-only --diff .
- name: Run mypy
run: mypy .
tag:
runs-on: ubuntu-latest
permissions:
contents: write
needs: [test, lint]
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.base_ref == 'main')
concurrency:
group: "md-python/tag"
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Tag package
run: |
set -e
# Get build number from GitHub run number
BUILD_NUMBER=${{ github.run_number }}
# Extract version from pyproject.toml
version=$(grep -m1 'version =' pyproject.toml | sed -E 's/version = "([^"]+)"/\1/')
tag=${version}-${BUILD_NUMBER}
# Create and push git tag
git_tag="v${tag}"
echo "Git tag ${git_tag}"
git tag "${git_tag}"
git push origin "${git_tag}"
echo "+++ Git tag: ${git_tag}"