Skip to content

Commit

Permalink
Update testing method
Browse files Browse the repository at this point in the history
Contributes to CURA-10475 and CURA-10951
  • Loading branch information
jellespijker committed Sep 11, 2023
1 parent 5413cb9 commit 9a8f4dd
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 138 deletions.
279 changes: 148 additions & 131 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,139 +3,156 @@ name: unit-test
# FIXME: This should be a reusable workflow

on:
push:
paths:
- 'src/**'
- 'include/**'
- 'tests'
- 'test_package/**'
- 'tests/**'
- 'cmake/**'
- 'conanfile.py'
- 'conandata.yml'
- 'CMakeLists.txt'
- 'requirements.txt'
- '.github/workflows/unit-test.yml'
- '.github/workflows/requirements*'
branches:
- main
- master
- 'CURA-*'
- '[0-9].[0-9]'
- '[0-9].[0-9][0-9]'
tags:
- '[0-9].[0-9].[0-9]'
- '[0-9].[0-9][0-9].[0-9]'
pull_request:
paths:
- 'src/**'
- 'include/**'
- 'tests'
- 'test_package/**'
- 'tests/**'
- 'cmake/**'
- 'conanfile.py'
- 'conandata.yml'
- 'CMakeLists.txt'
- 'requirements.txt'
- '.github/workflows/unit-test.yml'
- '.github/workflows/requirements*'
branches:
- main
- master
- '[0-9].[0-9]'
- '[0-9].[0-9][0-9]'
tags:
- '[0-9].[0-9].[0-9]'
- '[0-9].[0-9][0-9].[0-9]'
push:
paths:
- 'src/**'
- 'include/**'
- 'tests'
- 'test_package/**'
- 'tests/**'
- 'cmake/**'
- 'conanfile.py'
- 'conandata.yml'
- 'CMakeLists.txt'
- 'requirements.txt'
- '.github/workflows/unit-test.yml'
- '.github/workflows/requirements*'
branches:
- main
- master
- 'CURA-*'
- '[0-9].[0-9]'
- '[0-9].[0-9][0-9]'
tags:
- '[0-9].[0-9].[0-9]'
- '[0-9].[0-9][0-9].[0-9]'
pull_request:
paths:
- 'src/**'
- 'include/**'
- 'tests'
- 'test_package/**'
- 'tests/**'
- 'cmake/**'
- 'conanfile.py'
- 'conandata.yml'
- 'CMakeLists.txt'
- 'requirements.txt'
- '.github/workflows/unit-test.yml'
- '.github/workflows/requirements*'
branches:
- main
- master
- '[0-9].[0-9]'
- '[0-9].[0-9][0-9]'
tags:
- '[0-9].[0-9].[0-9]'
- '[0-9].[0-9][0-9].[0-9]'

env:
CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}
CONAN_LOGIN_USERNAME_CURA_CE: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD_CURA_CE: ${{ secrets.CONAN_PASS }}
CONAN_LOG_RUN_TO_OUTPUT: 1
CONAN_LOGGING_LEVEL: info
CONAN_NON_INTERACTIVE: 1
CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}
CONAN_LOGIN_USERNAME_CURA_CE: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD_CURA_CE: ${{ secrets.CONAN_PASS }}
CONAN_LOG_RUN_TO_OUTPUT: 1
CONAN_LOGGING_LEVEL: info
CONAN_NON_INTERACTIVE: 1

jobs:
conan-recipe-version:
uses: ultimaker/cura/.github/workflows/conan-recipe-version.yml@main
conan-recipe-version:
uses: ultimaker/cura/.github/workflows/conan-recipe-version.yml@main
with:
project_name: nest2d

testing:
runs-on: ubuntu-20.04
needs: [ conan-recipe-version ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python and pip
uses: actions/setup-python@v4
with:
project_name: nest2d

testing:
runs-on: ubuntu-20.04
needs: [ conan-recipe-version ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python and pip
uses: actions/setup-python@v4
with:
python-version: '3.10.x'
architecture: 'x64'
cache: 'pip'
cache-dependency-path: .github/workflows/requirements-conan-package.txt

- name: Install Python requirements and Create default Conan profile
run: |
pip install -r requirements-conan-package.txt
conan profile new default --detect
working-directory: .github/workflows/

- name: Use Conan download cache (Bash)
if: ${{ runner.os != 'Windows' }}
run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache"

- name: Cache Conan local repository packages (Bash)
uses: actions/cache@v3
if: ${{ runner.os != 'Windows' }}
with:
path: |
$HOME/.conan/data
$HOME/.conan/conan_download_cache
key: conan-${{ runner.os }}-${{ runner.arch }}

- name: Install Linux system requirements
if: ${{ runner.os == 'Linux' }}
run: sudo apt install build-essential checkinstall zlib1g-dev libssl-dev ninja-build autoconf libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev libxkbcommon-x11-dev -y

- name: Get Conan configuration
run: conan config install https://github.com/Ultimaker/conan-config.git

- name: Install dependencies
run: conan install . ${{ needs.conan-recipe-version.outputs.recipe_id_full }} -o enable_testing=True -s build_type=Release --build=missing --update -g GitHubActionsRunEnv -g GitHubActionsBuildEnv

- name: Upload the Dependency package(s)
run: conan upload "*" -r cura --all -c

- name: Set Environment variables from Conan install (bash)
if: ${{ runner.os != 'Windows' }}
run: |
. ./activate_github_actions_runenv.sh
. ./activate_github_actions_buildenv.sh
working-directory: build/Release/generators/

- name: Build Unit Test CuraEngine
run: |
cmake --preset release
cmake --build --preset release
- name: Run Unit Test CuraEngine
id: run-test
run: ctest --output-junit engine_test.xml
working-directory: build/Release/

- name: Publish Unit Test Results
id: test-results
uses: EnricoMi/publish-unit-test-result-action@v1
if: ${{ always() }}
with:
files: |
**/*.xml
- name: Conclusion
run: echo "Conclusion is ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}"
python-version: '3.10.x'
architecture: 'x64'
cache: 'pip'
cache-dependency-path: .github/workflows/requirements-conan-package.txt

- name: Install Python requirements and Create default Conan profile
run: |
pip install -r .github/workflows/requirements-conan-package.txt
# NOTE: Due to what are probably github issues, we have to remove the cache and reconfigure before the rest.
# This is maybe because grub caches the disk it uses last time, which is recreated each time.
- name: Install Linux system requirements
if: ${{ runner.os == 'Linux' }}
run: |
sudo rm /var/cache/debconf/config.dat
sudo dpkg --configure -a
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt update
sudo apt upgrade
sudo apt install build-essential checkinstall libegl-dev zlib1g-dev libssl-dev ninja-build autoconf libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev libxkbcommon-x11-dev pkg-config -y
- name: Install GCC-132 on ubuntu
run: |
sudo apt install g++-13 gcc-13 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
- name: Create the default Conan profile
run: conan profile new default --detect

- name: Get Conan configuration
run: |
conan config install https://github.com/Ultimaker/conan-config.git
conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/${{ runner.os }}/${{ runner.arch }}"
- name: Use Conan download cache (Bash)
if: ${{ runner.os != 'Windows' }}
run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache"

- name: Cache Conan local repository packages (Bash)
uses: actions/cache@v3
if: ${{ runner.os != 'Windows' }}
with:
path: |
$HOME/.conan/data
$HOME/.conan/conan_download_cache
key: conan-${{ runner.os }}-${{ runner.arch }}

- name: Install dependencies
run: conan install . ${{ needs.conan-recipe-version.outputs.recipe_id_full }} -s build_type=Release --build=missing --update -g GitHubActionsRunEnv -g GitHubActionsBuildEnv

- name: Upload the Dependency package(s)
run: conan upload "*" -r cura --all -c

- name: Set Environment variables from Conan install (bash)
if: ${{ runner.os != 'Windows' }}
run: |
. ./activate_github_actions_runenv.sh
. ./activate_github_actions_buildenv.sh
working-directory: build/Release/generators/

- name: Build Unit Test CuraEngine
run: |
cmake --preset release
cmake --build --preset release
- name: Run Unit Test CuraEngine
id: run-test
run: ctest --output-junit engine_test.xml
working-directory: build/Release/

- name: Publish Unit Test Results
id: test-results
uses: EnricoMi/publish-unit-test-result-action@v1
if: ${{ always() }}
with:
files: |
**/*.xml
- name: Conclusion
run: echo "Conclusion is ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}"
12 changes: 5 additions & 7 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from conan.tools.scm import Version


required_conan_version = ">=1.56.0"
required_conan_version = ">=1.58.0"


class Nest2DConan(ConanFile):
Expand All @@ -26,7 +26,6 @@ class Nest2DConan(ConanFile):
"fPIC": [True, False],
"tests": [True, False],
"header_only": [True, False],
"enable_testing": [True, False],
"geometries": ["clipper", "boost"],
"optimizer": ["nlopt", "optimlib"],
"threading": ["std", "tbb", "omp", "none"]
Expand All @@ -36,15 +35,14 @@ class Nest2DConan(ConanFile):
"tests": False,
"fPIC": True,
"header_only": False,
"enable_testing": False,
"geometries": "clipper",
"optimizer": "nlopt",
"threading": "std"
}

def set_version(self):
if self.version is None:
self.version = "5.3.0-alpha"
self.version = "5.4.0-alpha"

@property
def _min_cppstd(self):
Expand Down Expand Up @@ -98,7 +96,7 @@ def validate(self):

def build_requirements(self):
self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
if self.options.enable_testing:
if not self.conf.get("tools.build:skip_test", False, check_type = bool):
self.test_requires("catch2/[>=2.13.6]")


Expand All @@ -120,7 +118,7 @@ def configure(self):

def generate(self):
deps = CMakeDeps(self)
if self.options.enable_testing:
if not self.conf.get("tools.build:skip_test", False, check_type = bool):
deps.build_context_activated = ["catch2"]
deps.build_context_build_modules = ["catch2"]
deps.generate()
Expand All @@ -129,7 +127,7 @@ def generate(self):
tc.variables["HEADER_ONLY"] = self.options.header_only
if not self.options.header_only:
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
tc.variables["ENABLE_TESTING"] = self.options.enable_testing
tc.variables["ENABLE_TESTING"] = not self.conf.get("tools.build:skip_test", False, check_type = bool)
tc.variables["GEOMETRIES"] = self.options.geometries
tc.variables["OPTIMIZER"] = self.options.optimizer
tc.variables["THREADING"] = self.options.threading
Expand Down

0 comments on commit 9a8f4dd

Please sign in to comment.