-
-
Notifications
You must be signed in to change notification settings - Fork 2
163 lines (136 loc) · 4.04 KB
/
workflow.yml
File metadata and controls
163 lines (136 loc) · 4.04 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: CI/CD Pipeline
'on':
pull_request:
push:
tags: ['v*']
env:
LATEST_PYTHON_VERSION: '3.14'
jobs:
lint:
name: Lint (ruff)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: astral-sh/ruff-action@v3
with:
args: "check"
test:
name: Unit Tests
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python ${{ env.LATEST_PYTHON_VERSION }}
run: uv python install ${{ env.LATEST_PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --locked --all-extras --group dev
- name: Run tests with coverage
uses: nick-fields/retry@v3
with:
timeout_minutes: 2
max_attempts: 3
command: uv run --no-sync coverage run -m pytest tests/unit && uv run --no-sync coverage report && uv run --no-sync coverage xml
shell: bash
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
- name: Upload test results to Codecov
uses: codecov/codecov-action@v5
with:
report_type: test_results
integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python ${{ env.LATEST_PYTHON_VERSION }}
run: uv python install ${{ env.LATEST_PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --locked --all-extras --group dev
- name: Run integration tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
command: uv run --no-sync pytest tests/integration
shell: bash
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Lint Dockerfile
uses: hadolint/hadolint-action@v3.1.0
with:
config: .hadolint.yml
- name: Validate compose file
run: |
cp .env.example .env
docker compose -f docker-compose.yml config --quiet
- name: Build base image
run: docker build --target python-base -t discordbot-ci-test .
- name: Smoke test - Python available
run: |
VERSION=$(docker run --rm discordbot-ci-test python --version)
echo "$VERSION"
echo "$VERSION" | grep -q "${{ env.LATEST_PYTHON_VERSION }}"
- name: Smoke test - uv available
run: docker run --rm discordbot-ci-test uv --version
pages:
name: Deploy Pages
runs-on: ubuntu-latest
needs: [test, integration-test]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v6
- name: Prepare docs from README
run: |
{
echo '---'
echo 'layout: default'
echo '---'
echo ''
cat README.md
} > docs/index.md
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: docs/
destination: ./_site
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./_site/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
release:
name: Create Release
runs-on: ubuntu-latest
needs: [test, integration-test]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.ref_name }}
body: |
Automated release for version ${{ github.ref_name }}
draft: false
prerelease: false