Skip to content

Commit 69e2f44

Browse files
authored
Merge pull request #18 from LecrisUT/ci/GH-Action
ci: Implement more GitHub actions
2 parents 8852048 + 7add833 commit 69e2f44

File tree

19 files changed

+224
-51
lines changed

19 files changed

+224
-51
lines changed

.github/workflows/ci.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [ main ]
7+
push:
8+
branches: [ main ]
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
pre-commit:
19+
uses: ./.github/workflows/step_pre-commit.yaml
20+
21+
tests:
22+
needs: [ pre-commit ]
23+
uses: ./.github/workflows/step_test.yaml
24+
permissions:
25+
contents: read
26+
checks: write
27+
pull-requests: write
28+
29+
docs:
30+
needs: [ pre-commit ]
31+
uses: ./.github/workflows/step_docs.yaml
32+
33+
pass:
34+
needs: [ pre-commit, tests, docs ]
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Check all CI jobs
38+
uses: re-actors/alls-green@release/v1
39+
with:
40+
jobs: ${{ toJSON(needs) }}
41+
if: always()

.github/workflows/release.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
name: release
2-
run-name: Prepare release
2+
run-name: Release
33

44
on:
55
push:
66
tags:
77
- "v[0-9]+.[0-9]+.[0-9]+"
88
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
9+
workflow_dispatch:
910

1011
jobs:
12+
pre-commit:
13+
uses: ./.github/workflows/step_pre-commit.yaml
1114
tests:
12-
uses: ./.github/workflows/test.yaml
13-
secrets: inherit
15+
needs: [ pre-commit ]
16+
uses: ./.github/workflows/step_test.yaml
17+
permissions:
18+
contents: read
19+
checks: write
20+
pull-requests: write
21+
docs:
22+
needs: [ pre-commit ]
23+
uses: ./.github/workflows/step_docs.yaml
24+
1425
release:
15-
needs: [ tests ]
26+
needs: [ tests, docs ]
1627
name: Create release
1728
runs-on: ubuntu-latest
18-
permissions:
19-
contents: write
2029
steps:
21-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
2231
- uses: softprops/action-gh-release@v1
2332
with:
2433
name: CMakeExtraUtils ${{ github.ref_name }}

.github/workflows/step_docs.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: docs
2+
run-name: Run documentation tests
3+
4+
on:
5+
workflow_call:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
doc-test:
12+
name: Sphinx-${{ matrix.builder }}
13+
runs-on: ubuntu-latest
14+
continue-on-error: ${{ matrix.experimental || false }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
builder: [ linkcheck, html ]
19+
include:
20+
# Run default html builder with warnings as error
21+
- builder: html
22+
args: -W
23+
# TODO: Fix documentation and warnings
24+
experimental: true
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: 3.x
30+
- name: Install the project and docs dependencies
31+
run: pip install -e .[docs]
32+
- name: Run sphinx builder ${{ matrix.builder }}
33+
run: sphinx-build -b ${{ matrix.builder }} ${{ matrix.args }} ./docs ./docs/_build
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: pre-commit
2+
run-name: Run pre-commits
3+
4+
on:
5+
workflow_call:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
pre-commit:
12+
name: pre-commit
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: 3.x
19+
- uses: pre-commit/[email protected]

.github/workflows/step_test.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: test
2+
run-name: Run tests
3+
4+
on:
5+
workflow_call:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
tests:
12+
name: CMake ${{ matrix.cmake }}
13+
runs-on: ubuntu-latest
14+
container: ghcr.io/lecrisut/dev-env:main
15+
continue-on-error: ${{ matrix.experimental || false }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
cmake: ["3.20", "latest", "latestrc"]
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
# Note: Proper solution is: https://github.com/actions/runner/issues/2033#issuecomment-1598547465
25+
- name: Temporary fix for git permissions
26+
run: |
27+
git config --global --add safe.directory "*"
28+
git config --global user.email "[email protected]"
29+
git config --global user.name "GitHub Actions Bot"
30+
- uses: actions/setup-python@v5
31+
with:
32+
python-version: 3.x
33+
# TODO: This will be migrated to standalone actions
34+
- name: Setup tmt environment
35+
run: dnf install -y tmt tmt+report-junit
36+
- uses: lukka/get-cmake@latest
37+
with:
38+
cmakeVersion: ${{ matrix.cmake }}
39+
- name: Build and test native CMake
40+
run: |
41+
# Not running presets because of minimum CMake version being tested
42+
cmake -B ./build
43+
ctest --test-dir ./build --output-on-failure
44+
echo "CMakeExtraUtils_ROOT=$(pwd)/build" >> $GITHUB_ENV
45+
# TODO: This will be migrated to standalone actions
46+
- name: Run tmt tests
47+
run: >
48+
tmt --root ./test run --all provision -h local report -h junit --file report.xml
49+
- name: Upload Test Results
50+
if: always()
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: JUnit-CMake-${{ matrix.cmake }}
54+
path: report.xml
55+
report:
56+
name: Report JUnit
57+
needs: [ tests ]
58+
permissions:
59+
contents: read
60+
checks: write
61+
pull-requests: write
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Download test results
65+
uses: actions/download-artifact@v4
66+
- name: Publish Test Results
67+
uses: EnricoMi/publish-unit-test-result-action@v2
68+
with:
69+
files: "*/report.xml"
70+
large_files: true
71+
report_individual_runs: true
72+
report_suite_logs: any
73+
if: always()

.github/workflows/test.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ These utilities can be included using both `find_package()` and `ExternalProject
1111
installed on your system:
1212

1313
```cmake
14-
cmake_minimum_required(VERSION 3.25)
14+
cmake_minimum_required(VERSION 3.20)
1515
1616
find_package(CMakeExtraUtils REQUIRED)
1717
@@ -25,7 +25,7 @@ project(MyProject
2525
or if you want to download a specific version:
2626

2727
```cmake
28-
cmake_minimum_required(VERSION 3.25)
28+
cmake_minimum_required(VERSION 3.20)
2929
3030
FetchContet_Declare(CMakeExtraUtils
3131
GIT_REPOSITORY https://github.com/LecriUT/CMakeExtraUtils

cmake/CMakePresets-defaults.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"configurePresets": [
44
{
55
"name": "default",
6-
"displayName": "Default configuration preset",
6+
"displayName": "Default preset",
77
"binaryDir": "cmake-build-release",
88
"cacheVariables": {
99
"CMAKE_BUILD_TYPE": {
@@ -13,6 +13,16 @@
1313
}
1414
}
1515
],
16+
"testPresets": [
17+
{
18+
"name": "default",
19+
"displayName": "Default preset",
20+
"configurePreset": "default",
21+
"output": {
22+
"outputOnFailure": true
23+
}
24+
}
25+
],
1626
"workflowPresets": [
1727
{
1828
"name": "default",
@@ -21,6 +31,10 @@
2131
{
2232
"type": "configure",
2333
"name": "default"
34+
},
35+
{
36+
"type": "test",
37+
"name": "default"
2438
}
2539
]
2640
}

cmake/DynamicVersion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Calculate the project version from the git tags or `.git_archival.txt` if the so
55
## Example
66

77
```cmake
8-
cmake_minimum_required(VERSION 3.25)
8+
cmake_minimum_required(VERSION 3.20)
99
1010
find_package(CMakeExtraUtils REQUIRED)
1111

cmake/PackageComps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Export and import targets as individual components. Special components `shared`
77
The main `CMakeLists.txt` that exports the target:
88

99
```cmake
10-
cmake_minimum_required(VERSION 3.25)
10+
cmake_minimum_required(VERSION 3.20)
1111
1212
project(My_Project)
1313
@@ -48,7 +48,7 @@ find_components(COMPONENTS my_component)
4848
The user will then be able to use:
4949

5050
```cmake
51-
cmake_minimum_required(VERSION 3.25)
51+
cmake_minimum_required(VERSION 3.20)
5252
5353
project(Downstream_Project)
5454

0 commit comments

Comments
 (0)