diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile deleted file mode 100644 index fc2b76ed..00000000 --- a/.ci/Jenkinsfile +++ /dev/null @@ -1,204 +0,0 @@ -void cancelPrevious() { - stage("Cancelling previous") { - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > 1) milestone(buildNumber - 1) - milestone(buildNumber) - } -} - -def isPR = env.CHANGE_ID ? true : false - -def envInside(Map ctxt, Closure closure) { - String randDir = UUID.randomUUID().toString().substring(0, 4) - String venvDirectory = ctxt.runningUnix ? "${pwd()}/conanenv" : "${pwd()}\\conanenv" - String binPath = ctxt.runningUnix ? "$venvDirectory/bin/" : "$venvDirectory\\Scripts\\" - String conanHome = ctxt.runningUnix ? "${pwd()}/${randDir}/.conan" : "${pwd()}\\${randDir}\\.conan" - String cmakePath = ctxt.runningUnix ? "/Users/jenkins/cmake/cmake-3.23.1/bin" : "C:\\cmake\\cmake-3.23.1-win64-x64\\bin" - String pythonPath = ctxt.runningUnix ? "${env.WORKSPACE}/${ctxt.subDir}" : "${env.WORKSPACE}\\${ctxt.subDir}" - withEnv(["PATH+EXTRA=${binPath}", "PATH+CMAKE=${cmakePath}", "CONAN_HOME=${conanHome}", "PYTHONPATH=${pythonPath}"]) { - // This doesn't work if running docker.inside (https://issues.jenkins.io/browse/JENKINS-49076) - closure() - } -} - -def envCreate(Map ctxt) { - String venvDirectory = ctxt.runningUnix ? "${pwd()}/conanenv" : "${pwd()}\\conanenv" - String binPath = ctxt.runningUnix ? "$venvDirectory/bin/" : "$venvDirectory\\Scripts\\" - ctxt.shFunction("${ctxt.python_host} --version") - if (ctxt.isInsideDocker) { - // Alternate implementation because of https://issues.jenkins.io/browse/JENKINS-49076 - // Always install latest pre-release - ctxt.shFunction("pip install --upgrade pip") - ctxt.shFunction("pip uninstall -y conan") - ctxt.shFunction("pip install ${ctxt.branch.branchInstall} --upgrade") - ctxt.shFunction("pip install meson") - } - else { - ctxt.shFunction("${ctxt.python_host} -m venv $venvDirectory") - ctxt.shFunction("${binPath}python -m pip install -U pip") - // Always install latest pre-release - ctxt.shFunction("${binPath}python -m pip install ${ctxt.branch.branchInstall} --upgrade") - } -} - -String pipConanBranchInstall(String branch, String fork='conan-io') { - return "-e git+https://github.com/${fork}/conan.git@${branch}#egg=conan" -} - -// Run on latest development branch and latest released version -List getBranchesInstalls() { - def branches = [['name': 'latest Conan 2.0 release', 'branchInstall': 'conan']] - branches.add(0, ['name': 'develop Conan 2.0', 'branchInstall': pipConanBranchInstall('develop2')]) - return branches -} - -def runExample(Map ctxt, String example) { - for (extension in ctxt.extensions) { - if (example.contains(extension)) { - example = example.replace("\\","/") - split_path = example.split('/') - String script = split_path[split_path.length-1] - String path = example - script - script = ctxt.runningUnix ? "./${script}" : "${script}" - String command = script.contains(".py") ? "python ${script}" : "${script}" - dir("${path}") { - try { - echo "Running example: ${path}" - ctxt.shFunction("${command}") - } catch (Exception e) { - throw new Exception("Error running example ${example}: ${e.message}") - } - } - } - } -} - -def runExamples(Map ctxt) { - try { - ctxt.subDir = UUID.randomUUID().toString().substring(0, 4) - dir(ctxt.subDir) { - checkout scm - envCreate(ctxt) - envInside(ctxt) { - ctxt.shFunction("cmake --version") - ctxt.shFunction('conan profile detect --force') - if (ctxt.runningUnix) { - profile_path = sh(script: 'conan profile path default', returnStdout: true) - sh(script: "sed -i -e 's/gnu98/11/g' ${profile_path}") - } - echo "Running examples with CONAN_HOME: ${env.CONAN_HOME}" - for (example in ctxt.examples) { - runExample(ctxt, example) - } - } - } - } - finally { - cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, - cleanWhenSuccess: true, cleanWhenUnstable: true, disableDeferredWipeout: true, deleteDirs: true, - notFailBuild: true) - } -} - -def isMain() { - String mainBranch = 'main' - return env.BRANCH_NAME == mainBranch -} - -node('LinuxFunctional') { - - try { - cancelPrevious() - - List examples = [] - - // FIXME - // These examples won't run in the PR's at least until we have binaries for - // all libraries examples in CC to not slow down the ci on PR's - List skipExamplesInPR = ['tensorflow'] - List skipExamplesAlways = [] - - stage('Find examples') { - checkout scm - def _examples = sh(script: 'find . -name ci_test_example.*', returnStdout: true).readLines() - for (example in _examples) { - def shouldSkipinPR = skipExamplesInPR.any { skipExample -> example.contains(skipExample) } - def shouldSkipAlways = skipExamplesAlways.any { skipExample -> example.contains(skipExample) } - if ((example.contains(".sh") || example.contains(".bat") || example.contains(".py")) && (!shouldSkipinPR || !isPR) && (!shouldSkipAlways)) { - examples.add(example) - } - } - examples = examples.sort() - echo "Examples to run:\n - ${ examples.collect({ "$it" }).join('\n - ')}" - } - - if (!examples.isEmpty()) { - stage('Run examples') { - def conanBranchesInstalls = getBranchesInstalls() - parallel( - linux: { - conanBranchesInstalls.each { branch -> - stage("${branch.name}: Run Linux examples") { - def sourcedir = "/home/conan/" - def pyenvdir = "${sourcedir}.pyenv" - def pythonVersion = "3.9.2" - def command = "export PYENV_ROOT=${pyenvdir} && " \ - + "export PATH=\"${pyenvdir}/versions/\${pythonVersion}/bin:${pyenvdir}/bin:\$PATH\" && " \ - + "pyenv global ${pythonVersion} && " \ - + "sudo /home/conan/select_cmake.sh 3.23.5 && sudo /home/conan/select_gcc.sh 11" - sh(script: command) - runExamples([python_host: 'python3', - shFunction: { data -> sh(data) }, - isInsideDocker: true, - runningUnix: true, - examples: examples, - branch: branch, - extensions: ['.py', '.sh']]) - } - } - }, - macos: { - node('M2Macos') { - conanBranchesInstalls.each { branch -> - stage("${branch.name}: Run Macos examples") { - withEnv(["PYENV_ROOT=/Users/jenkins/.pyenv", "PATH+EXTRA=/Users/jenkins/.pyenv/shims:/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin"]) { - runExamples([python_host: '/Users/jenkins/.pyenv/versions/3.9.10/bin/python', - shFunction: { data -> sh(data) }, - isInsideDocker: false, - runningUnix: true, - examples: examples, - branch: branch, - extensions: ['.py', '.sh']]) - } - } - } - } - }, - windows: { - node('Windows') { - conanBranchesInstalls.each { branch -> - stage("${branch.name}: Run Windows examples") { - runExamples([python_host: 'C:\\Python39\\python.exe', - shFunction: { data -> bat(data) }, - isInsideDocker: false, - runningUnix: false, - examples: examples, - branch: branch, - extensions: ['.py', '.bat']]) - } - } - } - } - ) - } - } - } - catch(e){ - if (env.BRANCH_NAME == "main") { - def subject = "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'" - def summary = "${subject} (${env.BUILD_URL}), Conan Branch: ${env.BRANCH_NAME}" - slackSend (color: '#FF0000', message: summary) - } - throw e - } -} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..8b366664 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,68 @@ +name: Run Conan Examples + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + prepare: + runs-on: ubuntu-latest + outputs: + examples: ${{ steps.find.outputs.examples }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Find examples + id: find + run: | + examples=$(find . -name 'ci_test_example.*' | grep -E '\.py$|\.sh$' | sort | jq -R -s -c 'split("\n")[:-1]') + echo "examples=$examples" >> $GITHUB_OUTPUT + + run-macos: + needs: prepare + runs-on: macos-14 + strategy: + matrix: + branch: [ "conan", "develop2" ] + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.9" + + - name: Install Conan and tools + run: | + pip install -e "git+https://github.com/conan-io/conan.git@${{ matrix.branch }}#egg=conan" + pip install meson + + - name: Cache Homebrew packages + id: cache-brew + uses: actions/cache@v4 + with: + path: ~/Library/Caches/Homebrew + key: ${{ runner.os }}-brew + + - name: Install homebrew dependencies + run: | + brew install xcodegen make libtool zlib autoconf automake ninja + + - name: Run examples + run: | + examples=${{ needs.prepare.outputs.examples }} + echo "$examples" | jq -r '.[]' | while read example; do + echo "Running $example" + dir=$(dirname "$example") + script=$(basename "$example") + cd "$dir" + chmod +x "$script" + ./$(basename "$script") || exit 1 + cd - + done diff --git a/.github/workflows/ros-tests.yml b/.github/workflows/ros-tests.yml index 209c6563..11956148 100644 --- a/.github/workflows/ros-tests.yml +++ b/.github/workflows/ros-tests.yml @@ -18,11 +18,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Update ROS signing key (per ROS migration guide) - run: | - sudo rm /usr/share/keyrings/ros2-latest-archive-keyring.gpg - sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros2-latest-archive-keyring.gpg - - name: Configure environment and install Conan release run: | apt-get update && apt-get install -y python3 python3-pip @@ -44,11 +39,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Update ROS signing key (per ROS migration guide) - run: | - sudo rm /usr/share/keyrings/ros2-latest-archive-keyring.gpg - sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros2-latest-archive-keyring.gpg - - name: Configure environment and install Conan from develop2 branch run: | apt-get update && apt-get install -y python3 python3-pip