Skip to content

Commit 1116d15

Browse files
committed
ci: remove redundant runs on different python versions, unify env init
1 parent 47e8afb commit 1116d15

5 files changed

Lines changed: 58 additions & 79 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Set up C++ tests
2+
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Fetch upstream release tags
7+
shell: bash
8+
run: git fetch --tags https://github.com/diffpy/libdiffpy.git
9+
10+
- name: Check out CxxTest 4.4
11+
uses: actions/checkout@v6
12+
with:
13+
repository: CxxTest/cxxtest
14+
ref: 191adddb3876ab389c0c856e1c03874bf70f8ee4
15+
path: build/cxxtest
16+
17+
- name: Prepare C++ test configuration
18+
shell: python {0}
19+
run: |
20+
import runpy
21+
runpy.run_path('.github/scripts/configure-tests.py')
22+
23+
- name: Create build environment
24+
uses: conda-incubator/setup-miniconda@v3
25+
with:
26+
activate-environment: test
27+
channels: conda-forge
28+
conda-remove-defaults: "true"
29+
auto-update-conda: false
30+
auto-activate-base: false
31+
python-version: "3.14"
32+
environment-file: build/test-environment.yml
33+
channel-priority: strict
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Configure SCons and CxxTest for the CI matrix."""
1+
"""Configure SCons, CxxTest and the conda environment for CI tests."""
22

33
import json
44
from pathlib import Path
@@ -11,7 +11,7 @@
1111
requirements.append(spec)
1212

1313
Path("build").mkdir(exist_ok=True)
14-
Path("build/matrix-environment.yml").write_text(
14+
Path("build/test-environment.yml").write_text(
1515
json.dumps(
1616
{
1717
"name": "test",

‎.github/workflows/matrix-and-codecov.yml‎

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
name: Matrix and Codecov
22

33
on:
4-
# push:
5-
# branches:
6-
# - main
7-
release:
8-
types:
9-
- prereleased
10-
- published
4+
push:
5+
branches:
6+
- main
7+
8+
workflow_call:
9+
secrets:
10+
CODECOV_TOKEN:
11+
required: false
1112
workflow_dispatch:
1213

1314
concurrency:
1415
group: matrix-${{ github.ref }}
15-
cancel-in-progress: ${{ github.event_name != 'release' }}
16+
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
1617

1718
jobs:
1819
matrix-coverage:
19-
name: C++ tests (${{ matrix.os }}, Python ${{ matrix.python-version }})
20+
name: C++ tests (${{ matrix.os }})
2021
runs-on: ${{ matrix.os }}
2122
timeout-minutes: 45
2223
strategy:
2324
fail-fast: false
2425
matrix:
2526
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
26-
python-version: ["3.12", "3.13", "3.14"]
2727
include:
2828
- os: ubuntu-latest
2929
shell: bash -l {0}
@@ -51,48 +51,21 @@ jobs:
5151
with:
5252
fetch-depth: 0
5353

54-
- name: Fetch upstream release tags
55-
run: git fetch --tags https://github.com/diffpy/libdiffpy.git
56-
57-
# CxxTest is header-only and its generator runs directly from source.
58-
# The conda-forge package is not available on every matrix platform.
59-
- name: Check out CxxTest 4.4
60-
uses: actions/checkout@v6
61-
with:
62-
repository: CxxTest/cxxtest
63-
ref: 191adddb3876ab389c0c856e1c03874bf70f8ee4
64-
path: build/cxxtest
65-
66-
- name: Prepare C++ test configuration
67-
shell: python {0}
68-
run: |
69-
import runpy
70-
runpy.run_path('.github/scripts/configure-matrix.py')
71-
72-
- name: Create build environment
73-
uses: conda-incubator/setup-miniconda@v3
74-
with:
75-
activate-environment: test
76-
channels: conda-forge
77-
conda-remove-defaults: "true"
78-
auto-update-conda: false
79-
auto-activate-base: false
80-
python-version: ${{ matrix.python-version }}
81-
environment-file: build/matrix-environment.yml
82-
channel-priority: strict
54+
- name: Set up C++ tests
55+
uses: ./.github/actions/setup-tests
8356

8457
- name: Build and run C++ tests
8558
run: scons -j${{ matrix.jobs }} build=${{ matrix.build }} test
8659

8760
- name: Generate coverage report
88-
if: runner.os == 'Linux' && matrix.python-version == '3.14'
61+
if: runner.os == 'Linux'
8962
run: >-
9063
gcovr --gcov-executable "$CONDA_PREFIX/bin/gcov"
9164
--root . --filter 'build/coverage-.*/diffpy/'
9265
--xml coverage.xml
9366
9467
- name: Save coverage report
95-
if: runner.os == 'Linux' && matrix.python-version == '3.14'
68+
if: runner.os == 'Linux'
9669
uses: actions/upload-artifact@v4
9770
with:
9871
name: coverage-report
@@ -101,9 +74,7 @@ jobs:
10174

10275
- name: Upload coverage to Codecov
10376
# Fork push builds have no upstream Codecov token; keep their artifact.
104-
if: >-
105-
runner.os == 'Linux' && matrix.python-version == '3.14' &&
106-
github.repository == 'diffpy/libdiffpy'
77+
if: runner.os == 'Linux' && github.repository == 'diffpy/libdiffpy'
10778
uses: codecov/codecov-action@v5
10879
with:
10980
files: coverage.xml

‎.github/workflows/release-github-on-tag.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ jobs:
1919
secrets:
2020
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
2121

22+
matrix:
23+
uses: ./.github/workflows/matrix-and-codecov.yml
24+
secrets:
25+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
26+
2227
release-github:
23-
needs: [check-tag-privilege, check-pat-token-validity]
28+
needs: [check-tag-privilege, check-pat-token-validity, matrix]
2429
uses: scikit-package/release-scripts/.github/workflows/_release-github.yml@v0
2530
secrets:
2631
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}

‎.github/workflows/tests-on-pr.yml‎

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,8 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
- name: Initialize miniconda
25-
uses: conda-incubator/setup-miniconda@v3
26-
with:
27-
activate-environment: test
28-
channels: conda-forge
29-
conda-remove-defaults: "true"
30-
auto-update-conda: false
31-
auto-activate-base: false
32-
33-
- name: Conda config
34-
run: >-
35-
conda config --set always_yes yes
36-
--set changeps1 no
37-
38-
- name: Install requirements
39-
run: >-
40-
conda install
41-
--file requirements/build.txt
42-
--file requirements/conda.txt
43-
--file requirements/tests.txt
44-
45-
- name: Configure SCons for the conda environment
46-
run: |
47-
cat > sconscript.local <<'EOF'
48-
Import('env')
49-
import os
50-
prefix = os.environ['CONDA_PREFIX']
51-
env.Replace(CXX=os.path.join(prefix, 'bin', 'c++'))
52-
env.Prepend(CCFLAGS=['-isystem' + os.path.join(prefix, 'include')])
53-
env.Append(LIBPATH=os.path.join(prefix, 'lib'))
54-
env.Append(LINKFLAGS='-Wl,-rpath,' + os.path.join(prefix, 'lib'))
55-
EOF
24+
- name: Set up C++ tests
25+
uses: ./.github/actions/setup-tests
5626

5727
- name: Build and run C++ tests with coverage
5828
run: |

0 commit comments

Comments
 (0)