Skip to content

Commit 888c669

Browse files
committed
Convert main branch GitHub Action for OpenSUSE 3.6 builds.
1 parent 10adcb5 commit 888c669

File tree

7 files changed

+516
-77
lines changed

7 files changed

+516
-77
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/appveyor.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/codecov.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
name: Tests
2+
3+
# gh-84728: "paths-ignore" is not used to skip documentation-only PRs, because
4+
# it prevents to mark a job as mandatory. A PR cannot be merged if a job is
5+
# mandatory but not scheduled because of "paths-ignore".
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- 'opensuse*'
11+
pull_request:
12+
branches:
13+
- 'opensuse*'
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
check_source:
20+
name: 'Check for source changes'
21+
runs-on: ubuntu-latest
22+
container: opensuse/leap:latest
23+
outputs:
24+
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
25+
run_tests: ${{ steps.check.outputs.run_tests }}
26+
run_hypothesis: ${{ steps.check.outputs.run_hypothesis }}
27+
run_cifuzz: ${{ steps.check.outputs.run_cifuzz }}
28+
config_hash: ${{ steps.config_hash.outputs.hash }}
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Check for source changes
32+
id: check
33+
run: |
34+
if [ -z "$GITHUB_BASE_REF" ]; then
35+
echo "run_tests=true" >> $GITHUB_OUTPUT
36+
else
37+
git fetch origin $GITHUB_BASE_REF --depth=1
38+
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) may be more
39+
# reliable than git diff "origin/$GITHUB_BASE_REF.." (2 dots),
40+
# but it requires to download more commits (this job uses
41+
# "git fetch --depth=1").
42+
#
43+
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) works with Git
44+
# 2.26, but Git 2.28 is stricter and fails with "no merge base".
45+
#
46+
# git diff "origin/$GITHUB_BASE_REF.." (2 dots) should be enough on
47+
# GitHub, since GitHub starts by merging origin/$GITHUB_BASE_REF
48+
# into the PR branch anyway.
49+
#
50+
# https://github.com/python/core-workflow/issues/373
51+
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc|^\.pre-commit-config\.yaml$|\.ruff\.toml$)' && echo "run_tests=true" >> $GITHUB_OUTPUT || true
52+
fi
53+
54+
# Check if we should run hypothesis tests
55+
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
56+
echo $GIT_BRANCH
57+
if $(echo "$GIT_BRANCH" | grep -q -w '3\.\(8\|9\|10\|11\)'); then
58+
echo "Branch too old for hypothesis tests"
59+
echo "run_hypothesis=false" >> $GITHUB_OUTPUT
60+
else
61+
echo "Run hypothesis tests"
62+
echo "run_hypothesis=true" >> $GITHUB_OUTPUT
63+
fi
64+
65+
# oss-fuzz maintains a configuration for fuzzing the main branch of
66+
# CPython, so CIFuzz should be run only for code that is likely to be
67+
# merged into the main branch; compatibility with older branches may
68+
# be broken.
69+
FUZZ_RELEVANT_FILES='(\.c$|\.h$|\.cpp$|^configure$|^\.github/workflows/build\.yml$|^Modules/_xxtestfuzz)'
70+
if [ "$GITHUB_BASE_REF" = "main" ] && [ "$(git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE $FUZZ_RELEVANT_FILES; echo $?)" -eq 0 ]; then
71+
# The tests are pretty slow so they are executed only for PRs
72+
# changing relevant files.
73+
echo "Run CIFuzz tests"
74+
echo "run_cifuzz=true" >> $GITHUB_OUTPUT
75+
else
76+
echo "Branch too old for CIFuzz tests; or no C files were changed"
77+
echo "run_cifuzz=false" >> $GITHUB_OUTPUT
78+
fi
79+
- name: Compute hash for config cache key
80+
id: config_hash
81+
run: |
82+
echo "hash=${{ hashFiles('configure', 'configure.ac', '.github/workflows/build.yml') }}" >> $GITHUB_OUTPUT
83+
- name: Get a list of the changed documentation-related files
84+
if: github.event_name == 'pull_request'
85+
id: changed-docs-files
86+
uses: Ana06/[email protected]
87+
with:
88+
filter: |
89+
Doc/**
90+
Misc/**
91+
.github/workflows/reusable-docs.yml
92+
format: csv # works for paths with spaces
93+
- name: Check for docs changes
94+
if: >-
95+
github.event_name == 'pull_request'
96+
&& steps.changed-docs-files.outputs.added_modified_renamed != ''
97+
id: docs-changes
98+
run: |
99+
echo "run-docs=true" >> "${GITHUB_OUTPUT}"
100+
101+
check-docs:
102+
name: Docs
103+
needs: check_source
104+
if: fromJSON(needs.check_source.outputs.run-docs)
105+
uses: ./.github/workflows/reusable-docs.yml
106+
107+
check_generated_files:
108+
name: 'Check if generated files are up to date'
109+
# Don't use ubuntu-latest but a specific version to make the job
110+
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
111+
runs-on: ubuntu-22.04
112+
container: opensuse/leap:latest
113+
timeout-minutes: 60
114+
needs: check_source
115+
if: needs.check_source.outputs.run_tests == 'true'
116+
steps:
117+
- uses: actions/checkout@v4
118+
- uses: actions/setup-python@v5
119+
with:
120+
python-version: '3.x'
121+
- name: Runner image version
122+
run: echo "IMAGE_VERSION=${ImageVersion}" >> $GITHUB_ENV
123+
- name: Restore config.cache
124+
uses: actions/cache@v4
125+
with:
126+
path: config.cache
127+
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
128+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}-${{ env.pythonLocation }}
129+
- name: Install Dependencies
130+
run: sudo ./.github/workflows/posix-deps-apt.sh
131+
- name: Add ccache to PATH
132+
run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
133+
- name: Configure ccache action
134+
uses: hendrikmuhs/[email protected]
135+
with:
136+
save: false
137+
- name: Check Autoconf and aclocal versions
138+
run: |
139+
grep "Generated by GNU Autoconf 2.71" configure
140+
grep "aclocal 1.16.5" aclocal.m4
141+
grep -q "runstatedir" configure
142+
grep -q "PKG_PROG_PKG_CONFIG" aclocal.m4
143+
- name: Configure CPython
144+
run: |
145+
# Build Python with the libpython dynamic library
146+
./configure --config-cache --with-pydebug --enable-shared
147+
- name: Regenerate leap files
148+
# Same command used by Tools/build/regen-configure.sh ($AUTORECONF)
149+
run: autoreconf -ivf -Werror
150+
- name: Build CPython
151+
run: |
152+
make -j4 regen-all
153+
make regen-stdlib-module-names regen-sbom
154+
- name: Check for changes
155+
run: |
156+
git add -u
157+
changes=$(git status --porcelain)
158+
# Check for changes in regenerated files
159+
if test -n "$changes"; then
160+
echo "Generated files not up to date."
161+
echo "Perhaps you forgot to run make regen-all or build.bat --regen. ;)"
162+
echo "configure files must be regenerated with a specific version of autoconf."
163+
echo "$changes"
164+
echo ""
165+
git diff --staged || true
166+
exit 1
167+
fi
168+
- name: Check exported libpython symbols
169+
run: make smelly
170+
- name: Check limited ABI symbols
171+
run: make check-limited-abi
172+
- name: Check for unsupported C global variables
173+
if: github.event_name == 'pull_request' # $GITHUB_EVENT_NAME
174+
run: make check-c-globals
175+
176+
build_opensuse:
177+
name: 'OpenSUSE'
178+
needs: check_source
179+
if: needs.check_source.outputs.run_tests == 'true'
180+
uses: ./.github/workflows/reusable-opensuse.yml
181+
with:
182+
config_hash: ${{ needs.check_source.outputs.config_hash }}
183+
options: |
184+
../cpython-ro-srcdir/configure \
185+
--config-cache \
186+
--with-pydebug \
187+
--with-openssl=$OPENSSL_DIR
188+
189+
build_opensuse_ssltests:
190+
name: 'OpenSUSE SSL tests with OpenSSL'
191+
runs-on: ubuntu-22.04
192+
container: opensuse/leap:latest
193+
timeout-minutes: 60
194+
needs: check_source
195+
if: needs.check_source.outputs.run_tests == 'true'
196+
strategy:
197+
fail-fast: false
198+
matrix:
199+
openssl_ver: [1.1.1w, 3.0.13, 3.1.5, 3.2.1]
200+
env:
201+
OPENSSL_VER: ${{ matrix.openssl_ver }}
202+
MULTISSL_DIR: ${{ github.workspace }}/multissl
203+
OPENSSL_DIR: ${{ github.workspace }}/multissl/openssl/${{ matrix.openssl_ver }}
204+
LD_LIBRARY_PATH: ${{ github.workspace }}/multissl/openssl/${{ matrix.openssl_ver }}/lib
205+
steps:
206+
- uses: actions/checkout@v4
207+
- name: Runner image version
208+
run: echo "IMAGE_VERSION=${ImageVersion}" >> $GITHUB_ENV
209+
- name: Restore config.cache
210+
uses: actions/cache@v4
211+
with:
212+
path: config.cache
213+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}
214+
- name: Register gcc problem matcher
215+
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
216+
- name: Install Dependencies
217+
run: sudo ./.github/workflows/posix-deps-apt.sh
218+
- name: Configure OpenSSL env vars
219+
run: |
220+
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> $GITHUB_ENV
221+
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> $GITHUB_ENV
222+
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
223+
- name: 'Restore OpenSSL build'
224+
id: cache-openssl
225+
uses: actions/cache@v4
226+
with:
227+
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
228+
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
229+
- name: Install OpenSSL
230+
if: steps.cache-openssl.outputs.cache-hit != 'true'
231+
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux
232+
- name: Add ccache to PATH
233+
run: |
234+
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
235+
- name: Configure ccache action
236+
uses: hendrikmuhs/[email protected]
237+
with:
238+
save: false
239+
- name: Configure CPython
240+
run: ./configure --config-cache --with-pydebug --with-openssl=$OPENSSL_DIR
241+
- name: Build CPython
242+
run: make -j4
243+
- name: Display build info
244+
run: make pythoninfo
245+
- name: SSL tests
246+
run: ./python Lib/test/ssltests.py
247+
248+
all-required-green: # This job does nothing and is only used for the branch protection
249+
name: All required checks pass
250+
if: always()
251+
252+
needs:
253+
- check_source # Transitive dependency, needed to access `run_tests` value
254+
- check-docs
255+
- check_generated_files
256+
- build_opensuse
257+
- build_opensuse_ssltests
258+
259+
runs-on: ubuntu-latest
260+
container: opensuse/leap:latest
261+
262+
steps:
263+
- name: Check whether the needed jobs succeeded or failed
264+
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
265+
with:
266+
allowed-failures: >-
267+
build_opensuse_ssltests,
268+
allowed-skips: >-
269+
${{
270+
!fromJSON(needs.check_source.outputs.run-docs)
271+
&& '
272+
check-docs,
273+
'
274+
|| ''
275+
}}
276+
${{
277+
needs.check_source.outputs.run_tests != 'true'
278+
&& '
279+
check_generated_files,
280+
build_opensuse,
281+
build_opensuse_ssltests,
282+
'
283+
|| ''
284+
}}
285+
${{
286+
!fromJSON(needs.check_source.outputs.run_cifuzz)
287+
&& '
288+
cifuzz,
289+
'
290+
|| ''
291+
}}
292+
${{
293+
!fromJSON(needs.check_source.outputs.run_hypothesis)
294+
&& '
295+
test_hypothesis,
296+
'
297+
|| ''
298+
}}
299+
jobs: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)