-
Notifications
You must be signed in to change notification settings - Fork 3
100 lines (94 loc) · 2.89 KB
/
ci.yml
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
name: CI
on:
push:
pull_request:
jobs:
tests:
name: Run tests
strategy:
fail-fast: false
matrix:
python-version: [3.12]
poetry-version: [1.8.3]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v4
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
- name: Install dependencies
run: |
poetry run pip install --upgrade pip
poetry install --all-extras
- name: Run pytest
run: poetry run pytest -q tests -v -s
env:
TINYTICKER_UPDATE_REF_PLOTS: 1
CRYPTOCOMPARE_API_KEY: ${{secrets.CRYPTOCOMPARE_API_KEY}}
GPIOZERO_PIN_FACTORY: mock
- name: Upload plots
uses: actions/upload-artifact@v4
with:
name: tinyticker_plots_${{matrix.python-version}}
path: tests/data/layouts
release:
name: release
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'loiccoyle' }}
needs:
- tests
outputs:
release_created: ${{ steps.release.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
config-file: .github/release-please-config.json
manifest-file: .github/.release-please-manifest.json
publish:
name: Publish to pypi
needs:
- release
if: needs.release.outputs.release_created
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: abatilo/actions-poetry@v3
with:
poetry-version: 1.8.2
- name: Configure Pypi token
shell: bash
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
- name: Publish Package
shell: bash
run: poetry publish --build
trigger_image_build:
name: Trigger tinyticker disk image build
needs:
- publish
if: needs.release.outputs.release_created
runs-on: ubuntu-latest
steps:
- name: Workflow dispatch
run: gh workflow run "Build TinyTicker RPi image" --json --ref refs/heads/main --repo loiccoyle/private.actionsrunner
env:
GH_TOKEN: ${{ secrets.PRIVATE_RUNNER_ACCESS_TOKEN }}