Repository navigation
124 lines (107 loc) · 4.09 KB
/
Copy pathtest.yml
File metadata and controls
124 lines (107 loc) · 4.09 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
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- "**"
merge_group:
permissions:
contents: read
concurrency:
group: test-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pytest:
name: Unit tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-24.04
timeout-minutes: 15
strategy:
fail-fast: ${{ github.event_name == 'pull_request' }}
matrix:
python-version: ['3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Set up uv
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
enable-cache: true
- name: Install dependencies
run: uv sync --locked --group dev --python ${{ matrix.python-version }}
- name: Run pytest
id: pytest
env:
COVERAGE_ARGS: ${{ matrix.python-version == '3.12' && '--cov=cloudsmith_cli' || '' }}
run: uv run pytest -m "not integration" ${COVERAGE_ARGS} --junitxml=./reports/pytest.xml
- name: Upload test results
if: ${{ !cancelled() && steps.pytest.outcome != 'skipped' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-results-${{ matrix.python-version }}
path: ./reports/pytest.xml
retention-days: 30
if-no-files-found: error
integration-gate:
name: Check integration credentials
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
available: ${{ steps.credentials.outputs.available }}
steps:
- name: Check integration credentials
id: credentials
env:
API_KEY: ${{ secrets.PYTEST_CLOUDSMITH_API_KEY }}
API_HOST: ${{ vars.PYTEST_CLOUDSMITH_API_HOST }}
ORGANIZATION: ${{ vars.PYTEST_CLOUDSMITH_ORGANIZATION }}
run: |
if [ -n "${API_KEY}" ] && [ -n "${API_HOST}" ] && [ -n "${ORGANIZATION}" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
echo "Skipping live integration tests because credentials are unavailable."
fi
integration:
name: Live integration tests (Python 3.14)
needs: integration-gate
if: needs.integration-gate.outputs.available == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.14"
- name: Set up uv
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
enable-cache: true
- name: Install dependencies
run: uv sync --locked --group dev --python 3.14
- name: Run live integration tests
id: pytest
env:
PYTEST_CLOUDSMITH_API_KEY: ${{ secrets.PYTEST_CLOUDSMITH_API_KEY }}
PYTEST_CLOUDSMITH_API_HOST: ${{ vars.PYTEST_CLOUDSMITH_API_HOST }}
PYTEST_CLOUDSMITH_ORGANIZATION: ${{ vars.PYTEST_CLOUDSMITH_ORGANIZATION }}
PYTEST_CLOUDSMITH_USERNAME: ${{ secrets.PYTEST_CLOUDSMITH_USERNAME }}
PYTEST_CLOUDSMITH_PASSWORD: ${{ secrets.PYTEST_CLOUDSMITH_PASSWORD }}
run: uv run pytest -m integration --junitxml=./reports/pytest.xml
- name: Upload test results
if: ${{ !cancelled() && steps.pytest.outcome != 'skipped' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-results-integration-3.12
path: ./reports/pytest.xml
retention-days: 30
if-no-files-found: error