Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/actions/setup-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Set up C++ tests

runs:
using: composite
steps:
- name: Fetch upstream release tags
shell: bash
run: git fetch --tags https://github.com/diffpy/libdiffpy.git

- name: Check out CxxTest 4.4
uses: actions/checkout@v6
with:
repository: CxxTest/cxxtest
ref: 191adddb3876ab389c0c856e1c03874bf70f8ee4
path: build/cxxtest

- name: Prepare C++ test configuration
shell: python {0}
run: |
import runpy
runpy.run_path('.github/scripts/configure-tests.py')
- name: Create build environment
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: test
channels: conda-forge
conda-remove-defaults: "true"
auto-update-conda: false
auto-activate-base: false
python-version: "3.14"
environment-file: build/test-environment.yml
channel-priority: strict
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Configure SCons and CxxTest for the CI matrix."""
"""Configure SCons, CxxTest and the conda environment for CI tests."""

import json
from pathlib import Path
Expand All @@ -11,7 +11,7 @@
requirements.append(spec)

Path("build").mkdir(exist_ok=True)
Path("build/matrix-environment.yml").write_text(
Path("build/test-environment.yml").write_text(
json.dumps(
{
"name": "test",
Expand Down
59 changes: 15 additions & 44 deletions .github/workflows/matrix-and-codecov.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name: Matrix and Codecov

on:
# push:
# branches:
# - main
release:
types:
- prereleased
- published
push:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we normally comment out the matrix on merge to main as it was burning too many build minutes (we were running out of free minutes after a few days and had to wait a month for them to reset). However, I am inclined to leave it here for libdiffpy because it is a bit of a tricky build and so testing on all platforms is more than usual important.

branches:
- main

workflow_call:
secrets:
CODECOV_TOKEN:
required: false
workflow_dispatch:

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

jobs:
matrix-coverage:
name: C++ tests (${{ matrix.os }}, Python ${{ matrix.python-version }})
name: C++ tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
python-version: ["3.12", "3.13", "3.14"]
include:
- os: ubuntu-latest
shell: bash -l {0}
Expand Down Expand Up @@ -51,48 +51,21 @@ jobs:
with:
fetch-depth: 0

- name: Fetch upstream release tags
run: git fetch --tags https://github.com/diffpy/libdiffpy.git

# CxxTest is header-only and its generator runs directly from source.
# The conda-forge package is not available on every matrix platform.
- name: Check out CxxTest 4.4
uses: actions/checkout@v6
with:
repository: CxxTest/cxxtest
ref: 191adddb3876ab389c0c856e1c03874bf70f8ee4
path: build/cxxtest

- name: Prepare C++ test configuration
shell: python {0}
run: |
import runpy
runpy.run_path('.github/scripts/configure-matrix.py')
- name: Create build environment
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: test
channels: conda-forge
conda-remove-defaults: "true"
auto-update-conda: false
auto-activate-base: false
python-version: ${{ matrix.python-version }}
environment-file: build/matrix-environment.yml
channel-priority: strict
- name: Set up C++ tests
uses: ./.github/actions/setup-tests

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

- name: Generate coverage report
if: runner.os == 'Linux' && matrix.python-version == '3.14'
if: runner.os == 'Linux'
run: >-
gcovr --gcov-executable "$CONDA_PREFIX/bin/gcov"
--root . --filter 'build/coverage-.*/diffpy/'
--xml coverage.xml
- name: Save coverage report
if: runner.os == 'Linux' && matrix.python-version == '3.14'
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: coverage-report
Expand All @@ -101,9 +74,7 @@ jobs:

- name: Upload coverage to Codecov
# Fork push builds have no upstream Codecov token; keep their artifact.
if: >-
runner.os == 'Linux' && matrix.python-version == '3.14' &&
github.repository == 'diffpy/libdiffpy'
if: runner.os == 'Linux' && github.repository == 'diffpy/libdiffpy'
uses: codecov/codecov-action@v5
with:
files: coverage.xml
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release-github-on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ jobs:
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}

matrix:
uses: ./.github/workflows/matrix-and-codecov.yml
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

release-github:
needs: [check-tag-privilege, check-pat-token-validity]
needs: [check-tag-privilege, check-pat-token-validity, matrix]
uses: scikit-package/release-scripts/.github/workflows/_release-github.yml@v0
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
Expand Down
34 changes: 2 additions & 32 deletions .github/workflows/tests-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,8 @@ jobs:
with:
fetch-depth: 0

- name: Initialize miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: test
channels: conda-forge
conda-remove-defaults: "true"
auto-update-conda: false
auto-activate-base: false

- name: Conda config
run: >-
conda config --set always_yes yes
--set changeps1 no
- name: Install requirements
run: >-
conda install
--file requirements/build.txt
--file requirements/conda.txt
--file requirements/tests.txt
- name: Configure SCons for the conda environment
run: |
cat > sconscript.local <<'EOF'
Import('env')
import os
prefix = os.environ['CONDA_PREFIX']
env.Replace(CXX=os.path.join(prefix, 'bin', 'c++'))
env.Prepend(CCFLAGS=['-isystem' + os.path.join(prefix, 'include')])
env.Append(LIBPATH=os.path.join(prefix, 'lib'))
env.Append(LINKFLAGS='-Wl,-rpath,' + os.path.join(prefix, 'lib'))
EOF
- name: Set up C++ tests
uses: ./.github/actions/setup-tests

- name: Build and run C++ tests with coverage
run: |
Expand Down
Loading