-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (129 loc) · 4.18 KB
/
component-test-python.yml
File metadata and controls
132 lines (129 loc) · 4.18 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
name: Test
on:
workflow_call:
inputs:
runner-size:
required: false
type: string
description: 'Runner size for the component-runner-size-converter'
architecture:
required: false
type: string
description: "Runner architecture (x64 or arm64)"
default: "x64"
service-name:
required: false
type: string
description: 'Proper name for your service i.e API Service, Backend Service'
service-emoji:
required: false
type: string
description: 'An emoji to identify your service by :)'
python-version:
required: false
type: string
default: "3.13"
description: 'Python version to use'
test-directory:
required: false
type: string
default: "tests"
description: 'Directory containing test files'
pytest-args:
required: false
type: string
default: ""
description: 'Additional pytest arguments'
docker-compose-path:
required: false
type: string
description: 'File path of the docker compose file'
slack-message-id:
required: false
type: string
description: 'Slack message ID from initialization for updates'
secrets:
SLACK_APP_TOKEN:
required: true
description: 'Slack app token'
TEST_ENV_FILE:
required: false
description: 'Environment variables for tests in .env format'
permissions:
contents: read
actions: read
jobs:
setup:
name: Setup
runs-on: linux-arm64
outputs:
runner-name: ${{ steps.runner.outputs.runner-name }}
steps:
- name: Get runner name
id: runner
uses: monta-app/github-workflows/.github/actions/runner-size-converter@main
with:
runner-size: ${{ inputs.runner-size }}
architecture: ${{ inputs.architecture }}
test:
name: Test
needs: setup
runs-on: ${{ needs.setup.outputs.runner-name }}
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Setup Docker Compose
if: ${{ inputs.docker-compose-path }}
uses: monta-app/github-workflows/.github/actions/docker-compose-setup@main
with:
docker-compose-path: ${{ inputs.docker-compose-path }}
- name: Create .env file from secret
run: |
echo "${{ secrets.TEST_ENV_FILE }}" > .env
echo "Created .env file with $(wc -l < .env) lines"
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ inputs.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Run tests with pytest
id: pytest
run: |
PYTHONPATH=. uv run pytest ${{ inputs.test-directory }} \
--junit-xml=pytest-report.xml \
--html=pytest-report.html \
--self-contained-html \
--tb=short \
-v \
${{ inputs.pytest-args }}
- name: Upload test results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: test-results-python-${{ inputs.python-version }}
path: |
pytest-report.xml
pytest-report.html
retention-days: 7
overwrite: true
- name: Publish result message to slack
uses: monta-app/slack-notifier-cli-action@main
if: always()
with:
job-type: "test"
job-status: ${{ job.status }}
service-name: ${{ inputs.service-name }}
service-emoji: ${{ inputs.service-emoji }}
slack-app-token: ${{ secrets.SLACK_APP_TOKEN }}
slack-channel-id: "C01KL9FUPNK"
slack-message-id: ${{ inputs.slack-message-id }}