-
Notifications
You must be signed in to change notification settings - Fork 4
135 lines (122 loc) · 5.33 KB
/
czicompress_cmake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
name: CMake Build (czicompress)
on:
push:
branches: ["main"] # run only when merge with main branch
pull_request:
branches: ["main"] # run only when merge with main branch
workflow_dispatch: {}
permissions:
contents: read
jobs:
build-tests:
defaults:
run:
working-directory: ${{github.workspace}}/czicompress
# https://stackoverflow.com/questions/69636799/how-do-i-pass-the-job-name-into-a-github-actions-input
env:
name: ${{matrix.config.name}}-${{matrix.build}}
name: ${{matrix.config.name}}-${{matrix.build}}
runs-on: ${{matrix.config.os}}
strategy:
fail-fast: false
matrix:
build: [Release, Debug]
config: # Create matrix with combinations of compiler and options.
# Notes:
# The property 'package' is controlling whether the build-time-dependencies (i.e. eigen3, cli11, catch2) are pulled in via the system's package manager or via CMake at build-time.
- {
name: windows-64-msvc-package-on,
os: windows-latest,
platform: x64-windows-static,
package: ON,
path-cache: '${{ github.workspace }}\vcpkg\installed',
path-toolchain: "C:/vcpkg/scripts/buildsystems/vcpkg.cmake",
os-id: "windows",
}
- {
name: ubuntu-package-off,
os: ubuntu-20.04, # we want to use an older version in order to increase likelihood that binaries work on other distros
platform: x64-linux,
package: OFF,
path-cache: "/usr/local/share/vcpkg/installed",
path-toolchain: "/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake",
os-id: "linux",
}
exclude:
# From https://github.com/actions/runner/issues/1512
- build: Debug
config:
{
name: ubuntu-package-off,
os: ubuntu-20.04,
platform: x64-linux,
package: OFF,
path-cache: "/usr/local/share/vcpkg/installed",
path-toolchain: "/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake",
os-id: "linux",
}
steps:
- name: Checkout the source codes.
uses: actions/checkout@v4
- uses: ./.github/actions/cmake-build
with:
path-cache: ${{matrix.config.path-cache}}
path-toolchain: ${{matrix.config.path-toolchain}}
os-id: ${{matrix.config.os-id}}
build-type: ${{matrix.build}}
package: ${{matrix.config.package}}
platform: ${{matrix.config.platform}}
src-dir: "${{github.workspace}}/czicompress"
- name: Run unit tests
working-directory: ${{github.workspace}}/czicompress/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{matrix.build}}
# Coverage collection based on https://about.codecov.io/blog/how-to-set-up-codecov-with-c-plus-plus-and-github-actions/
- name: Prepare Coverage
if: ${{ (matrix.config.os == 'windows-latest') && (matrix.build == 'Debug') }}
shell: pwsh
run: |
choco install OpenCppCoverage -y
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
- name: Get Coverage
if: ${{ (matrix.config.os == 'windows-latest') && (matrix.build == 'Debug') }}
working-directory: ${{github.workspace}}/czicompress/build/tests/${{matrix.build}}
shell: cmd
run: OpenCppCoverage.exe --export_type cobertura:${{github.workspace}}\TestResults\coverage.xml --sources "${{github.workspace}}\czicompress" --excluded_sources "${{github.workspace}}\czicompress\tests" --modules czicompress -- czicompress_tests.exe
- name: Upload Coverage
uses: codecov/codecov-action@v4
if: ${{ (matrix.config.os == 'windows-latest') && (matrix.build == 'Debug') }}
with:
files: coverage.xml
fail_ci_if_error: true
directory: ${{ github.workspace }}/TestResults
verbose: true
token: ${{ secrets.CODECOV_TOKEN }} # required
- name: Prepare licenses
if: matrix.build == 'Release'
shell: bash
run: |
set -e
mkdir ./czicompress-${{env.name}}
cp -R ./THIRD_PARTY_LICENSES_ARTIFACT_DISTRIBUTION.txt ./czicompress-${{env.name}}/
cp -R ./build/app/THIRD_PARTY_LICENSES.txt ./czicompress-${{env.name}}/
# gather the binaries
- name: Prepare Linux binaries
if: ${{ (matrix.config.os == 'ubuntu-20.04') && (matrix.build == 'Release') }}
shell: bash
run: |
cp ./build/app/czicompress ./build/capi/libczicompressc.so ./czicompress-${{env.name}}/
- name: Prepare Windows binaries
if: ${{ (matrix.config.os == 'windows-latest') && (matrix.build == 'Release') }}
shell: bash
run: |
cp ./build/app/${{matrix.build}}/*.exe ./build/capi/${{matrix.build}}/libczicompressc.dll ./czicompress-${{env.name}}/
# upload the build-results to artifacts-store
- name: Upload artifacts
if: matrix.build == 'Release'
uses: actions/upload-artifact@v4
with:
name: czicompress-${{env.name}}
path: czicompress/czicompress-${{env.name}}/