|
| 1 | +name: Continuous Integration |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '*' |
| 7 | + tags: |
| 8 | + - "v*.*.*" |
| 9 | + |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - develop |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{format('{0}:{1}', github.repository, github.ref)}} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + cpp-matrix: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + name: Generate Test Matrix |
| 22 | + outputs: |
| 23 | + matrix: ${{ steps.cpp-matrix.outputs.matrix }} |
| 24 | + steps: |
| 25 | + - name: Generate Test Matrix |
| 26 | + uses: alandefreitas/cpp-actions/[email protected] |
| 27 | + id: cpp-matrix |
| 28 | + with: |
| 29 | + compilers: | |
| 30 | + gcc >=7 |
| 31 | + clang 6 || 9 || 12 || >=14 |
| 32 | + msvc >= 14 |
| 33 | + mingw * |
| 34 | + clang-cl * |
| 35 | + apple-clang * |
| 36 | + standards: '>=17' |
| 37 | + latest-factors: gcc Coverage UBSan |
| 38 | + max-standards: 1 |
| 39 | + |
| 40 | + build: |
| 41 | + needs: cpp-matrix |
| 42 | + |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + include: ${{ fromJSON(needs.cpp-matrix.outputs.matrix) }} |
| 47 | + |
| 48 | + defaults: |
| 49 | + run: |
| 50 | + shell: bash |
| 51 | + |
| 52 | + name: ${{ matrix.name }} |
| 53 | + runs-on: ${{ matrix.runs-on }} |
| 54 | + container: ${{ matrix.container }} |
| 55 | + permissions: |
| 56 | + contents: write |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Clone matplot++ |
| 60 | + uses: actions/checkout@v3 |
| 61 | + |
| 62 | + - name: Setup C++ |
| 63 | + uses: alandefreitas/cpp-actions/[email protected] |
| 64 | + id: setup-cpp |
| 65 | + with: |
| 66 | + compiler: ${{ matrix.compiler }} |
| 67 | + version: ${{ matrix.version }} |
| 68 | + |
| 69 | + - name: Install packages |
| 70 | + uses: alandefreitas/cpp-actions/[email protected] |
| 71 | + id: package-install |
| 72 | + with: |
| 73 | + apt-get: ${{ matrix.install }} ${{ ((matrix.coverage) && 'gnuplot') || '' }} |
| 74 | + |
| 75 | + - name: CMake Workflow |
| 76 | + uses: alandefreitas/cpp-actions/[email protected] |
| 77 | + with: |
| 78 | + cmake-version: '>=3.15' |
| 79 | + generator: ${{ matrix.generator }} |
| 80 | + build-type: ${{ matrix.build-type }} |
| 81 | + # Only run tests in these two cases because we're just running examples here. |
| 82 | + # Other tests come later. |
| 83 | + run-tests: ${{ ((matrix.coverage) && 'true') || '' }} |
| 84 | + cxxstd: ${{ (!matrix.coverage && matrix.cxxstd) || matrix.latest-cxxstd }} |
| 85 | + cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }} |
| 86 | + ccflags: ${{ matrix.ccflags }} |
| 87 | + cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }} |
| 88 | + cxxflags: ${{ matrix.cxxflags }} |
| 89 | + # Also make it shared in coverage tests because of disk space |
| 90 | + shared: ${{ matrix.shared || matrix.coverage }} |
| 91 | + install-prefix: $GITHUB_WORKSPACE/.local |
| 92 | + export-compile-commands: ${{ matrix.time-trace }} |
| 93 | + # There are cases where the environment cannot store all examples, and we need to disable them |
| 94 | + extra-args: -D MATPLOTPP_BUILD_WITH_PEDANTIC_WARNINGS=ON ${{ format('-D MATPLOTPP_BUILD_EXAMPLES={0}', (!matrix.asan && !matrix.ubsan && !matrix.x86 && 'ON') || 'OFF' ) }} |
| 95 | + package: ${{ matrix.is-main }} |
| 96 | + package-artifact: false |
| 97 | + package-dir: packages |
| 98 | + |
| 99 | + - name: Archive packages |
| 100 | + if: ${{ matrix.is-main && github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }} |
| 101 | + uses: actions/upload-artifact@v3 |
| 102 | + with: |
| 103 | + name: release-packages-${{ matrix.compiler }}${{ (!contains('*', matrix.version) && format('-{0}', matrix.version)) || '' }}-${{ runner.os }} |
| 104 | + path: build/packages |
| 105 | + retention-days: 1 |
| 106 | + |
| 107 | + - name: CMake Integration |
| 108 | + uses: alandefreitas/cpp-actions/[email protected] |
| 109 | + if: ${{ !matrix.ubsan && !matrix.asan }} |
| 110 | + with: |
| 111 | + source-dir: test/integration |
| 112 | + ref-source-dir: ./test/integration |
| 113 | + cmake-version: '>=3.15' |
| 114 | + generator: ${{ matrix.generator }} |
| 115 | + build-type: ${{ matrix.build-type }} |
| 116 | + run-tests: '' |
| 117 | + cxxstd: ${{ matrix.cxxstd }} |
| 118 | + cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }} |
| 119 | + ccflags: ${{ matrix.ccflags }} |
| 120 | + cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }} |
| 121 | + cxxflags: ${{ matrix.cxxflags }} |
| 122 | + shared: ${{ matrix.shared || matrix.coverage }} |
| 123 | + install: false |
| 124 | + extra-args: ${{ format('-D Matplot++_ROOT="{0}"', '$GITHUB_WORKSPACE/.local') }} |
| 125 | + export-compile-commands: ${{ matrix.time-trace }} |
| 126 | + |
| 127 | + - name: FlameGraph |
| 128 | + uses: alandefreitas/cpp-actions/[email protected] |
| 129 | + if: matrix.time-trace |
| 130 | + with: |
| 131 | + build-dir: build |
| 132 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + trace-commands: true |
| 134 | + |
| 135 | + - name: Codecov |
| 136 | + if: ${{ matrix.coverage }} |
| 137 | + run: | |
| 138 | + set -x |
| 139 | + # Find gcov |
| 140 | + gcov_tool="gcov" |
| 141 | + if command -v "gcov-${{ steps.setup-cpp.outputs.version-major }}.${{ steps.setup-cpp.outputs.version-minor }}" &> /dev/null; then |
| 142 | + gcov_tool="gcov" |
| 143 | + elif command -v "gcov-${{ steps.setup-cpp.outputs.version-major }}" &> /dev/null; then |
| 144 | + gcov_tool="gcov-${{ steps.setup-cpp.outputs.version-major }}" |
| 145 | + fi |
| 146 | + lcov -c -q -o "./build/coverage.info" -d "./build" --include "$(pwd)/*" --gcov-tool "$gcov_tool" |
| 147 | + |
| 148 | + # Upload to codecov |
| 149 | + bash <(curl -s https://codecov.io/bash) -f "./build/coverage.info" |
| 150 | + |
| 151 | + # Update summary |
| 152 | + echo "# Coverage" >> $GITHUB_STEP_SUMMARY |
| 153 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 154 | + echo "[](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY |
| 155 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 156 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 157 | + echo "$GITHUB_REF_NAME: [](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY |
| 158 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 159 | +
|
| 160 | + docs: |
| 161 | + needs: build |
| 162 | + if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }} |
| 163 | + defaults: |
| 164 | + run: |
| 165 | + shell: bash |
| 166 | + |
| 167 | + name: Publish docs |
| 168 | + # timeout-minutes: 120 |
| 169 | + runs-on: ubuntu-22.04 |
| 170 | + permissions: |
| 171 | + contents: write |
| 172 | + |
| 173 | + steps: |
| 174 | + - name: Clone matplot++ |
| 175 | + uses: actions/checkout@v3 |
| 176 | + |
| 177 | + - name: Generate Table of Contents |
| 178 | + uses: technote-space/toc-generator@v2 |
| 179 | + with: |
| 180 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 181 | + MAX_HEADER_LEVEL: 3 |
| 182 | + FOLDING: true |
| 183 | + |
| 184 | + - name: Update Contributors |
| 185 | + |
| 186 | + env: |
| 187 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 188 | + with: |
| 189 | + image_size: 100 |
| 190 | + columns_per_row: 6 |
| 191 | + |
| 192 | + - name: Download mdsplit |
| 193 | + uses: carlosperate/[email protected] |
| 194 | + id: download-mdsplit |
| 195 | + with: |
| 196 | + file-url: 'https://github.com/alandefreitas/mdsplit/releases/download/v0.1.1/Executable.Linux.zip' |
| 197 | + file-name: 'mdsplit.zip' |
| 198 | + location: '.' |
| 199 | + |
| 200 | + - name: Unzip mdsplit |
| 201 | + run: | |
| 202 | + unzip mdsplit.zip |
| 203 | + rm -f mdsplit.zip |
| 204 | + sudo chmod +x mdsplit |
| 205 | + ls |
| 206 | +
|
| 207 | + - name: Generate Documentation Source |
| 208 | + run: ./mdsplit -r alandefreitas/matplotplusplus |
| 209 | + |
| 210 | + - name: Setup Python |
| 211 | + uses: actions/setup-python@v2 |
| 212 | + with: |
| 213 | + python-version: 3.x |
| 214 | + |
| 215 | + - name: Install Mkdocs Material |
| 216 | + run: pip install mkdocs-material |
| 217 | + |
| 218 | + - name: Install Awesome Pages Plugin # https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin |
| 219 | + run: pip install mkdocs-awesome-pages-plugin |
| 220 | + |
| 221 | + - name: Deploy mkdocs to gh-pages branch |
| 222 | + run: mkdocs gh-deploy --force |
| 223 | + |
| 224 | + releases: |
| 225 | + needs: build |
| 226 | + if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }} |
| 227 | + defaults: |
| 228 | + run: |
| 229 | + shell: bash |
| 230 | + |
| 231 | + name: Create Release Packages |
| 232 | + timeout-minutes: 120 |
| 233 | + runs-on: ubuntu-22.04 |
| 234 | + permissions: |
| 235 | + contents: write |
| 236 | + |
| 237 | + steps: |
| 238 | + - name: Clone matplot++ |
| 239 | + uses: actions/checkout@v3 |
| 240 | + |
| 241 | + - name: Check conventional commit |
| 242 | + if: ${{ !contains( matrix.config.os, 'macos') }} |
| 243 | + |
| 244 | + continue-on-error: true |
| 245 | + |
| 246 | + - name: Download all artifacts |
| 247 | + uses: actions/download-artifact@v3 |
| 248 | + with: |
| 249 | + path: artifacts |
| 250 | + |
| 251 | + - name: List artifacts |
| 252 | + run: ls -R |
| 253 | + working-directory: artifacts |
| 254 | + |
| 255 | + - name: Create changelog |
| 256 | + uses: alandefreitas/cpp-actions/create-changelog@4f2622267261fc75a0d885cf3367f29e62984f68 # v1.5.0 |
| 257 | + with: |
| 258 | + output-path: CHANGELOG.md |
| 259 | + thank-non-regular: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 260 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 261 | + link-commits: ${{ ! (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }} |
| 262 | + limit: 150 |
| 263 | + |
| 264 | + - name: Create GitHub Package Release |
| 265 | + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} |
| 266 | + uses: softprops/action-gh-release@v1 |
| 267 | + with: |
| 268 | + files: artifacts/release-packages-*/* |
| 269 | + name: ${{ github.ref_name || github.ref }} |
| 270 | + tag_name: ${{ github.ref_name || github.ref }}${{ ((!startsWith(github.ref, 'refs/tags/')) && '-release') || '' }} |
| 271 | + body_path: CHANGELOG.md |
| 272 | + prerelease: false |
| 273 | + draft: false |
| 274 | + token: ${{ github.token }} |
0 commit comments