Setup PR tests #8
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: Static Analyses | |
on: | |
pull_request: | |
branches: [ "main" ] | |
merge_group: | |
types: [checks_requested] | |
jobs: | |
Indentation: | |
name: Clang Formatting Check | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/gyselax/gyselalibxx_env | |
options: --user 1001 | |
steps: | |
- uses: actions/checkout@v4 | |
- shell: bash | |
run: | | |
./bin/indent -td | |
Markdown: | |
name: Markdown format check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Get Python dependencies | |
run: | | |
pip install numpy | |
- name: Check files | |
id: markdown | |
continue-on-error: true | |
shell: bash | |
run: | | |
MARKDOWN_FILES=$(find . -name "*.md" -not -path "./vendor/*") | |
MARKDOWN_FILES="$MARKDOWN_FILES $(find ./vendor/sll/ -name '*.md')" | |
echo $MARKDOWN_FILES | |
python3 ci_tools/markdown_linter.py ${MARKDOWN_FILES} | |
echo "EXIT_CODE=$?" >> $GITHUB_OUTPUT | |
- name: Check error code | |
shell: python | |
run: | | |
assert ${{ steps.markdown.outputs.EXIT_CODE }} in (0, 2) | |
Python: | |
name: Python Best Practices | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/gyselax/gyselalibxx_env | |
options: --user 1001 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Run pylint | |
run: | | |
pylint $(find tests -iname *.py) | |
pylint $(find doc -iname *.py) | |
pylint $(find ci_tools -iname *.py) | |
shell: bash | |
env: | |
PYTHONPATH: ./post-process/PythonScripts | |
- name: Run filtered pylint | |
run: | | |
# Find all files with no extension or a .py extension in post-process/PythonScripts/ | |
POST_PROCESS_PYTHON_FILES=$(find post-process/PythonScripts/ -type f ! -name "*.*"; find post-process/PythonScripts -iname *.py) | |
# Get pylint errors without failing | |
pylint ${POST_PROCESS_PYTHON_FILES} > post_process_errors.txt || true | |
# Filter errors on changed files | |
for f in $(git diff ${{ github.event.pull_request.base.sha }} --name-only); do grep $f post_process_errors.txt || true; done | tee filtered_errors.txt | |
# Raise an error if post-process in filtered errors | |
! grep "post-process" filtered_errors.txt >/dev/null | |
shell: bash | |
env: | |
PYTHONPATH: ./post-process/PythonScripts | |
Documentation: | |
name: Documentation check | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/gyselax/gyselalibxx_env | |
options: --user 1001 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Make documenation | |
run: | | |
# Make docs | |
mkdir build | |
cd build | |
cmake -DBUILD_DOCUMENTATION=ON .. | |
make doc | |
cd .. | |
shell: bash | |
- name: Check for new errors | |
run: | | |
# Get files which have changed in this merge request | |
git diff ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} --no-indent-heuristic --unified=0 --output=pull_diff.txt --no-color | |
# Filter documentation messages to only complain about modified files | |
python3 ci_tools/check_documentation.py pull_diff.txt build/docs/doxygen.log | |
git diff ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} --no-indent-heuristic --unified=0 --output=pull_new_files.txt --no-color --diff-filter=A | |
python3 ci_tools/check_readme_presence.py pull_new_files.txt | |
shell: bash | |