-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (74 loc) · 2.51 KB
/
build.yaml
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
name: Test, build, and release
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m venv venv
venv/bin/pip install -r requirements.txt
- name: Verify requirements.txt
if: ${{ matrix.python-version == '3.11' }}
run: |
venv/bin/pip-compile --quiet --allow-unsafe --generate-hashes --strip-extras
git diff --exit-code -- requirements.txt
- name: Run lint check
if: ${{ matrix.python-version == '3.11' }}
run: |
venv/bin/ruff format --check obs_common tests
venv/bin/ruff check obs_common tests
- name: Run tests
env:
SENTRY_DSN: http://public@localhost:8090/1
STORAGE_EMULATOR_HOST: http://localhost:8001
run: |
docker compose up -d fakesentry gcs-emulator
venv/bin/pytest tests/
# stop services immediate and ignore errors
docker compose down -t0 || true
- name: License Check
if: ${{ matrix.python-version == '3.11' }}
run: |
venv/bin/pip install -e . --no-deps
venv/bin/license-check
build-and-release:
if: ${{ github.ref == 'refs/heads/main' }}
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --tags origin
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m venv venv
venv/bin/pip install -r requirements.txt
- name: Generate release tag
run: echo RELEASE_TAG="$(venv/bin/python -c 'import obs_common.release; print(obs_common.release.generate_tag())')" >> "$GITHUB_ENV"
- name: Overrride dynamic version
run: sed 's/dynamic = \["version"]/# dynamic = ["version"]\nversion = "'"$RELEASE_TAG"'"/' -i pyproject.toml
- name: Build wheel
run: venv/bin/python -m build
- name: Publish release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "$RELEASE_TAG" --repo="$GITHUB_REPOSITORY" --generate-notes dist/*.whl