From 02cce8024d0e91036266cae310ed8d24f9c64d17 Mon Sep 17 00:00:00 2001 From: capellancitizen Date: Tue, 13 Aug 2024 11:27:33 -0400 Subject: CI: Added pytest, some speed improvements (#3135) Geos build is now cached, and its tests are no longer built. --- .github/workflows/build.yml | 53 ++++++++++++++++++++++++++++----------------- CODING_STYLE.md | 1 - bin/build-geos-win.cmd | 5 +++-- bin/build-linux-dist | 13 +++++++---- pytest.ini | 3 +++ requirements.txt | 5 +++++ 6 files changed, 53 insertions(+), 27 deletions(-) create mode 100644 pytest.ini diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8639c0cd..f664d594 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,12 +16,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.9.x' - - uses: actions/setup-node@v4 - with: - node-version: 20 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.1 - uses: actions/cache@v4 id: pip-cache with: @@ -29,6 +23,13 @@ jobs: key: ${{ runner.os }}-20.04-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-20.04-pip- + - uses: actions/cache@v4 + id: geos-build-cache + with: + path: geos/build + key: ${{ runner.os }}-20.04-geos-build-${{ hashFiles('bin/build-linux') }} + restore-keys: | + ${{ runner.os }}-20.04-geos-build- - name: install dependencies shell: bash @@ -88,13 +89,17 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - uses: actions/setup-node@v4 - with: - node-version: 20 - uses: actions/setup-python@v5 with: python-version: '3.8.x' architecture: 'x86' + - uses: actions/cache@v4 + id: geos-build-cache + with: + path: geos + key: win32-geos-build-${{ hashFiles('bin/geos-win.cmd') }} + restore-keys: | + win32-geos-build- - uses: microsoft/setup-msbuild@v2 - name: Setup Git for Windows SDK uses: git-for-windows/setup-git-for-windows-sdk@v1.10.0 @@ -125,6 +130,9 @@ jobs: run: | SET BUILD32="1" bin\build-geos-win.cmd + - shell: bash + run: | + pytest - shell: bash run: | make dist @@ -154,13 +162,17 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - uses: actions/setup-node@v4 - with: - node-version: 20 - uses: actions/setup-python@v5 with: python-version: '3.8.x' architecture: 'x64' + - uses: actions/cache@v4 + id: geos-build-cache + with: + path: geos + key: win64-geos-build-${{ hashFiles('bin/geos-win.cmd') }} + restore-keys: | + win64-geos-build- - uses: microsoft/setup-msbuild@v2 - name: Setup Git for Windows SDK uses: git-for-windows/setup-git-for-windows-sdk@v1.10.0 @@ -185,6 +197,9 @@ jobs: shell: cmd run: | bin\build-geos-win.cmd + - shell: bash + run: | + pytest - shell: bash run: | make dist @@ -217,9 +232,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.9.x' - - uses: actions/setup-node@v4 - with: - node-version: 20 - name: install dependencies shell: bash run: | @@ -252,6 +264,9 @@ jobs: pip install pyinstaller echo "${{ env.pythonLocation }}/bin" >> $GITHUB_PATH + - shell: bash + run: | + pytest - shell: bash run: | make dist @@ -265,7 +280,6 @@ jobs: NOTARY_ACCOUNT: ${{ secrets.INKSTITCH_NOTARIZE_AC }} NOTARY_PASSWORD: ${{ secrets.INKSTITCH_NOTARIZE_PASS }} - - uses: actions/upload-artifact@v4 with: name: inkstitch-mac-x86 @@ -279,9 +293,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.9.x' - - uses: actions/setup-node@v4 - with: - node-version: 20 - name: install dependencies shell: bash run: | @@ -314,6 +325,9 @@ jobs: pip install pyinstaller echo "${{ env.pythonLocation }}/bin" >> $GITHUB_PATH + - shell: bash + run: | + pytest - shell: bash run: | make dist @@ -327,7 +341,6 @@ jobs: NOTARY_ACCOUNT: ${{ secrets.INKSTITCH_NOTARIZE_AC }} NOTARY_PASSWORD: ${{ secrets.INKSTITCH_NOTARIZE_PASS }} - - uses: actions/upload-artifact@v4 with: name: inkstitch-mac-arm64 diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 0c47cd4e..34fff7c4 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -38,7 +38,6 @@ Code review is an important in our project, and we ask that all code changes be When providing feedback, please keep in mind our goals of making the codebase **fun to work on** and **easy to understand**. It may be the case that someone does something in a different way than you would have. If it still meets these goals, then perhaps it's fine as it is. Diversity of thought makes a codebase like ours stronger. - Object-Oriented Programming =========================== Object-oriented programming is encouraged but not required. It can often make code easier to understand, but not always. We pick the best tool to express the solution to our problem as clearly as possible. diff --git a/bin/build-geos-win.cmd b/bin/build-geos-win.cmd index a3b1ca5d..d81409da 100755 --- a/bin/build-geos-win.cmd +++ b/bin/build-geos-win.cmd @@ -10,8 +10,9 @@ curl -L -O https://github.com/libgeos/geos/releases/download/3.12.2/geos-3.12.2 7z x geos-3.12.2.tar.bz2 7z x geos-3.12.2.tar -cd geos-3.12.2 -cmake -S . -B _build -G "Visual Studio 16 2019" -A %BUILDFLAG% -DCMAKE_INSTALL_PREFIX=%GEOS_INSTALL% -DCMAKE_GENERATOR_TOOLSET=host=x64 +move geos-3.12.2 geos +cd geos +cmake -S . -B _build -G "Visual Studio 16 2019" -A %BUILDFLAG% -DCMAKE_INSTALL_PREFIX=%GEOS_INSTALL% -DCMAKE_GENERATOR_TOOLSET=host=x64 -DBUILD_TESTING=OFF cmake --build _build --config Release -j 16 --verbose cd _build diff --git a/bin/build-linux-dist b/bin/build-linux-dist index aaa487b4..5b591f71 100755 --- a/bin/build-linux-dist +++ b/bin/build-linux-dist @@ -1,15 +1,16 @@ #!/usr/bin/env bash +set -e # creating folder to install geos mkdir $HOME/geos-build GEOS_PATH=$HOME/geos-build # Downloading geos curl -L -O https://github.com/libgeos/geos/releases/download/3.12.2/geos-3.12.2.tar.bz2 -# uzipping geos -tar -xf geos-3.12.2.tar.bz2 -cd geos-3.12.2 +# uzipping geos into the geos directory +mkdir -p geos && cd geos +tar -xf ../geos-3.12.2.tar.bz2 --strip-components=1 # Building geos -mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=$GEOS_PATH -DCMAKE_BUILD_TYPE=Release .. +mkdir -p build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=$GEOS_PATH -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF .. make && make install export PATH=$GEOS_PATH/bin:$PATH @@ -20,5 +21,9 @@ cd ../.. python -m pip uninstall -y shapely python -m pip cache remove shapely python -m pip install -v shapely --no-binary shapely +# Future improvement might be to split this out so pytest is a separate step and line on the build log, +# but the LD_LIBRARY_PATH env var needs to be passed between those steps with step outputs or something. +# This works for now. +pytest make dist diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..7f369af2 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +testpaths = + tests \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 5fe6c915..2563d1f2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -37,3 +37,8 @@ flask-cors pywinutils ; sys_platform == 'win32' pywin32 ; sys_platform == 'win32' +# Test dependencies. +# It should be okay to include these here because this list isn't the one used for bundling dependencies. +# Instead Pyinstaller finds what dependencies the project needs based on what inkstitch.py imports +pytest + -- cgit v1.2.3