-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement CMake project #1
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
51ea51a
Add CMake Presets
LecrisUT 4134b6a
Implement basic project structure
LecrisUT 1b07644
Add basic pre-commit
LecrisUT 118f2a0
Implement basic project
LecrisUT 4b244ff
Link project to `fmt`
LecrisUT 209ce5f
Add test-suite
LecrisUT 21f8b87
Add packaging tests
LecrisUT e76609f
Add packaging
LecrisUT d68c83b
Add basic GitHub CI
LecrisUT 400ee75
Add packit packaging
LecrisUT 27da8c9
Add basic tmt plans
LecrisUT 6499953
Add bundled ctest tmt plan
LecrisUT a78254b
Add Find<Package> helpers
LecrisUT 9a0a3b2
Implement Findfmt
LecrisUT af7766d
Add test-suite helpers
LecrisUT 52f648b
Enable packaging tests
LecrisUT 7556491
Add functional test
LecrisUT 76a3925
Add coverage option and codecov CI
LecrisUT 61536a3
Add static-analysis
LecrisUT dd1d383
Mark windows toolchain as experimental
LecrisUT cee25b2
Drop Fedora-37 and EPEL9
LecrisUT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
BasedOnStyle: Google | ||
IndentWidth: 4 | ||
IncludeBlocks: Preserve | ||
AllowShortFunctionsOnASingleLine: Empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Name: cmake-template | ||
Summary: CMake project template | ||
Version: 0.0.0 | ||
Release: %autorelease | ||
License: MIT | ||
URL: https://github.com/LecrisUT/CMake-Template | ||
|
||
Source: https://github.com/LecrisUT/CMake-Template/archive/refs/tags/v%{version}.tar.gz | ||
|
||
BuildRequires: ninja-build | ||
BuildRequires: cmake | ||
BuildRequires: gcc-c++ | ||
BuildRequires: fmt-devel | ||
BuildRequires: catch-devel | ||
Requires: fmt | ||
|
||
%description | ||
CMake project template | ||
|
||
%package devel | ||
Summary: Development files for cmake-template | ||
Requires: cmake-template%{?_isa} = %{version}-%{release} | ||
|
||
%description devel | ||
This package contains libraries and header files for developing | ||
applications that use cmake-template. | ||
|
||
|
||
%prep | ||
%autosetup -n cmake-template-%{version} | ||
|
||
|
||
%build | ||
%cmake \ | ||
-DTEMPLATE_SHARED_LIBS=ON \ | ||
-DTEMPLATE_TESTS=ON | ||
%cmake_build | ||
|
||
|
||
%install | ||
%cmake_install | ||
|
||
|
||
%check | ||
%ctest | ||
|
||
|
||
%files | ||
%doc README.md | ||
%license LICENSE | ||
%{_libdir}/libtemplate.so.* | ||
%{_bindir}/hello | ||
|
||
%files devel | ||
%{_libdir}/libtemplate.so | ||
%{_includedir}/template.h | ||
%{_libdir}/cmake/Template | ||
%{_libdir}/pkgconfig/template.pc | ||
|
||
|
||
%changelog | ||
%autochangelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
summary: | ||
Test the bundled ctests | ||
discover+: | ||
how: fmf | ||
path: test | ||
execute: | ||
how: tmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
discover: | ||
how: fmf | ||
dist-git-source: true | ||
dist-git-extract: cmake-template-*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plan: | ||
import: | ||
url: https://github.com/packit/tmt-plans | ||
ref: main | ||
name: /plans/rpminspect | ||
environment: | ||
RPMINSPECT_EXCLUDE: disttag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
plan: | ||
import: | ||
url: https://github.com/packit/tmt-plans | ||
ref: main | ||
name: /plans/rpmlint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
summary: | ||
Basic smoke tests | ||
discover: | ||
how: fmf | ||
filter: "tag: smoke" | ||
execute: | ||
how: tmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Common test variables | ||
tag: | ||
- smoke | ||
tier: 0 | ||
path: / | ||
|
||
# Define tests | ||
/version: | ||
test: hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: CI | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [ main ] | ||
push: | ||
branches: [ main ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
pre-commit: | ||
uses: ./.github/workflows/step_pre-commit.yaml | ||
|
||
tests: | ||
needs: [ pre-commit ] | ||
uses: ./.github/workflows/step_test.yaml | ||
|
||
static-analysis: | ||
needs: [ pre-commit ] | ||
uses: ./.github/workflows/step_static-analysis.yaml | ||
secrets: | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
|
||
pass: | ||
needs: [ pre-commit, tests, static-analysis ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check all CI jobs | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: release | ||
run-name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" | ||
|
||
jobs: | ||
tests: | ||
uses: ./.github/workflows/step_test.yaml | ||
pypi-wheel: | ||
needs: [ tests ] | ||
uses: ./.github/workflows/step_build-wheel.yaml | ||
upload_pypi: | ||
name: Upload to PyPI repository | ||
needs: [ tests, pypi-wheel ] | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/project/spglib/ | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: artifact | ||
path: dist | ||
- name: Publish package to TestPyPI | ||
if: ${{ contains(github.ref, 'rc') }} | ||
# TODO: Maybe we can move this to main PyPI since it is marked rc | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository_url: https://test.pypi.org/legacy/ | ||
- name: Publish package to PyPI | ||
if: ${{ !contains(github.ref, 'rc') }} | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
release: | ||
needs: [ upload_pypi ] | ||
name: Create release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: softprops/action-gh-release@v1 | ||
with: | ||
name: Spglib ${{ github.ref_name }} | ||
draft: true | ||
prerelease: ${{ contains(github.ref, 'rc') }} | ||
generate_release_notes: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: pre-commit | ||
run-name: Run pre-commits | ||
|
||
on: | ||
workflow_call: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
pre-commit: | ||
name: Check pre-commit | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.x | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: static-analysis | ||
on: | ||
workflow_call: | ||
secrets: | ||
SONAR_TOKEN: | ||
required: true | ||
jobs: | ||
sonar-cloud: | ||
name: Analyze with SonarCloud | ||
runs-on: ubuntu-latest | ||
env: | ||
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python for gcovr | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.x | ||
- name: install gcovr | ||
run: | | ||
pip install gcovr | ||
- name: Install sonar-scanner and build-wrapper | ||
uses: SonarSource/sonarcloud-github-c-cpp@v2 | ||
- name: Run cmake/ctest with sonar build-wrapper | ||
run: | | ||
cmake --preset gcc-ci --fresh -G "Unix Makefiles" | ||
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build --preset gcc-ci | ||
ctest --preset gcc-ci | ||
gcovr --sonarqube > coverage.xml | ||
- name: Run sonar-scanner | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: | | ||
sonar-scanner \ | ||
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \ | ||
--define sonar.coverageReportPaths=coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: test | ||
run-name: Run tests | ||
|
||
on: | ||
workflow_call: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
tests: | ||
name: Check ${{ matrix.toolchain }} toolchain | ||
runs-on: ${{ matrix.os || 'ubuntu-latest' }} | ||
container: ${{ !matrix.os && 'ghcr.io/lecrisut/dev-env:main' || '' }} | ||
continue-on-error: ${{ matrix.experimental || false }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
toolchain: [ gcc, llvm, intel, windows, macos ] | ||
include: | ||
- os: windows-latest | ||
toolchain: windows | ||
experimental: true | ||
- os: macos-latest | ||
toolchain: macos | ||
steps: | ||
- name: Enable msvc toolchain on windows | ||
uses: ilammy/msvc-dev-cmd@v1 | ||
if: contains(matrix.os, 'windows') | ||
- name: Activate Intel compilers | ||
run: | | ||
source /opt/intel/oneapi/setvars.sh | ||
printenv >> $GITHUB_ENV | ||
echo $PATH >> $GITHUB_PATH | ||
if: matrix.toolchain == 'intel' | ||
- uses: actions/checkout@v4 | ||
- uses: lukka/get-cmake@latest | ||
- name: Run CMake configuration for ${{ matrix.toolchain }} toolchain | ||
uses: lukka/[email protected] | ||
with: | ||
workflowPreset: "${{ matrix.toolchain }}-ci" | ||
- name: Get lcov data | ||
run: | | ||
lcov -c -d cmake-build-*/ -o coverage.info --include "$(pwd)/src/*" | ||
# TODO: Disabled coverage on non-gcc toolchains. Not sure why it is broken | ||
if: matrix.toolchain == 'gcc' | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: coverage.info | ||
if: matrix.toolchain == 'gcc' | ||
pass: | ||
needs: [ tests ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check test jobs | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## CMake patterns | ||
CMakeUserPresets.json | ||
compile_commands.json | ||
|
||
## Other common pattern | ||
build/ | ||
# Jetbrains default | ||
cmake-build-*/ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of these reusable CI is that they could be imported by other projects as well, assuming they have a similar structure, i.e. each project would only define the
ci.yaml
file and import the step workflows from (this) central project. I am planning to make one forexecutablebooks
as well so they can have a centralized CI to manage.