Speed up build #1037
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
name: Documentation | |
on: | |
push: | |
branches: [main] | |
pull_request_target: | |
branches: [main] | |
# Newer commits should cancel old runs | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
documentation: | |
permissions: | |
contents: read | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: applied-material-modeling/neml2-ci@main | |
with: | |
ref: ${{ github.event.pull_request.head.sha || github.ref }} | |
python-version: 3.9 | |
cmake-version: 3.28 | |
torch-version: 2.5.1 | |
- name: Configure | |
run: cmake --preset dev -GNinja -S . | |
- name: Build | |
run: cmake --build --preset dev-doc | |
# Documentation error checking | |
- name: Show build logs for C++ documentation | |
run: | | |
echo '### C++ documentation build log' >> $GITHUB_STEP_SUMMARY | |
cat build/dev/doc/doxygen.html.log >> $GITHUB_STEP_SUMMARY | |
- name: Show build logs for Python documentation | |
run: | | |
echo '### Python documentation build log' >> $GITHUB_STEP_SUMMARY | |
cat build/dev/doc/doxygen.python.log >> $GITHUB_STEP_SUMMARY | |
- name: Warn about syntax errors | |
run: | | |
cat build/dev/doc/syntax_error.log >> $GITHUB_STEP_SUMMARY | |
- name: Error if syntax errors were detected | |
run: grep -q "No syntax error" build/dev/doc/syntax_error.log | |
- name: Upload documentation | |
uses: actions/upload-artifact@v4 | |
with: | |
name: documentation | |
path: build/dev/doc/build/html | |
coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: applied-material-modeling/neml2-ci@main | |
with: | |
ref: ${{ github.event.pull_request.head.sha || github.ref }} | |
python-version: 3.9 | |
cmake-version: 3.28 | |
torch-version: 2.5.1 | |
- name: Configure | |
run: cmake --preset coverage -GNinja -S . | |
- name: Build | |
run: cmake --build --preset coverage | |
- name: Code coverage check | |
run: build/coverage/scripts/coverage.sh | |
- name: Upload coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage | |
path: build/coverage/coverage | |
deploy: | |
needs: [documentation, coverage] | |
permissions: | |
contents: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: documentation | |
path: site/html | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage | |
path: site/html/coverage | |
# PR preview | |
- name: Deploy preview to GitHub Pages | |
if: github.event_name == 'pull_request_target' | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages | |
folder: site/html | |
target-folder: pr-preview/pr-${{ github.event.number }} | |
- name: Update comment with preview link | |
if: github.event_name == 'pull_request_target' | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: preview-link | |
message: | | |
Documentation preview: <https://applied-material-modeling.github.io/neml2/pr-preview/pr-${{ github.event.number }}> | |
Code coverage: <https://applied-material-modeling.github.io/neml2/pr-preview/pr-${{ github.event.number }}/coverage> | |
# Deploy to GitHub Pages | |
- name: Deploy to GitHub Pages | |
if: github.event_name == 'push' | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages | |
folder: site/html | |
clean-exclude: pr-preview/ | |
single-commit: true |