From 635dd0996e13f555d4c60e491f49b375195910b0 Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Sat, 14 Dec 2024 21:04:06 +0100 Subject: [PATCH] Remove ansible from macOS CI --- .github/workflows/ci-macos.yml | 38 ++++----- .github/workflows/ci-ubuntu.yml | 4 +- .github/workflows/mull-20.04.yml | 2 +- infrastructure/generator.py | 79 ++++++++++++------- ...tu.mustache => CMakePresets.json.mustache} | 8 +- 5 files changed, 72 insertions(+), 59 deletions(-) rename infrastructure/templates/cmake-presets/{ubuntu.mustache => CMakePresets.json.mustache} (82%) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 7a63a2270..97327b7c4 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -5,10 +5,11 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} on: - pull_request: push: branches: ["main"] tags: ["**"] + pull_request: + branches: ["main"] jobs: macos: @@ -16,38 +17,29 @@ jobs: runs-on: macos-latest strategy: matrix: - LLVM_VERSION: [13, 14, 15, 16, 17, 18] + include: + - OS_NAME: "macos" + LLVM_VERSION: 13 steps: - - name: Debugging - run: | - env | sort - cat $GITHUB_EVENT_PATH - - name: Fix git run: | git config --global --add safe.directory $PWD - - - name: Checkout sources - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - - uses: ./actions/detect-package-metadata id: metadata - name: Run CI task run: | - brew install ansible - cd infrastructure && \ - ansible-playbook macos-playbook.yaml \ - -e llvm_version="${{ matrix.LLVM_VERSION }}" \ - -e source_dir=$PWD/.. \ - -e gitref=$GITHUB_SHA \ - -e host=localhost \ - -e SDKROOT=`xcrun -show-sdk-path` \ - -e mull_version=${{ steps.metadata.outputs.version }}${{ steps.metadata.outputs.suffix }} \ - --verbose + pip3 install -r requirements.txt --break-system-packages --user + ./infrastructure/generator.py cmake --os macos --llvm_version ${{ matrix.LLVM_VERSION }} + cmake --preset mull -DMULL_VERSION=${{ steps.metadata.outputs.version }}${{ steps.metadata.outputs.suffix }} + cmake --workflow --preset build-and-test + cmake --workflow --preset package + ./end2end-tests/run_end2end_tests.sh ${{ matrix.LLVM_VERSION }} + mull-runner-${{ matrix.LLVM_VERSION }} --version - name: Publish package if: env.CLOUDSMITH_API_KEY != null @@ -57,12 +49,12 @@ jobs: --version ${{ steps.metadata.outputs.version }}${{ steps.metadata.outputs.suffix }} \ mull-project/mull-${{ steps.metadata.outputs.channel }} \ --tags macos \ - infrastructure/packages/`cat infrastructure/PACKAGE_FILE_NAME`.zip + infrastructure/packages/*.zip - name: Move package run: | mkdir -p /tmp/packages - mv infrastructure/packages/`cat infrastructure/PACKAGE_FILE_NAME`.zip /tmp/packages/`cat infrastructure/PACKAGE_FILE_NAME`.zip + mv infrastructure/packages/*.zip /tmp/packages/ - uses: ./actions/attach-package with: diff --git a/.github/workflows/ci-ubuntu.yml b/.github/workflows/ci-ubuntu.yml index 5f41978e7..591cbf5bb 100644 --- a/.github/workflows/ci-ubuntu.yml +++ b/.github/workflows/ci-ubuntu.yml @@ -8,8 +8,8 @@ on: push: branches: ["main"] tags: ["**"] - pull_request: - branches: ["main"] + # pull_request: + # branches: ["main"] jobs: build-and-test: diff --git a/.github/workflows/mull-20.04.yml b/.github/workflows/mull-20.04.yml index 0842cc8fc..e398a6269 100644 --- a/.github/workflows/mull-20.04.yml +++ b/.github/workflows/mull-20.04.yml @@ -1,7 +1,7 @@ name: Mull (20.04) on: - pull_request: + # pull_request: push: branches: ["main"] diff --git a/infrastructure/generator.py b/infrastructure/generator.py index 003692832..48166eaca 100755 --- a/infrastructure/generator.py +++ b/infrastructure/generator.py @@ -6,38 +6,53 @@ import shutil SUPPORTED_PLATFORMS = { - "ubuntu": { - "20.04": [12], - "22.04": [13, 14, 15], - "24.04": [14, 15, 16, 17, 18] - } + "ubuntu": {"20.04": [12], "22.04": [13, 14, 15], "24.04": [14, 15, 16, 17, 18]} } def cmake(args): - template_name = f"infrastructure/templates/cmake-presets/{args.os}.mustache" - template_args = {"LLVM_VERSION": args.llvm_version} + os_specific_args = { + "ubuntu": { + "CC": f"clang-{args.llvm_version}", + "CXX": f"clang++-{args.llvm_version}", + "CMAKE_PREFIX_PATH": f"/usr/lib/llvm-{args.llvm_version}/cmake/;/usr/lib/cmake/clang-{args.llvm_version}/", + }, + "macos": { + "CC": f"/opt/homebrew/opt/llvm@{args.llvm_version}/bin/clang", + "CXX": f"/opt/homebrew/opt/llvm@{args.llvm_version}/bin/clang++", + "CMAKE_PREFIX_PATH": f"/opt/homebrew/opt/llvm@{args.llvm_version}/lib/cmake/llvm/;/opt/homebrew/opt/llvm@{args.llvm_version}/lib/cmake/clang/", + }, + } + template_name = f"infrastructure/templates/cmake-presets/CMakePresets.json.mustache" + template_args = os_specific_args[args.os] + template_args["LLVM_VERSION"] = args.llvm_version + template_args["OS_NAME"] = args.os renderer = pystache.Renderer(missing_tags="strict") with open(template_name, "r") as t: result = renderer.render(t.read(), template_args) - with open('CMakePresets.json', "w") as f: + with open("CMakePresets.json", "w") as f: f.write(result) def devcontainers(args): shutil.rmtree(".devcontainer") - for (os_name, platform) in SUPPORTED_PLATFORMS.items(): + for os_name, platform in SUPPORTED_PLATFORMS.items(): template_folder = f"infrastructure/templates/devcontainers/{os_name}" - for (os_version, llvm_versions) in platform.items(): + for os_version, llvm_versions in platform.items(): for llvm_version in llvm_versions: - container_folder = f".devcontainer/{os_name}_{os_version}_{llvm_version}" + container_folder = ( + f".devcontainer/{os_name}_{os_version}_{llvm_version}" + ) os.makedirs(container_folder, exist_ok=True) - template_args = {"LLVM_VERSION": llvm_version, - "OS_NAME": os_name, "OS_VERSION": os_version} + template_args = { + "LLVM_VERSION": llvm_version, + "OS_NAME": os_name, + "OS_VERSION": os_version, + } renderer = pystache.Renderer(missing_tags="strict") - for template in ['devcontainer.json', "Dockerfile"]: + for template in ["devcontainer.json", "Dockerfile"]: template_name = f"{template_folder}/{template}.mustache" result_filename = f"{container_folder}/{template}" with open(template_name, "r") as t: @@ -53,13 +68,16 @@ def gh_workflows(args): strategies = [] for os_version in sorted(SUPPORTED_PLATFORMS["ubuntu"].keys()): for llvm_version in SUPPORTED_PLATFORMS["ubuntu"][os_version]: - arg = {"OS_NAME": "ubuntu", "OS_VERSION": os_version, - "LLVM_VERSION": llvm_version} + arg = { + "OS_NAME": "ubuntu", + "OS_VERSION": os_version, + "LLVM_VERSION": llvm_version, + } strategies.append(arg) template_args = {"strategy": strategies, "OS_NAME": "Ubuntu"} renderer = pystache.Renderer(missing_tags="strict") - for template in ['ci-ubuntu.yml']: + for template in ["ci-ubuntu.yml"]: template_name = f"{template_folder}/{template}.mustache" result_filename = f"{workflow_folder}/{template}" with open(template_name, "r") as t: @@ -70,21 +88,24 @@ def gh_workflows(args): def main(): parser = argparse.ArgumentParser( - prog='generator', description='Generates various infra files for Mull') + prog="generator", description="Generates various infra files for Mull" + ) subparsers = parser.add_subparsers( - title='subcommands', help='available subcommands', dest="cmd") - - parser_cmake = subparsers.add_parser( - 'cmake', help='Generates CMake preset file') - parser_cmake.add_argument('--os', choices=('ubuntu',), - help='Select OS for which to generate preset', type=str) + title="subcommands", help="available subcommands", dest="cmd" + ) + + parser_cmake = subparsers.add_parser("cmake", help="Generates CMake preset file") + parser_cmake.add_argument( + "--os", + choices=("ubuntu", "macos"), + help="Select OS for which to generate preset", + type=str, + ) parser_cmake.add_argument("--llvm_version", type=int) - subparsers.add_parser('devcontainers', help='Generates devcontainer files') - subparsers.add_parser('github_workflows', - help='Generates GitHub workflow files') - subparsers.add_parser('all', - help='Combines devcontainers and github_workflows') + subparsers.add_parser("devcontainers", help="Generates devcontainer files") + subparsers.add_parser("github_workflows", help="Generates GitHub workflow files") + subparsers.add_parser("all", help="Combines devcontainers and github_workflows") args = parser.parse_args() if args.cmd == "cmake": diff --git a/infrastructure/templates/cmake-presets/ubuntu.mustache b/infrastructure/templates/cmake-presets/CMakePresets.json.mustache similarity index 82% rename from infrastructure/templates/cmake-presets/ubuntu.mustache rename to infrastructure/templates/cmake-presets/CMakePresets.json.mustache index c159f7326..ad1f8422d 100644 --- a/infrastructure/templates/cmake-presets/ubuntu.mustache +++ b/infrastructure/templates/cmake-presets/CMakePresets.json.mustache @@ -4,12 +4,12 @@ { "name": "mull", "generator": "Ninja", - "binaryDir": "${sourceDir}/build.{{{LLVM_VERSION}}}.dir", + "binaryDir": "${sourceDir}/build.{{OS_NAME}}.{{{LLVM_VERSION}}}.dir", "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", - "CMAKE_C_COMPILER": "clang-{{LLVM_VERSION}}", - "CMAKE_CXX_COMPILER": "clang++-{{LLVM_VERSION}}", - "CMAKE_PREFIX_PATH": "/usr/lib/llvm-{{LLVM_VERSION}}/cmake/;/usr/lib/cmake/clang-{{LLVM_VERSION}}/" + "CMAKE_C_COMPILER": "{{CC}}", + "CMAKE_CXX_COMPILER": "{{CXX}}", + "CMAKE_PREFIX_PATH": "{{CMAKE_PREFIX_PATH}}" } } ],