diff --git a/.github/actions/clp-core-build/action.yaml b/.github/actions/clp-core-build/action.yaml deleted file mode 100644 index e627ec4fb0..0000000000 --- a/.github/actions/clp-core-build/action.yaml +++ /dev/null @@ -1,81 +0,0 @@ -name: "clp-core-build" -description: "Builds CLP-core in the specified container" - -inputs: - image_name: - description: "Name of the container image (without registry or repository) to use" - required: true - use_published_image: - description: "Whether to use the published container image" - required: true - use_shared_libs: - description: "Whether to build the core binaries by linking against shared libraries" - required: true - upload_binaries: - description: "Whether to upload the core binaries" - required: true - binaries_artifact_name: - description: "Name of the artifact containing the core binaries" - required: false - -runs: - using: "composite" - steps: - - if: "inputs.use_published_image == 'false'" - uses: "actions/download-artifact@v4" - with: - name: "${{inputs.image_name}}" - path: "/tmp" - - - if: "inputs.use_published_image == 'false'" - name: "Load image" - run: "docker load --input '/tmp/${{inputs.image_name}}.tar'" - shell: "bash" - - - id: "get_image_props" - run: | - if [[ "${{inputs.use_published_image}}" == "true" ]] ; then - # Docker doesn't support repository names with uppercase characters, so we convert to - # lowercase here. - repository=$(echo '${{github.repository}}' | tr '[:upper:]' '[:lower:]') - echo "qualified_image_name=ghcr.io/${repository}/${{inputs.image_name}}:main" \ - >> "$GITHUB_OUTPUT" - else - echo "qualified_image_name=${{inputs.image_name}}:latest" >> "$GITHUB_OUTPUT" - fi - shell: "bash" - - - run: "./tools/scripts/deps-download/init.sh" - shell: "bash" - - - run: >- - docker run - --user $(id -u):$(id -g) - --volume "$GITHUB_WORKSPACE":/mnt/clp - --workdir /mnt/clp - ${{steps.get_image_props.outputs.qualified_image_name}} - bash -c "task deps:core && - python3 /mnt/clp/components/core/tools/scripts/utils/build-and-run-unit-tests.py - ${{inputs.use_shared_libs == 'true' && '--use-shared-libs' || ''}} - --source-dir /mnt/clp/components/core - --build-dir /mnt/clp/components/core/build - --num-jobs $(getconf _NPROCESSORS_ONLN)" - shell: "bash" - - - if: "inputs.upload_binaries == 'true'" - id: "copy_binaries" - run: |- - output_dir="/tmp/${{inputs.binaries_artifact_name}}" - echo "output_dir=${output_dir}" >> "$GITHUB_OUTPUT" - - mkdir -p "${output_dir}" - cd "$GITHUB_WORKSPACE/components/core/build" - tar cfvv "${output_dir}/clp.tar" clg clp clp-s glt make-dictionaries-readable - shell: "bash" - - - if: "inputs.upload_binaries == 'true'" - uses: "actions/upload-artifact@v4" - with: - name: "${{inputs.binaries_artifact_name}}" - path: "${{steps.copy_binaries.outputs.output_dir}}" - retention-days: 1 diff --git a/.github/actions/run-on-image/action.yaml b/.github/actions/run-on-image/action.yaml new file mode 100644 index 0000000000..a96ebaec3a --- /dev/null +++ b/.github/actions/run-on-image/action.yaml @@ -0,0 +1,52 @@ +name: "run-on-image" +description: "Runs a command inside a downloaded/published container image with the repo mounted" + +inputs: + image_name: + description: "Name of the container image (without registry or repository) to use" + required: true + use_published_image: + description: "Whether to use the published container image" + required: true + run_command: + description: "Command to execute" + required: true + +runs: + using: "composite" + steps: + - if: "inputs.use_published_image == 'false'" + uses: "actions/download-artifact@v4" + with: + name: "${{inputs.image_name}}" + path: "/tmp" + + - if: "inputs.use_published_image == 'false'" + name: "Load image" + run: "docker load --input '/tmp/${{inputs.image_name}}.tar'" + shell: "bash" + + - id: "get_image_props" + run: | + if [[ "${{inputs.use_published_image}}" == "true" ]] ; then + # Docker doesn't support repository names with uppercase characters, so we convert to + # lowercase here. + repository=$(echo '${{github.repository}}' | tr '[:upper:]' '[:lower:]') + echo "qualified_image_name=ghcr.io/${repository}/${{inputs.image_name}}:main" \ + >> "$GITHUB_OUTPUT" + else + echo "qualified_image_name=${{inputs.image_name}}:latest" >> "$GITHUB_OUTPUT" + fi + shell: "bash" + + - run: "./tools/scripts/deps-download/init.sh" + shell: "bash" + + - run: >- + docker run + --user $(id -u):$(id -g) + --volume "$GITHUB_WORKSPACE":/mnt/repo + --workdir /mnt/repo + ${{steps.get_image_props.outputs.qualified_image_name}} + bash -c "${{inputs.run_command}}" + shell: "bash" diff --git a/.github/workflows/clp-core-build.yaml b/.github/workflows/clp-core-build.yaml index 2ea980df56..300443f3d8 100644 --- a/.github/workflows/clp-core-build.yaml +++ b/.github/workflows/clp-core-build.yaml @@ -3,8 +3,8 @@ name: "clp-core-build" on: pull_request: paths: - - ".github/actions/clp-core-build/action.yaml" - ".github/actions/clp-core-build-containers/action.yaml" + - ".github/actions/run-on-image/action.yaml" - ".github/workflows/clp-core-build.yaml" - ".gitmodules" - "components/core/**" @@ -14,8 +14,8 @@ on: - "!components/core/tools/scripts/lib_install/macos/**" push: paths: - - ".github/actions/clp-core-build/action.yaml" - ".github/actions/clp-core-build-containers/action.yaml" + - ".github/actions/run-on-image/action.yaml" - ".github/workflows/clp-core-build.yaml" - ".gitmodules" - "components/core/**" @@ -163,16 +163,21 @@ jobs: run: "chown $(id -u):$(id -g) -R ." shell: "bash" - - uses: "./.github/actions/clp-core-build" + - uses: "./.github/actions/run-on-image" env: OS_NAME: "centos-stream-9" with: image_name: "${{env.DEPS_IMAGE_NAME_PREFIX}}${{env.OS_NAME}}" - use_shared_libs: "${{matrix.use_shared_libs}}" use_published_image: >- ${{needs.filter-relevant-changes.outputs.centos_stream_9_image_changed == 'false' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')}} - upload_binaries: "false" + run_command: >- + task deps:core + && python3 /mnt/repo/components/core/tools/scripts/utils/build-and-run-unit-tests.py + ${{matrix.use_shared_libs == 'true' && '--use-shared-libs' || ''}} + --source-dir /mnt/repo/components/core + --build-dir /mnt/repo/components/core/build + --num-jobs $(getconf _NPROCESSORS_ONLN) ubuntu-jammy-binaries: # Run if the ancestor jobs succeeded OR they were skipped and clp was changed. @@ -189,6 +194,8 @@ jobs: upload_binaries: false - use_shared_libs: false upload_binaries: true + env: + OS_NAME: "ubuntu-jammy" name: "ubuntu-jammy-${{matrix.use_shared_libs && 'dynamic' || 'static'}}-linked-bins" continue-on-error: true runs-on: "ubuntu-latest" @@ -201,17 +208,37 @@ jobs: run: "chown $(id -u):$(id -g) -R ." shell: "bash" - - uses: "./.github/actions/clp-core-build" - env: - OS_NAME: "ubuntu-jammy" + - uses: "./.github/actions/run-on-image" with: image_name: "${{env.DEPS_IMAGE_NAME_PREFIX}}${{env.OS_NAME}}" - use_shared_libs: "${{matrix.use_shared_libs}}" use_published_image: >- ${{needs.filter-relevant-changes.outputs.ubuntu_jammy_image_changed == 'false' || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')}} - upload_binaries: "${{matrix.upload_binaries}}" - binaries_artifact_name: "${{env.BINARIES_ARTIFACT_NAME_PREFIX}}${{env.OS_NAME}}" + run_command: >- + task deps:core + && python3 /mnt/repo/components/core/tools/scripts/utils/build-and-run-unit-tests.py + ${{matrix.use_shared_libs == 'true' && '--use-shared-libs' || ''}} + --source-dir /mnt/repo/components/core + --build-dir /mnt/repo/components/core/build + --num-jobs $(getconf _NPROCESSORS_ONLN) + + - if: "matrix.upload_binaries == 'true'" + id: "copy_binaries" + run: |- + output_dir="/tmp/${{env.BINARIES_ARTIFACT_NAME_PREFIX}}${{env.OS_NAME}}" + echo "output_dir=${output_dir}" >> "$GITHUB_OUTPUT" + + mkdir -p "${output_dir}" + cd "$GITHUB_WORKSPACE/components/core/build" + tar cfvv "${output_dir}/clp.tar" clg clp clp-s glt make-dictionaries-readable + shell: "bash" + + - if: "matrix.upload_binaries == 'true'" + uses: "actions/upload-artifact@v4" + with: + name: "${{env.BINARIES_ARTIFACT_NAME_PREFIX}}${{env.OS_NAME}}" + path: "${{steps.copy_binaries.outputs.output_dir}}" + retention-days: 1 ubuntu-jammy-binaries-image: # Run if the ancestor jobs were successful/skipped, building clp was successful, and this is a