Repository navigation
147 lines (129 loc) · 4.91 KB
/
Copy pathlinux-tests.yml
File metadata and controls
147 lines (129 loc) · 4.91 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
name: Linux tests
on:
workflow_call:
inputs:
test-stage:
description: '"unit-integration" runs the unit and integration tests, "functional" the functional and runner tests'
required: true
type: string
python-versions:
required: true
type: string
run-slow-tests:
required: false
default: 'false'
type: string
run-covtest:
required: false
default: 'false'
type: string
jobs:
build_container:
runs-on: ubuntu-26.04
name: Build Linux container
outputs:
image_tag: ${{ steps.dockerfile_hash.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate Dockerfile checksum
id: dockerfile_hash
run: |
DOCKERFILE_HASH=$(find ./.ci/docker/conan-tests -type f -exec sha256sum {} \; | sha256sum | cut -d' ' -f1)
echo "tag=$DOCKERFILE_HASH" >> $GITHUB_OUTPUT
- name: Check if image exists
id: check_image
run: |
if docker manifest inspect ghcr.io/${{ github.repository_owner }}/conan-tests:${{ steps.dockerfile_hash.outputs.tag }} > /dev/null 2>&1; then
echo "status=exists" >> $GITHUB_OUTPUT
else
echo "status=no-image" >> $GITHUB_OUTPUT
fi
- name: Build and push image if not exists
if: steps.check_image.outputs.status == 'no-image'
run: |
docker build -t ghcr.io/${{ github.repository_owner }}/conan-tests:${{ steps.dockerfile_hash.outputs.tag }} -f ./.ci/docker/conan-tests .
docker push ghcr.io/${{ github.repository_owner }}/conan-tests:${{ steps.dockerfile_hash.outputs.tag }}
linux_tests:
needs: build_container
runs-on: ubuntu-26.04
container:
image: ghcr.io/${{ github.repository_owner }}/conan-tests:${{ needs.build_container.outputs.image_tag }}
options: --user conan
strategy:
matrix:
python-version: ${{ fromJson(inputs.python-versions) }}
name: ${{ inputs.test-stage == 'functional' && 'Functional' || 'Unit & Integration' }} Tests (${{ matrix.python-version }})
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
run: |
pyenv global ${{ matrix.python-version }}
python --version
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r conans/requirements.txt
pip install -r conans/requirements_dev.txt
pip install -r conans/requirements_server.txt
pip install meson
- name: Determine tests to run
id: determine_tests
uses: ./.github/actions/determine-tests
with:
test-types: ${{ inputs.test-stage == 'functional' && 'functional' || 'unittests integration' }}
run-slow-tests: ${{ inputs.run-slow-tests }}
run-covtest: ${{ inputs.run-covtest }}
- name: Run tests
uses: ./.github/actions/test-coverage
with:
python-version: ${{ matrix.python-version }}
test-type: ${{ inputs.test-stage }}
tests: ${{ steps.determine_tests.outputs.tests }}
linux_runner_tests:
needs: build_container
if: inputs.test-stage == 'functional'
runs-on: ubuntu-26.04
strategy:
matrix:
# Use modern versions due to docker incompatibility with python <3.8
python-version: ${{ github.event_name != 'pull_request' && fromJson('["3.13", "3.10"]') || fromJson('["3.10"]') }}
name: Runner Tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements_runner*.txt') }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r conans/requirements.txt
pip install -r conans/requirements_dev.txt
pip install -r conans/requirements_server.txt
pip install -r conans/requirements_runner.txt
- name: Run runner tests
uses: ./.github/actions/test-coverage
with:
python-version: ${{ matrix.python-version }}
test-type: runners
tests: '-m docker_runner -rs'
workers: 1