Skip to content

Commit

Permalink
Merge pull request #18 from LecrisUT/ci/GH-Action
Browse files Browse the repository at this point in the history
ci: Implement more GitHub actions
  • Loading branch information
LecrisUT authored Dec 14, 2023
2 parents 8852048 + 7add833 commit 69e2f44
Show file tree
Hide file tree
Showing 19 changed files with 224 additions and 51 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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
permissions:
contents: read
checks: write
pull-requests: write

docs:
needs: [ pre-commit ]
uses: ./.github/workflows/step_docs.yaml

pass:
needs: [ pre-commit, tests, docs ]
runs-on: ubuntu-latest
steps:
- name: Check all CI jobs
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
if: always()
23 changes: 16 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
name: release
run-name: Prepare release
run-name: Release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
workflow_dispatch:

jobs:
pre-commit:
uses: ./.github/workflows/step_pre-commit.yaml
tests:
uses: ./.github/workflows/test.yaml
secrets: inherit
needs: [ pre-commit ]
uses: ./.github/workflows/step_test.yaml
permissions:
contents: read
checks: write
pull-requests: write
docs:
needs: [ pre-commit ]
uses: ./.github/workflows/step_docs.yaml

release:
needs: [ tests ]
needs: [ tests, docs ]
name: Create release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: softprops/action-gh-release@v1
with:
name: CMakeExtraUtils ${{ github.ref_name }}
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/step_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: docs
run-name: Run documentation tests

on:
workflow_call:

permissions:
contents: read

jobs:
doc-test:
name: Sphinx-${{ matrix.builder }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental || false }}
strategy:
fail-fast: false
matrix:
builder: [ linkcheck, html ]
include:
# Run default html builder with warnings as error
- builder: html
args: -W
# TODO: Fix documentation and warnings
experimental: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install the project and docs dependencies
run: pip install -e .[docs]
- name: Run sphinx builder ${{ matrix.builder }}
run: sphinx-build -b ${{ matrix.builder }} ${{ matrix.args }} ./docs ./docs/_build
19 changes: 19 additions & 0 deletions .github/workflows/step_pre-commit.yaml
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: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/[email protected]
73 changes: 73 additions & 0 deletions .github/workflows/step_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: test
run-name: Run tests

on:
workflow_call:

permissions:
contents: read

jobs:
tests:
name: CMake ${{ matrix.cmake }}
runs-on: ubuntu-latest
container: ghcr.io/lecrisut/dev-env:main
continue-on-error: ${{ matrix.experimental || false }}
strategy:
fail-fast: false
matrix:
cmake: ["3.20", "latest", "latestrc"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Note: Proper solution is: https://github.com/actions/runner/issues/2033#issuecomment-1598547465
- name: Temporary fix for git permissions
run: |
git config --global --add safe.directory "*"
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions Bot"
- uses: actions/setup-python@v5
with:
python-version: 3.x
# TODO: This will be migrated to standalone actions
- name: Setup tmt environment
run: dnf install -y tmt tmt+report-junit
- uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ matrix.cmake }}
- name: Build and test native CMake
run: |
# Not running presets because of minimum CMake version being tested
cmake -B ./build
ctest --test-dir ./build --output-on-failure
echo "CMakeExtraUtils_ROOT=$(pwd)/build" >> $GITHUB_ENV
# TODO: This will be migrated to standalone actions
- name: Run tmt tests
run: >
tmt --root ./test run --all provision -h local report -h junit --file report.xml
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: JUnit-CMake-${{ matrix.cmake }}
path: report.xml
report:
name: Report JUnit
needs: [ tests ]
permissions:
contents: read
checks: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Download test results
uses: actions/download-artifact@v4
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "*/report.xml"
large_files: true
report_individual_runs: true
report_suite_logs: any
if: always()
18 changes: 0 additions & 18 deletions .github/workflows/test.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ These utilities can be included using both `find_package()` and `ExternalProject
installed on your system:

```cmake
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.20)
find_package(CMakeExtraUtils REQUIRED)
Expand All @@ -25,7 +25,7 @@ project(MyProject
or if you want to download a specific version:

```cmake
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.20)
FetchContet_Declare(CMakeExtraUtils
GIT_REPOSITORY https://github.com/LecriUT/CMakeExtraUtils
Expand Down
16 changes: 15 additions & 1 deletion cmake/CMakePresets-defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"configurePresets": [
{
"name": "default",
"displayName": "Default configuration preset",
"displayName": "Default preset",
"binaryDir": "cmake-build-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": {
Expand All @@ -13,6 +13,16 @@
}
}
],
"testPresets": [
{
"name": "default",
"displayName": "Default preset",
"configurePreset": "default",
"output": {
"outputOnFailure": true
}
}
],
"workflowPresets": [
{
"name": "default",
Expand All @@ -21,6 +31,10 @@
{
"type": "configure",
"name": "default"
},
{
"type": "test",
"name": "default"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion cmake/DynamicVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Calculate the project version from the git tags or `.git_archival.txt` if the so
## Example

```cmake
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.20)
find_package(CMakeExtraUtils REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions cmake/PackageComps.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Export and import targets as individual components. Special components `shared`
The main `CMakeLists.txt` that exports the target:

```cmake
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.20)
project(My_Project)
Expand Down Expand Up @@ -48,7 +48,7 @@ find_components(COMPONENTS my_component)
The user will then be able to use:

```cmake
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.20)
project(Downstream_Project)
Expand Down
4 changes: 2 additions & 2 deletions docs/cmake_modules/DynamicVersion.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# DynamicVersion

:::{include} ../../cmake/DynamicVersion.md
```{include} ../../cmake/DynamicVersion.md
---
start-after: "# [`DynamicVersion.cmake`](DynamicVersion.cmake)"
---
:::
```

:::{dropdown} Full source code

Expand Down
4 changes: 2 additions & 2 deletions docs/cmake_modules/PackageComps.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# PackageComps

:::{include} ../../cmake/PackageComps.md
```{include} ../../cmake/PackageComps.md
---
start-after: "# [`PackageComps.cmake`](PackageComps.cmake)"
---
:::
```

:::{dropdown} Full source code

Expand Down
4 changes: 2 additions & 2 deletions docs/cmake_modules/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CMake modules

:::{toctree}
```{toctree}
---
maxdepth: 1
titlesonly: true
Expand All @@ -9,4 +9,4 @@ glob: true
---
./*
:::
```
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
source_suffix = [".md"]

html_theme = "furo"
html_static_path = ["_static"]

myst_enable_extensions = [
"tasklist",
Expand Down
5 changes: 2 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CMakeExtraUtils is a collection of cmake modules designed to help you manage and
See the [installation guide](install) for details on how to import this project and
[CMake modules](cmake_modules/index) for the modules available.

:::{toctree}
```{toctree}
---
maxdepth: 2
titlesonly: true
Expand All @@ -14,5 +14,4 @@ glob: true
---
install
cmake_modules/index
test
:::
```
2 changes: 1 addition & 1 deletion test/DynamicVersion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.20)

find_package(CMakeExtraUtils REQUIRED)

Expand Down
2 changes: 1 addition & 1 deletion test/PackageComps/simple_provider/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.20)

project(TestProvider VERSION 0.0.0)

Expand Down
2 changes: 1 addition & 1 deletion test/PackageComps/simple_user/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.20)

project(TestUser VERSION 0.0.0)

Expand Down
Loading

0 comments on commit 69e2f44

Please sign in to comment.