diff --git a/.github/workflows/build-conquest-python.yml b/.github/workflows/build-conquest-python.yml new file mode 100644 index 0000000..6d2cc42 --- /dev/null +++ b/.github/workflows/build-conquest-python.yml @@ -0,0 +1,106 @@ +# A github workflow file to build conquest python +name: Build Conquest Python + +on: # yamllint disable-line rule:truthy + workflow_dispatch: + inputs: + artifactory-push: + description: "Push result to Artifactory" + default: false + type: boolean + platforms: + description: 'Platform to build for, eg. ' + options: + - 'rocky8' + - 'ubuntu' + - 'macos' + - 'windows' + push: + paths: + - '.github/workflows/build-conquest-python.yml' + - 'build_conquest_python.py' + - 'ccdc/thirdparty/package.py' + +jobs: + setup: + runs-on: ubuntu-latest + outputs: + runson: ${{ steps.set_output.outputs.runson }} + container: ${{ steps.set_output.outputs.container }} + python: ${{ steps.set_output.outputs.python }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set output + id: set_output + run: | + if [[ "${{ inputs.platforms }}" == "rocky8" ]]; then + echo runson=ubuntu-latest >> $GITHUB_OUTPUT + echo container=ccdcrepository.azurecr.io/conan/rocky8-gcc10:latest >> $GITHUB_OUTPUT + echo python=python3 >> $GITHUB_OUTPUT + elif [[ "${{ inputs.platforms }}" == "ubuntu" ]]; then + echo runson=ubuntu-latest >> $GITHUB_OUTPUT + echo python=python3 >> $GITHUB_OUTPUT + elif [[ "${{ inputs.platforms }}" == "macos" ]]; then + echo runson=macos-12 >> $GITHUB_OUTPUT + echo python=python >> $GITHUB_OUTPUT + elif [[ "${{ inputs.platforms }}" == "windows" ]]; then + echo runson=windows-2019 >> $GITHUB_OUTPUT + echo python=python >> $GITHUB_OUTPUT + fi + + # Build the conquest python for rocky8 + echo runson=ubuntu-latest >> $GITHUB_OUTPUT + echo container=ccdcrepository.azurecr.io/conan/rocky8-gcc10:latest >> $GITHUB_OUTPUT + echo python=python3 >> $GITHUB_OUTPUT + + build-upload: + needs: + - setup + runs-on: ${{ needs.setup.outputs.runson }} + container: + image: ${{ needs.setup.outputs.container }} + credentials: + username: ${{ secrets.AZURE_CR_USER }} + password: ${{ secrets.AZURE_CR_PASSWORD }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + if: ${{ needs.setup.outputs.python == 'python' }} + with: + python-version: '3.9' + + - name: Set up Python environment + run: | + ${{ needs.setup.outputs.python }} --version + ${{ needs.setup.outputs.python }} -m pip install --upgrade pip wheel setuptools + + - name: Build conquest python + run: | + output=$(${{ needs.setup.outputs.python }} build_conquest_python.py | grep Creating | tail -n 1) + archive_filename=$(echo $output | awk '{print $2}') + archive_path=$(echo $output | awk '{print $NF}') + echo "archive_filename=$archive_filename" >> $GITHUB_ENV + echo "archive_path=$archive_path" >> $GITHUB_ENV + + - name: Set up JFrog CLI + if: ${{ inputs.artifactory-push }} + uses: jfrog/setup-jfrog-cli@v4 + env: + JF_ENV_1: ${{ secrets.ARTIFACTORY_GH_CCDC_3RDPARTY_PYTHON_INTERPRETERS_READ_WRITE_EXPORT }} + + - name: Upload conquest python to Artifactory + if: ${{ inputs.artifactory-push }} + shell: bash + run: | + # Upload the conquest python to Artifactory + jf c use gh-ccdc-3rdparty-python-interpreters-read-write + jfrog rt upload --flat \ + "${{ env.archive_path }}/${{ env.archive_filename }}" \ + "ccdc-3rdparty-python-interpreters/conquest_python/2.7/" diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 3e7bb74..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,112 +0,0 @@ -jobs: - - job: Centos7 - pool: - vmImage: "ubuntu-latest" - # We use a container to run the build as we must be compatible with centos7's older glibc - container: rockdreamer/centos7-gcc9:latest - variables: - artifactory.platformName: "centos7" - steps: - - task: CmdLine@2 - inputs: - script: "sudo yum -y install mesa-libGL-devel libX11-devel libXmu-devel libXft-devel unzip wget" - displayName: "Add prerequisites" - - task: CmdLine@2 - inputs: - script: "curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo" - displayName: "Add Microsoft repository" - - task: CmdLine@2 - inputs: - script: "sudo yum install -y powershell" - displayName: "Install PowerShell" - - task: CmdLine@2 - inputs: - script: "wget -O /tmp/cmake-3.17.1-Linux-x86_64.sh --no-check-certificate --quiet 'https://cmake.org/files/v3.17/cmake-3.17.1-Linux-x86_64.sh'" - displayName: "Fetch cmake" - - task: CmdLine@2 - inputs: - script: "sudo bash /tmp/cmake-3.17.1-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir" - displayName: "Install cmake" - # No need to setup specific python, the container's python3 will be used - - template: common-tasks.yml - - - job: Ubuntu - pool: - vmImage: "ubuntu-22.04" - variables: - artifactory.platformName: "ubuntu22.04" - steps: - - task: CmdLine@2 - inputs: - script: "sudo apt-get -y update" - displayName: "Apt update" - - task: CmdLine@2 - inputs: - script: "sudo apt-get -y upgrade" - displayName: "Apt upgrade" - - task: CmdLine@2 - inputs: - script: "sudo apt-get -y install libgl1-mesa-dev libxmuu-dev libx11-dev libxft-dev wget" - displayName: "Add prerequisites" - - task: CmdLine@2 - inputs: - script: "wget -O /tmp/cmake-3.17.1-Linux-x86_64.sh --no-check-certificate --quiet 'https://cmake.org/files/v3.17/cmake-3.17.1-Linux-x86_64.sh'" - displayName: "Fetch cmake" - - task: CmdLine@2 - inputs: - script: "sudo bash /tmp/cmake-3.17.1-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir" - displayName: "Install cmake" - - task: UsePythonVersion@0 - inputs: - versionSpec: "3.8" - displayName: "Use latest python 3.8" - # No need to setup specific python, the container's python3 will be used - - template: common-tasks.yml - - - job: macOS - pool: - vmImage: "macOS-13" - variables: - artifactory.platformName: "darwin" - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: "3.8" - displayName: "Use latest python 3.8" - # No need to setup specific python, the container's python3 will be used - - template: common-tasks.yml - - - job: WindowsVS2019 - pool: - vmImage: "windows-2019" - variables: - build_vs_version: "2019" - artifactory.platformName: "windows" - steps: - - task: ArtifactoryGenericDownload@3 - inputs: - connection: 'devops-ccdc-3rd-party' - specSource: 'taskConfiguration' - fileSpec: | - { - "files": [ - { - "pattern": "ccdc-3rdparty-python-interpreters/conquest-windows-build-requirements/", - "target": "$(System.ArtifactsDirectory)/" - } - ] - } - replaceSpecVars: true - failNoOp: true - displayName: "Download windows requirements from artifactory" - - task: CmdLine@2 - inputs: - script: "tree $(System.ArtifactsDirectory) /f" - displayName: "Contents of ArtifactsDirectory" - - - task: UsePythonVersion@0 - inputs: - versionSpec: "3.8" - displayName: "Use latest python 3.8" - # No need to setup specific python, the container's python3 will be used - - template: common-tasks.yml diff --git a/build_conquest_python.py b/build_conquest_python.py index b15a41e..a58fd3a 100755 --- a/build_conquest_python.py +++ b/build_conquest_python.py @@ -707,6 +707,17 @@ def main(): except OSError: pass + if Package().linux: + subprocess.run('sudo dnf update -y ', shell=True, check=True) + #subprocess.run("sudo dnf install -y 'dnf-command(config-manager)'", shell=True, check=True) + #subprocess.run('sudo dnf config-manager --enable powertools', shell=True, check=True) + #subprocess.run('sudo dnf install -y epel-release', shell=True, check=True) + subprocess.run( + 'sudo dnf install -y libXmu-devel', + shell=True, + check=True + ) + if not Package().windows: ZlibPackage().build() SqlitePackage().build() diff --git a/ccdc/thirdparty/package.py b/ccdc/thirdparty/package.py index f517b3e..3dbf34d 100644 --- a/ccdc/thirdparty/package.py +++ b/ccdc/thirdparty/package.py @@ -56,6 +56,8 @@ def ubuntu_version(self): @property def platform(self): + if sys.platform.startswith('linux'): + return 'linux' if not self.use_distribution_in_base_name: return sys.platform if not self.linux: @@ -138,8 +140,8 @@ def output_base_name(self): self.name, self.version, ] - if 'BUILD_BUILDNUMBER' in os.environ: - components.append(os.environ['BUILD_BUILDNUMBER']) + if 'GITHUB_RUN_NUMBER' in os.environ: + components.append(os.environ['GITHUB_RUN_NUMBER']) else: components.append('do-not-use-me-developer-version') components.append(self.platform) diff --git a/common-tasks.yml b/common-tasks.yml deleted file mode 100644 index 37bb550..0000000 --- a/common-tasks.yml +++ /dev/null @@ -1,74 +0,0 @@ -steps: -# Build using whatever the parent task provides us -- task: PythonScript@0 - inputs: - scriptSource: 'filePath' - scriptPath: build_conquest_python.py - displayName: 'install conquest_python' - -#### The new artifactory doesn't support sorting, so we can't do this task for now -## Upload artifactory build info -#- task: ArtifactoryCollectIssues@1 -# inputs: -# artifactoryService: 'devops-ccdc-3rd-party' -# configSource: 'taskConfiguration' -# taskConfig: | -# version: 1 -# issues: -# trackerName: JIRA -# regexp: '(.*?)\b\(?(Jira|JIRA|jira)?\s+([A-Za-z]{2,5}\d*-\d+)\)?' -# keyGroupIndex: 3 -# summaryGroupIndex: 1 -# trackerUrl: https://jira.ccdc.cam.ac.uk/issues -# aggregate: true -# aggregationStatus: RELEASED -# buildName: '$(Build.DefinitionName)' -# buildNumber: '$(Build.BuildNumber)-$(artifactory.platformName)' -# displayName: 'Collect issues' - -- powershell: | - $filename = Get-ChildItem -Path $(Build.ArtifactStagingDirectory) -Filter *.tar.gz | Select-Object -ExpandProperty Name - Write-Host "Filename: $filename" - if ($filename -match "conquest_python-([0-9]+\.[0-9]+)") { - $PythonVersion = $Matches[1] - Write-Host "Python version: $PythonVersion" - Write-Host "##vso[task.setvariable variable=PythonVersion]$PythonVersion" - } - else { - Write-Error "Unable to extract Python version from filename" - } - displayName: 'Extract Python version' - -- task: ArtifactoryGenericUpload@2 - inputs: - artifactoryService: 'devops-ccdc-3rd-party' - specSource: 'taskConfiguration' - fileSpec: | - { - "files": [ - { - "pattern": "$(Build.ArtifactStagingDirectory)/conquest_python*tar.gz", - "target": "ccdc-3rdparty-python-interpreters/conquest_python/$(PythonVersion)/" - } - ] - } - replaceSpecVars: true - collectBuildInfo: true - buildName: '$(Build.DefinitionName)' - buildNumber: '$(Build.BuildNumber)-$(artifactory.platformName)' - module: 'conquest_python/$(artifactory.platformName)' - includeEnvVars: true - failNoOp: true - env: - JFROG_CLI_TEMP_DIR: '$(Build.ArtifactStagingDirectory)' - displayName: 'Upload distribution to artifactory' - -- task: ArtifactoryPublishBuildInfo@1 - inputs: - artifactoryService: 'devops-ccdc-3rd-party' - buildName: '$(Build.DefinitionName)' - buildNumber: '$(Build.BuildNumber)-$(artifactory.platformName)' - excludeEnvVars: '*password*;*secret*;*key*;*token*;CL_USER;CL_PASSWORD' - env: - JFROG_CLI_TEMP_DIR: '$(Build.ArtifactStagingDirectory)' - displayName: 'Publish build'