8000 ci: Reorganize CI by LecrisUT · Pull Request #362 · spglib/spglib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ci: Reorganize CI #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 25, 2024
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
22 changes: 21 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: CI
run-name: >
CI (${{ github.event_name }})
${{ github.event_name == 'pull_request' && format('PR#{0}', github.event.number) || '' }}

on:
workflow_dispatch:
Expand Down Expand Up @@ -35,10 +38,24 @@ concurrency:
cancel-in-progress: true

jobs:
pre-commit:
name: pre-commit
uses: ./.github/workflows/step_pre-commit.yaml

tests:
name: test
needs: [ pre-commit ]
uses: ./.github/workflows/step_test.yaml
with:
mask-experimental: ${{ github.event_name == 'push' }}

coverage:
name: 👀 coverage
needs: [ tests ]
uses: ./.github/workflows/step_coverage.yaml

build-wheel:
name: build-wheel
uses: ./.github/workflows/step_build-wheel.yaml
needs: [ tests ]
with:
Expand All @@ -48,10 +65,13 @@ jobs:
cibw_build: ${{ inputs.cibw_build || 'cp311-*' }}

test-docs:
name: 📘 test-docs
needs: [ pre-commit ]
uses: ./.github/workflows/step_test-docs.yaml

pass:
needs: [tests, test-docs, build-wheel]
name: ✅ Pass
needs: [ pre-commit, tests, test-docs, build-wheel, coverage ]
runs-on: ubuntu-latest
steps:
- name: Check all CI jobs
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: release
run-name: Release
name: 🚀 release
run-name: Release ${{ github.ref_name }}

on:
push:
Expand All @@ -9,13 +9,15 @@ on:

jobs:
tests:
name: tests
uses: ./.github/workflows/step_test.yaml
pypi-wheel:
build-wheel:
name: build-wheel
needs: [ tests ]
uses: ./.github/workflows/step_build-wheel.yaml
upload_pypi:
name: Upload to PyPI repository
needs: [ tests, pypi-wheel ]
needs: [ tests, build-wheel ]
runs-on: ubuntu-latest
environment:
name: pypi
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/step_build-wheel.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
name: pypi-wheel
run-name: Spglib PyPI Wheel builds for linux

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
name: build-wheel

permissions:
contents: read
Expand Down Expand Up @@ -34,7 +29,7 @@ on:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
name: 🖥️ ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -64,7 +59,7 @@ jobs:
if: ${{ inputs.upload }}

build_sdist:
name: Build source distribution
name: 🐍 sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/step_coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: 👀 coverage

on:
workflow_call:

permissions:
contents: read

jobs:
ctest:
name: ${{ matrix.coverage }}
runs-on: ubuntu-latest
strategy:
matrix:
coverage: [ unit_tests, c_api, fortran_api ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: lukka/get-cmake@latest
- name: Get test coverage for ${{ matrix.coverage }}
uses: lukka/run-cmake@v10.3
with:
workflowPreset: "ci-coverage-${{ matrix.coverage }}"
- name: Get lcov data
uses: danielealbano/lcov-action@v3
with:
# Note lcov-action prepends and appends wild-cards *. Account for those
# https://github.com/danielealbano/lcov-action/issues/11
remove_patterns: /test/,/cmake-build*/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: ${{ matrix.coverage }} coverage
files: coverage.info
flags: ${{ matrix.coverage }}
verbose: true

pytest:
name: python_api
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Setup spglib
run: |
python -m pip install --upgrade pip
pip install .[test-cov] \
--config-settings=cmake.define.CMAKE_C_COMPILER=gcc \
--config-settings=cmake.define.SPGLIB_TEST_COVERAGE=ON \
--config-settings=build-dir=build
- name: Test pytest with coverage
run: pytest --cov=spglib
- name: Get lcov data
uses: danielealbano/lcov-action@v3
with:
# Note lcov-action prepends and appends wild-cards *. Account for those
# https://github.com/danielealbano/lcov-action/issues/11
remove_patterns: /test/,/cmake-build*/,/tmp/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: python_api coverage
files: coverage.info,.coverage
flags: python_api
verbose: true
20 changes: 20 additions & 0 deletions .github/workflows/step_pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: pre-commit

on:
workflow_call:

permissions:
contents: read

jobs:
pre-commit:
name: Check pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/action@v3.0.0
3 changes: 1 addition & 2 deletions .github/workflows/step_test-docs.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: test-docs
run-name: Run documentation tests
name: 📘 test-docs

on:
workflow_call:
Expand Down
135 changes: 30 additions & 105 deletions .github/workflows/step_test.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
name: test
run-name: Run tests

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

on:
workflow_call:
inputs:
mask-experimental:
type: boolean
default: true
description: Always report experimental test as successful

permissions:
contents: read

jobs:
pre-commit:
name: Check pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/action@v3.0.0

tests:
name: Check ${{ matrix.toolchain }} and Python ${{ matrix.python-version }}
name: >
🖥️ ${{ matrix.os || 'Fedora' }} +
${{ !matrix.os && format('🛠️ {0} +', matrix.toolchain) || '' }}
🐍 ${{ matrix.python-version }}
${{ matrix.experimental && '[🧪 Experimental]' || '' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
container: ${{ !matrix.os && 'ghcr.io/lecrisut/dev-env:main' || '' }}
needs: [ pre-commit ]
continue-on-error: ${{ matrix.experimental || false }}
strategy:
fail-fast: false
matrix:
toolchain: [ gcc, llvm, intel, windows, macos ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12"]
toolchain: [ gcc, llvm, intel ]
python-version: [ "3.8", "3.x" ]
Copy link
Member

Choose a reason for hiding this comment

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

include:
- os: windows-2019
toolchain: windows
# - os: windows-2019
# toolchain: windows
# python-version: "3.x"
- os: macos-11
toolchain: macos
python-version: "3.x"
- os: windows-latest
toolchain: windows
python-version: "3.x"
experimental: true
- os: macos-latest
toolchain: macos
python-version: "3.x"
experimental: true
- python-version: "3.12"
experimental: true
pip-extra-flags: --pre
# - python-version: "3.13"
# experimental: true
# pre: true
steps:
- name: Enable msvc toolchain on windows
uses: ilammy/msvc-dev-cmd@v1
Expand All @@ -70,94 +66,23 @@ jobs:
run: git config --system --add safe.directory '*'
- name: Patch /etc/lsb-release for experimental python
# Mimic Ubuntu in order to be able to download experimental python
run : |
run: |
echo -en 'DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=22.04\nDISTRIB_CODENAME=jammy\nDISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"' >> /etc/lsb-release
if: ${{ !matrix.os && matrix.experimental }}
if: ${{ !matrix.os && matrix.pre }}
- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
allow-prereleases: ${{ matrix.pre || false }}
# TODO: Replace with editable install once configure presets are available
- name: Install python bindings
run: python3 -m pip install ${{ matrix.pip-extra-flags }} .[test]
run: >
python3 -m pip install
${{ matrix.pre && '--pre' }}
.[test]
- uses: lukka/get-cmake@latest
- name: Run CMake configuration for ${{ matrix.toolchain }} toolchain
uses: lukka/run-cmake@v10.3
with:
workflowPreset: "${{ matrix.toolchain }}-ci"

coverage:
name: Check ${{ matrix.coverage_api }} API test coverage
runs-on: ubuntu-latest
needs: [ tests ]
strategy:
matrix:
coverage: [ unit_tests, c_api, fortran_api ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: lukka/get-cmake@latest
- name: Get test coverage for ${{ matrix.coverage }}
uses: lukka/run-cmake@v10.3
with:
workflowPreset: "ci-coverage-${{ matrix.coverage }}"
- name: Get lcov data
uses: danielealbano/lcov-action@v3
with:
# Note lcov-action prepends and appends wild-cards *. Account for those
# https://github.com/danielealbano/lcov-action/issues/11
remove_patterns: /test/,/cmake-build*/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: ${{ matrix.coverage }} coverage
files: coverage.info
flags: ${{ matrix.coverage }}
verbose: true

coverage-pytest:
name: Run python tests with coverage
runs-on: ubuntu-latest
needs: [ tests ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
cache: pip
- name: Setup spglib
run: |
python -m pip install --upgrade pip
pip install .[test-cov] \
--config-settings=cmake.define.CMAKE_C_COMPILER=gcc \
--config-settings=cmake.define.SPGLIB_TEST_COVERAGE=ON \
--config-settings=build-dir=build
- name: Test pytest with coverage
run: pytest --cov=spglib
- name: Get lcov data
uses: danielealbano/lcov-action@v3
with:
# Note lcov-action prepends and appends wild-cards *. Account for those
# https://github.com/danielealbano/lcov-action/issues/11
remove_patterns: /test/,/cmake-build*/,/tmp/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: python api coverage
files: coverage.info,.coverage
flags: python_api
verbose: true
pass:
needs: [pre-commit, tests, coverage, coverage-pytest]
runs-on: ubuntu-latest
steps:
- name: Check test jobs
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
if: always()
continue-on-error: ${{ matrix.experimental && inputs.mask-experimental}}
Loading
0