Try pre-commit action #1193
Workflow file for this run
This file contains hidden or 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: Build and Test | |
| on: | |
| push: | |
| branches: | |
| - "*" | |
| pull_request: | |
| branches: | |
| - "*" | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${ {github.event_name }}-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{github.event_name == 'pull_request'}} | |
| jobs: | |
| pre-commit: | |
| name: pre-commit checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Run pre-commit | |
| uses: pre-commit/action@v3.0.1 | |
| run_tox: | |
| name: mocked tests | |
| needs: [pre-commit] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v2 | |
| - uses: actions/setup-python@v1 | |
| - name: Install OpenMPI, CMake, Boost library, Eigen and pkg-config | |
| run: | | |
| sudo apt-get -yy update | |
| sudo apt-get install -y libopenmpi-dev cmake libboost-all-dev libeigen3-dev pkg-config | |
| sudo rm -rf /var/lib/apt/lists/* | |
| - name: Checkout precice and make required files discoverable | |
| run: | | |
| git clone --branch develop https://github.com/precice/precice.git precice-core | |
| mkdir -p precice | |
| cp precice-core/src/precice/Participant.hpp precice/Participant.hpp | |
| cp precice-core/src/precice/Tooling.hpp precice/Tooling.hpp | |
| cp precice-core/src/precice/Tooling.cpp precice/Tooling.cpp | |
| cd precice-core | |
| mkdir build && cd build | |
| cmake .. -DPRECICE_FEATURE_MPI_COMMUNICATION=OFF -DPRECICE_FEATURE_PETSC_MAPPING=OFF -DPRECICE_FEATURE_PYTHON_ACTIONS=OFF -DBUILD_TESTING=OFF | |
| - name: Install tox | |
| run: pip install tox | |
| - name: Run tox | |
| env: | |
| PKG_CONFIG_SYSTEM_INCLUDE_PATH: 1 | |
| run: | | |
| export PKG_CONFIG_PATH=$(readlink -f "precice-core/build") | |
| tox | |
| build_dist: | |
| name: build distributions | |
| needs: [pre-commit] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: precice/precice:nightly | |
| options: --user root | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure safe directory | |
| run: git config --global --add safe.directory $GITHUB_WORKSPACE | |
| - name: Install dependencies | |
| run: | | |
| apt-get -yy update | |
| apt-get install -y python3-pip python3.12-venv pkg-config pipx | |
| rm -rf /var/lib/apt/lists/* | |
| - name: Install pyproject-build | |
| run: | | |
| pipx install build | |
| - name: Build sdist | |
| run: | | |
| export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
| $HOME/.local/bin/pyproject-build -s | |
| - name: Build wheel | |
| run: | | |
| export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
| $HOME/.local/bin/pyproject-build -w | |
| pip_install: | |
| name: pip install | |
| needs: [pre-commit] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: precice/precice:nightly | |
| options: --user root | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| apt-get -yy update | |
| apt-get install -y python3-pip python3.12-venv pkg-config | |
| rm -rf /var/lib/apt/lists/* | |
| - name: Create venv | |
| run: | | |
| python3 -m venv .venv | |
| - name: Run pip install | |
| run: | | |
| .venv/bin/pip3 install . | |
| - name: Check import | |
| run: | | |
| export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
| .venv/bin/python3 -c "import precice" | |
| - name: Get version | |
| run: | | |
| export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
| .venv/bin/python3 -c "import precice; print(precice.__version__)" | |
| .venv/bin/python3 -c "import precice; print(precice.get_version_information())" | |
| solverdummy_test: | |
| name: solverdummies | |
| needs: [pip_install] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: precice/precice:nightly | |
| options: --user root | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| apt-get -yy update | |
| apt-get install -y python3-pip python3.12-venv pkg-config | |
| rm -rf /var/lib/apt/lists/* | |
| - name: Create venv | |
| run: | | |
| python3 -m venv .venv | |
| - name: Activate venv | |
| # see https://stackoverflow.com/a/74669486 | |
| run: | | |
| . .venv/bin/activate | |
| echo PATH=$PATH >> $GITHUB_ENV | |
| - name: Run pip install | |
| run: pip3 install . | |
| - name: Run solverdummy | |
| run: | | |
| export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
| cd examples/solverdummy/ | |
| python3 solverdummy.py precice-config.xml SolverOne MeshOne & python3 solverdummy.py precice-config.xml SolverTwo MeshTwo |