From 134291d0245a5967c99246d71b5c91bc89dab008 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Fri, 6 Sep 2024 13:34:01 +0200 Subject: [PATCH 01/86] ROCKS 1452 - Refactor Build Rock workflow to be externally reusable --- .github/workflows/Build-Rock.yaml | 315 ++++++++++-------- .github/workflows/Image.yaml | 32 +- .github/workflows/_Test-OCI-Factory.yaml | 3 + oci/mock-rock/_releases.json | 20 +- src/build_rock/assemble_rock/assemble.sh | 54 +++ src/build_rock/assemble_rock/requirements.sh | 6 + .../configure/generate_build_matrix.py | 139 ++++++++ src/build_rock/configure/requirements.txt | 1 + src/build_rock/lpci_build/lpci_build.sh | 58 ++++ src/shared/github_output.py | 27 ++ src/shared/release_info.py | 2 +- .../test_convert_junit_xml_to_markdown.py | 18 + tests/unit/test_generate_build_matrix.py | 101 ++++++ tests/unit/test_github_output.py | 54 +++ 14 files changed, 668 insertions(+), 162 deletions(-) create mode 100755 src/build_rock/assemble_rock/assemble.sh create mode 100755 src/build_rock/assemble_rock/requirements.sh create mode 100755 src/build_rock/configure/generate_build_matrix.py create mode 100644 src/build_rock/configure/requirements.txt create mode 100755 src/build_rock/lpci_build/lpci_build.sh create mode 100755 src/shared/github_output.py mode change 100755 => 100644 src/shared/release_info.py create mode 100644 tests/integration/test_convert_junit_xml_to_markdown.py create mode 100644 tests/unit/test_generate_build_matrix.py create mode 100755 tests/unit/test_github_output.py diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 495c8650..20dc4ca7 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -1,206 +1,227 @@ -name: Build rock +name: Build Rock on: workflow_call: inputs: + # build configuration oci-archive-name: - description: "Final filename of the rock's OCI archive" + description: "Final filename of the Rock OCI archive." type: string required: true - oci-factory-path: - description: "Path, in the OCI Factory, to this rock" + arch-map: + description: "JSON string mapping target architecture to runner." type: string - required: true - rock-name: - description: "Name of the rock" - type: string - required: true + default: '{"amd64": "ubuntu-22.04"}' + lpci-fallback: + description: 'Enable fallback to Launchpad build when runners for target arch are not available.' + type: boolean + default: false + + # source configuration rock-repo: - description: "Public Git repo where to build the rock from" + description: "Public Git repo where to build the rock from." type: string required: true rock-repo-commit: - description: "Git ref from where to build the rock from" + description: "Git ref from where to build the rock from." type: string required: true rockfile-directory: - description: "Directory, in 'rock-repo', where to find the rockcraft.yaml file" + description: "Directory in repository where to find the rockcraft.yaml file." type: string required: true + env: - ROCKS_CI_FOLDER: ci-rocks + ROCK_REPO_DIR: rock-repo # path where the image repo is cloned to + ROCK_CI_FOLDER: ci-rocks # path of uploaded/downloaded artifacts + + OCI_FACTORY_REPO: canonical/oci-factory + # TODO: update before final merge + OCI_FACTORY_BRANCH: ROCKS-1452/oci-factory-refactor-build-rock-to-be-externally-reusable # required for external workflow calls. jobs: - prepare-multi-arch-matrix: + + configure-build: + # configure-build reads the rockcraft.yaml, creating one or more *-build job runs + # depending on the target architecture. runs-on: ubuntu-22.04 outputs: - build-for: ${{ steps.rock-platforms.outputs.build-for }} - build-with-lpci: ${{ steps.rock-platforms.outputs.build-with-lpci }} + runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} + lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} steps: - - name: Clone GitHub image repository - uses: actions/checkout@v4 - id: clone-image-repo - continue-on-error: true + + # Job Setup + - uses: actions/checkout@v4 with: - repository: ${{ inputs.rock-repo }} - fetch-depth: 0 - - name: Clone generic image repository - if: ${{ steps.clone-image-repo.outcome == 'failure' }} - run: | - git clone ${{ inputs.rock-repo }} . - - run: git checkout ${{ inputs.rock-repo-commit }} - - run: sudo snap install yq --channel=v4/stable - - name: Validate image naming and base - working-directory: ${{ inputs.rockfile-directory }} - run: | - rock_name=`cat rockcraft.y*ml | yq -r .name` - if [[ "${{ inputs.oci-factory-path }}" != *"${rock_name}"* ]] - then - echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name!" - exit 1 - fi + repository: ${{ env.OCI_FACTORY_REPO }} + ref: ${{ env.OCI_FACTORY_BRANCH }} + fetch-depth: 1 + - uses: actions/setup-python@v5 with: - python-version: '3.x' - - run: pip install pyyaml - - name: Get rock archs - uses: jannekem/run-python-script-action@v1 - id: rock-platforms + python-version: "3.x" + + - run: pip install -r src/build_rock/configure/requirements.txt + + + - uses: actions/checkout@v4 with: - script: | - import yaml - import os - - BUILD_WITH_LPCI = 0 - - with open("${{ inputs.rockfile-directory }}/rockcraft.yaml") as rf: - rockcraft_yaml = yaml.safe_load(rf) - - platforms = rockcraft_yaml["platforms"] - - target_archs = [] - for platf, values in platforms.items(): - if isinstance(values, dict) and "build-for" in values: - target_archs += list(values["build-for"]) - continue - target_archs.append(platf) - - print(f"Target architectures: {set(target_archs)}") - - matrix = {"include": []} - gh_supported_archs = {"amd64": "ubuntu-22.04", "arm64": "Ubuntu_ARM64_4C_16G_01"} - if set(target_archs) - set(gh_supported_archs.keys()): - # Then there are other target archs, so we need to build in LP - matrix["include"].append( - {"architecture": "-".join(set(target_archs)), "runner": gh_supported_archs["amd64"]} - ) - BUILD_WITH_LPCI = 1 - else: - for runner_arch, runner_name in gh_supported_archs.items(): - if runner_arch in target_archs: - matrix["include"].append( - {"architecture": runner_arch, "runner": runner_name} - ) - - with open(os.environ["GITHUB_OUTPUT"], "a") as gh_out: - print(f"build-for={matrix}", file=gh_out) - print(f"build-with-lpci={BUILD_WITH_LPCI}", file=gh_out) - - build: - needs: [prepare-multi-arch-matrix] + repository: ${{ inputs.rock-repo }} + path: ${{ env.ROCK_REPO_DIR }} + ref: ${{ inputs.rock-repo-commit }} + submodules: 'recursive' + + + # Configure matrices for each *-build job + - name: Configure + id: configure + run: | + python3 -m src.build_rock.configure.generate_build_matrix \ + --rockfile-directory "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}" \ + --lpci-fallback "${{ toJSON(inputs.lpci-fallback) }}" \ + --config ${{ toJSON(inputs.arch-map) }} # important: do not use quotes here + + + runner-build: + # runner-build builds rocks per target architecture using pre configured runner images. + needs: [configure-build] + if: fromJSON(needs.configure-build.outputs.runner-build-matrix).include[0] != '' strategy: fail-fast: true - matrix: ${{ fromJSON(needs.prepare-multi-arch-matrix.outputs.build-for) }} - runs-on: ${{ matrix.runner }} - name: 'Build ${{ inputs.rock-name }} | ${{ matrix.architecture }}' + matrix: ${{ fromJSON(needs.configure-build.outputs.runner-build-matrix) }} + runs-on: ${{ matrix.runner }} + name: 'runner-build | ${{ matrix.architecture }} ' steps: - - name: Clone GitHub image repository + + - name: Clone Repo uses: actions/checkout@v4 - id: clone-image-repo - continue-on-error: true with: repository: ${{ inputs.rock-repo }} - fetch-depth: 0 - - name: Clone generic image repository - if: ${{ steps.clone-image-repo.outcome == 'failure' }} - run: | - git clone ${{ inputs.rock-repo }} . - - run: git checkout ${{ inputs.rock-repo-commit }} - - name: Build rock ${{ inputs.rock-name }} + path: ${{ env.ROCK_REPO_DIR }} + ref: ${{ inputs.rock-repo-commit }} + submodules: 'recursive' + + + - name: Build Target id: rockcraft - if: needs.prepare-multi-arch-matrix.outputs.build-with-lpci == 0 uses: canonical/craft-actions/rockcraft-pack@main with: - path: "${{ inputs.rockfile-directory }}" + path: "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}" verbosity: debug - - uses: actions/setup-python@v5 - if: needs.prepare-multi-arch-matrix.outputs.build-with-lpci == 1 + + + - name: Collect Artifacts + id: collect-artifacts + run: | + mkdir -p ${{ env.ROCK_CI_FOLDER }} && cp ${{ steps.rockcraft.outputs.rock }} "$_" + echo "filename=$(basename ${{ steps.rockcraft.outputs.rock }})" >> $GITHUB_OUTPUT + + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 with: - python-version: '3.x' - - uses: nick-fields/retry@v3.0.0 - name: Build multi-arch ${{ inputs.rock-name }} in Launchpad - if: needs.prepare-multi-arch-matrix.outputs.build-with-lpci == 1 + name: ${{ inputs.oci-archive-name }}-${{ steps.collect-artifacts.outputs.filename }} + path: ${{ env.ROCK_CI_FOLDER }} + if-no-files-found: error + + + lpci-build: + # lpci-build is a fallback for building rocks if no suitable runners are + # configured for the required architecture. Builds in this job will be + # outsourced to Launchpad for completion. + # Note the Secret + needs: [configure-build] + if: fromJSON(needs.configure-build.outputs.lpci-build-matrix).include[0] != '' + strategy: + fail-fast: true + matrix: ${{ fromJSON(needs.configure-build.outputs.lpci-build-matrix) }} + runs-on: ubuntu-22.04 + name: 'lpci-build | ${{ matrix.architecture }} ' + steps: + + # Job Setup + - uses: actions/checkout@v4 + with: + repository: ${{ env.OCI_FACTORY_REPO }} + ref: ${{ env.OCI_FACTORY_BRANCH }} + fetch-depth: 1 + + + - name: Clone Repo + uses: actions/checkout@v4 + with: + repository: ${{ inputs.rock-repo }} + path: ${{ env.ROCK_REPO_DIR }} + ref: ${{ inputs.rock-repo-commit }} + submodules: 'recursive' + + + - name: Build Target + # TODO: Replace this retry action with bash equivalent for better testing + uses: nick-fields/retry@v3.0.0 with: timeout_minutes: 180 max_attempts: 4 polling_interval_seconds: 5 retry_wait_seconds: 30 command: | - set -ex - cd ${{ inputs.rockfile-directory }} - rocks_toolbox="$(mktemp -d)" - git clone --depth 1 --branch v1.1.2 https://github.com/canonical/rocks-toolbox $rocks_toolbox - ${rocks_toolbox}/rockcraft_lpci_build/requirements.sh - pip3 install -r ${rocks_toolbox}/rockcraft_lpci_build/requirements.txt - - python3 ${rocks_toolbox}/rockcraft_lpci_build/rockcraft_lpci_build.py \ - --lp-credentials-b64 "${{ secrets.LP_CREDENTIALS_B64 }}" \ - --launchpad-accept-public-upload - - name: Rename rock OCI archive - id: rock + src/build_rock/lpci_build/lpci_build.sh \ + -c "${{ secrets.LP_CREDENTIALS_B64 }}" \ + -d "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}" + + + - name: Collect Artifacts + id: collect-artifacts run: | - mkdir ${{ env.ROCKS_CI_FOLDER }} - if [ ${{ needs.prepare-multi-arch-matrix.outputs.build-with-lpci }} -eq 0 ] - then - cp ${{ steps.rockcraft.outputs.rock }} ${{ env.ROCKS_CI_FOLDER }}/$(basename ${{ steps.rockcraft.outputs.rock }}) - echo "filename=$(basename ${{ steps.rockcraft.outputs.rock }})" >> $GITHUB_OUTPUT - else - cp ${{ inputs.rockfile-directory }}/*.rock ${{ env.ROCKS_CI_FOLDER }} - echo "filename=${{ inputs.rock-name }}_${{ matrix.architecture }}" >> $GITHUB_OUTPUT - fi - - name: Upload ${{ inputs.rock-name }} for ${{ matrix.architecture }} + mkdir -p ${{ env.ROCK_CI_FOLDER }} && cp ${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/*.rock "$_" + echo "filename=${{ matrix.rock-name }}_${{ matrix.architecture }}" >> $GITHUB_OUTPUT + + + - name: Upload Artifacts uses: actions/upload-artifact@v4 with: - name: ${{ inputs.oci-archive-name }}-${{ steps.rock.outputs.filename }} - path: ${{ env.ROCKS_CI_FOLDER }} + name: ${{ inputs.oci-archive-name }}-${{ steps.collect-artifacts.outputs.filename }} + path: ${{ env.ROCK_CI_FOLDER }} if-no-files-found: error + assemble-rock: - needs: [prepare-multi-arch-matrix, build] + # Assemble individual single-arch rocks into multi-arch rocks + needs: [configure-build, runner-build, lpci-build] runs-on: ubuntu-22.04 + # Always run even if one of the *-build jobs are skipped + # Nice example from benjamin-bergia/github-workflow-patterns... + if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }} steps: - - uses: actions/download-artifact@v4 + + # Job Setup + - uses: actions/checkout@v4 + with: + repository: ${{ env.OCI_FACTORY_REPO }} + ref: ${{ env.OCI_FACTORY_BRANCH }} + fetch-depth: 1 + + - run: src/build_rock/assemble_rock/requirements.sh + + + - name: Download Single Arch Rocks + uses: actions/download-artifact@v4 id: download - - run: sudo apt update && sudo apt install buildah -y - - name: Merge single-arch rocks into multi-arch OCI archive + with: + path: ${{ env.ROCK_CI_FOLDER }} + + + - name: Assemble Multi Arch Rock run: | - set -xe - ls ./${{ inputs.oci-archive-name }}* - buildah manifest create multi-arch-rock - for rock in `find ${{ inputs.oci-archive-name }}*/*.rock` - do - test -f $rock - buildah manifest add multi-arch-rock oci-archive:$rock - done - buildah manifest push --all multi-arch-rock oci-archive:${{ inputs.oci-archive-name }} - - name: Upload multi-arch ${{ inputs.oci-archive-name }} OCI archive + src/build_rock/assemble_rock/assemble.sh \ + -n "${{ inputs.oci-archive-name }}" \ + -d "${{ env.ROCK_CI_FOLDER }}" + + + - name: Upload Multi Arch Rock uses: actions/upload-artifact@v4 with: name: ${{ inputs.oci-archive-name }} path: ${{ inputs.oci-archive-name }} - if-no-files-found: error - - uses: actions/cache/save@v4 - with: - path: ${{ inputs.oci-archive-name }} - key: ${{ github.run_id }}-${{ inputs.oci-archive-name }} + if-no-files-found: error \ No newline at end of file diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index ae393492..8325b895 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -115,6 +115,7 @@ jobs: --oci-path ${{ steps.validate-image.outputs.img-path }} \ --revision-data-dir ${{ env.DATA_DIR }} \ + run-build: needs: [prepare-build] strategy: @@ -122,16 +123,39 @@ jobs: matrix: ${{ fromJSON(needs.prepare-build.outputs.build-matrix) }} uses: ./.github/workflows/Build-Rock.yaml with: - oci-archive-name: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} - oci-factory-path: ${{ matrix.path }} - rock-name: ${{ matrix.name }} + oci-archive-name: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} rock-repo: ${{ matrix.source }} rock-repo-commit: ${{ matrix.commit }} rockfile-directory: ${{ matrix.directory }} + arch-map: '{"amd64": "ubuntu-22.04", "arm64": "Ubuntu_ARM64_4C_16G_01"}' + lpci-fallback: true secrets: inherit - test: + tmp-cache-job: + # Note: This is a temporary job that will be removed when the refactored test job is merged. + # Going forward we download the built rocks from artifacts instead of cache. This job takes + # the uploaded rocks then re-caches them for compatibility. + name: Temporary step to cache rocks + runs-on: ubuntu-22.04 needs: [prepare-build, run-build] + strategy: + fail-fast: true + matrix: ${{ fromJSON(needs.prepare-build.outputs.build-matrix) }} + steps: + + - name: Download Rock + uses: actions/download-artifact@v4 + with: + name: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} + + - uses: actions/cache/save@v4 + with: + key: ${{ github.run_id }}-${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} + path: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} + + + test: + needs: [prepare-build, run-build, tmp-cache-job] name: Test strategy: fail-fast: true diff --git a/.github/workflows/_Test-OCI-Factory.yaml b/.github/workflows/_Test-OCI-Factory.yaml index e9708a04..729eaf0d 100644 --- a/.github/workflows/_Test-OCI-Factory.yaml +++ b/.github/workflows/_Test-OCI-Factory.yaml @@ -45,6 +45,9 @@ jobs: # test-oci-factory/pytest requirements - run: pip install -r tests/etc/requirements.txt + # build_rock/configure requirements + - run: pip install -r src/build_rock/configure/requirements.txt + - name: Run pytest continue-on-error: true diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index eb4e52da..f3740785 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -13,13 +13,13 @@ }, "1.0-22.04": { "candidate": { - "target": "478" + "target": "481" }, "beta": { - "target": "478" + "target": "481" }, "edge": { - "target": "478" + "target": "481" }, "end-of-life": "2025-05-01T00:00:00Z" }, @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "479" + "target": "482" }, "beta": { - "target": "479" + "target": "482" }, "edge": { - "target": "479" + "target": "482" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "479" + "target": "482" }, "beta": { - "target": "479" + "target": "482" }, "edge": { - "target": "479" + "target": "482" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "480" + "target": "483" }, "edge": { "target": "1.2-22.04_beta" diff --git a/src/build_rock/assemble_rock/assemble.sh b/src/build_rock/assemble_rock/assemble.sh new file mode 100755 index 00000000..3d149477 --- /dev/null +++ b/src/build_rock/assemble_rock/assemble.sh @@ -0,0 +1,54 @@ +#! /bin/bash + +set -e + + +function usage(){ + echo + echo "$(basename "$0") -d -n " + echo + echo "Merge multiple OCI Rock images into one multi arch image." + echo + echo -e "-d \\t Directory to search for rock OCI images in." + echo -e "-n \\t Final output archive name. " +} + +while getopts "d:n:" opt +do + case $opt in + d) + ROCK_DIR="$OPTARG" + ;; + n) + ARCHIVE_NAME="$OPTARG" + ;; + ?) + usage + exit 1 + ;; + esac +done + +if [ -z "$ROCK_DIR" ] +then + echo "Error: Missing rock search directory argument (-d)" + usage + exit 1 +fi + +if [ -z "$ARCHIVE_NAME" ] +then + echo "Error: Missing final archive name (-n)" + usage + exit 1 +fi + +buildah manifest create multi-arch-rock + +for rock in `find "$ROCK_DIR" -name "*.rock" -type f` +do + buildah manifest add multi-arch-rock oci-archive:$rock +done + +buildah manifest push --all multi-arch-rock "oci-archive:$ARCHIVE_NAME" + diff --git a/src/build_rock/assemble_rock/requirements.sh b/src/build_rock/assemble_rock/requirements.sh new file mode 100755 index 00000000..1ff6d0d0 --- /dev/null +++ b/src/build_rock/assemble_rock/requirements.sh @@ -0,0 +1,6 @@ +#! /bin/bash + +set -e + +sudo apt update +sudo apt install buildah -y diff --git a/src/build_rock/configure/generate_build_matrix.py b/src/build_rock/configure/generate_build_matrix.py new file mode 100755 index 00000000..dae4f2a0 --- /dev/null +++ b/src/build_rock/configure/generate_build_matrix.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python3 + +import yaml +import os +import argparse +import json +from enum import Enum +from typing import Optional +from ...shared import github_output + + +class MATRIX_NAMES(Enum): + RUNNER = "runner-build-matrix" + LPCI = "lpci-build-matrix" + + +class MissingArchSupport(Exception): + pass + + +def get_target_archs(rockcraft: dict) -> list: + """get list of target architectures from rockcraft project definition""" + + rock_platforms = rockcraft["platforms"] + + target_archs = set() + + for platf, values in rock_platforms.items(): + + if isinstance(values, dict) and "build-for" in values: + # TODO: Should this be "build-on"? + # https://documentation.ubuntu.com/rockcraft/en/latest/reference/rockcraft.yaml/#platforms-entry-build-on + if isinstance(arches := values["build-for"], list): + target_archs.update(arches) + elif isinstance(values, str): + target_archs.add(arches) + else: + target_archs.add(platf) + + return target_archs + + +def configure_matrices(target_archs: list, arch_map: dict, lp_fallback: bool) -> dict: + """Sort build into appropriate build matrices""" + + # map configuration to individual job matrices + build_matrices = {name.value: {"include": []} for name in MATRIX_NAMES} + + # Check if we have runners for all supported architectures + if missing_archs := set(target_archs) - set(arch_map.keys()): + + # raise exception if we cannot fallback to LP builds + if not lp_fallback: + raise MissingArchSupport( + f"Missing support for runner arches: {missing_archs}" + ) + + # configure LP build + build_matrices[MATRIX_NAMES.LPCI.value]["include"].append( + {"architecture": "-".join(set(target_archs))} + ) + + else: + # configure runner matrix for list of supported runners + for runner_arch, runner_name in arch_map.items(): + if runner_arch in target_archs: + build_matrices[MATRIX_NAMES.RUNNER.value]["include"].append( + {"architecture": runner_arch, "runner": runner_name} + ) + + return build_matrices + + +def set_build_config_outputs( + rock_name: str, build_matrices: dict, output_path: Optional[str] = None +): + """Update GITHUB_OUTPUT with build configuration.""" + + outputs = {"rock-name": rock_name, **build_matrices} + + # set default when not testing + if output_path is None: + output_path = os.environ["GITHUB_OUTPUT"] + + with open(output_path, "a") as fh: + github_output.write(fh, **outputs) + + +def main(): + parser = argparse.ArgumentParser() + + parser.add_argument( + "--rockfile-directory", + help="Path where to directory containing rockcraft.yaml.", + required=True, + ) + + parser.add_argument( + "--lpci-fallback", + help="Revert to lpci if architectures are not supported. ", + required=True, + type=str, + ) + + parser.add_argument( + "--config", + help="JSON mapping arch to runner for matrix generation.", + required=True, + ) + + args = parser.parse_args() + + # get configuration form rockcraft yaml + with open(f"{args.rockfile_directory}/rockcraft.yaml") as rf: + rockcraft_yaml = yaml.safe_load(rf) + + # load config + arch_map = json.loads(args.config) + + # check input of lpci_fallback which should be an explicit boolean + try: + # use json.loads for conveniently casting string to bool + lpci_fallback = json.loads(args.lpci_fallback.lower()) + + if not isinstance(lpci_fallback, bool): + raise TypeError("Expected bool type") + + except (TypeError, json.decoder.JSONDecodeError) as exc: + raise ValueError('--lpci-fallback expected "true" or "false" value') from exc + + target_archs = get_target_archs(rockcraft_yaml) + build_matrices = configure_matrices(target_archs, arch_map, lpci_fallback) + + # set github outputs for use in later steps + set_build_config_outputs(rockcraft_yaml["name"], build_matrices) + + +if __name__ == "__main__": + main() diff --git a/src/build_rock/configure/requirements.txt b/src/build_rock/configure/requirements.txt new file mode 100644 index 00000000..aa4d4d06 --- /dev/null +++ b/src/build_rock/configure/requirements.txt @@ -0,0 +1 @@ +pyyaml==6.0.2 diff --git a/src/build_rock/lpci_build/lpci_build.sh b/src/build_rock/lpci_build/lpci_build.sh new file mode 100755 index 00000000..35849730 --- /dev/null +++ b/src/build_rock/lpci_build/lpci_build.sh @@ -0,0 +1,58 @@ +#! /bin/bash + + +set -e + + +function usage(){ + echo + echo "$(basename "$0") -d -c " + echo + echo "Build local rockcraft project on Launchpad." + echo + echo -e "-d \\t Directory to rockcraft project file. " + echo -e "-c \\t Launchpad credentials. " +} + +while getopts "c:d:" opt +do + case $opt in + d) + ROCKCRAFT_DIR="$OPTARG" + ;; + c) + LC_CREDENTIALS_B64="$OPTARG" + ;; + ?) + usage + exit 1 + ;; + esac +done + +if [ -z "$ROCKCRAFT_DIR" ] +then + echo "Error: Missing rockcraft project directory argument (-d)" + usage + exit 1 +fi + +if [ -z "$LC_CREDENTIALS_B64" ] +then + echo "Error: Missing launchpad credentials argument (-c)" + usage + exit 1 +fi + + +cd "$ROCKCRAFT_DIR" +rocks_toolbox="$(mktemp -d)" + +# install dependencies +git clone --depth 1 --branch v1.1.2 https://github.com/canonical/rocks-toolbox $rocks_toolbox +${rocks_toolbox}/rockcraft_lpci_build/requirements.sh +pip3 install -r ${rocks_toolbox}/rockcraft_lpci_build/requirements.txt + +python3 ${rocks_toolbox}/rockcraft_lpci_build/rockcraft_lpci_build.py \ + --lp-credentials-b64 "$LC_CREDENTIALS_B64" \ + --launchpad-accept-public-upload diff --git a/src/shared/github_output.py b/src/shared/github_output.py new file mode 100755 index 00000000..2bc6a0bc --- /dev/null +++ b/src/shared/github_output.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +from io import TextIOBase +import json + +"""This module provides support for writing Github Outputs.""" + + +def write(output: TextIOBase = None, **kwargs): + """Format kwargs for Github Outputs and write to `output` File Object""" + + for key, value in kwargs.items(): + + formatted_value = format_value(value) + print(f"{key}={formatted_value}", file=output) + + +def format_value(value): + """Format `value` such that it can be stored as a github output""" + + if isinstance(value, str): + # str is an exception to casting with json.dumps as we do + # not need to represent the string itself, but just the data + return value + else: + json_value = json.dumps(value) + return json_value diff --git a/src/shared/release_info.py b/src/shared/release_info.py old mode 100755 new mode 100644 index 86a8d02d..d07a06f6 --- a/src/shared/release_info.py +++ b/src/shared/release_info.py @@ -6,7 +6,7 @@ """ import json -from src.image.utils.schema.triggers import KNOWN_RISKS_ORDERED +from ..image.utils.schema.triggers import KNOWN_RISKS_ORDERED class BadChannel(Exception): diff --git a/tests/integration/test_convert_junit_xml_to_markdown.py b/tests/integration/test_convert_junit_xml_to_markdown.py new file mode 100644 index 00000000..41938951 --- /dev/null +++ b/tests/integration/test_convert_junit_xml_to_markdown.py @@ -0,0 +1,18 @@ +from ..fixtures.buffers import str_buff +from ..fixtures.junit_et import junit_with_failure +import tools.junit_to_markdown.convert as report + + +def test_print_redirection(junit_with_failure, str_buff, capsys): + """Ensure that the report is entirely redirected when needed""" + + report.print_junit_report(junit_with_failure, str_buff) + report.print_junit_report(junit_with_failure, None) # print report to stdout + + str_buff.seek(0) + str_buff_content = str_buff.read() + + captured = capsys.readouterr() + stdout_content = captured.out + + assert stdout_content == str_buff_content, "Printing to multiple locations." diff --git a/tests/unit/test_generate_build_matrix.py b/tests/unit/test_generate_build_matrix.py new file mode 100644 index 00000000..7ee89a7b --- /dev/null +++ b/tests/unit/test_generate_build_matrix.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 + +from src.build_rock.configure.generate_build_matrix import ( + get_target_archs, + configure_matrices, + MissingArchSupport, + set_build_config_outputs, +) +from pathlib import Path +import pytest +from tempfile import TemporaryDirectory + + +def test_get_target_archs(): + """Test extraction of target architectures from rockcraft project configuration""" + project = { + "name": "hello-world", + "title": "Hello World", + "summary": "An Hello World rock", + "description": "This is just an example of a Rockcraft project\nfor a Hello World rock.\n", + "version": "latest", + "base": "bare", + "build-base": "ubuntu@22.04", + "license": "Apache-2.0", + "run-user": "_daemon_", + "environment": {"FOO": "bar"}, + "services": { + "hello": { + "override": "replace", + "command": "/usr/bin/hello -t", + "environment": {"VAR1": "value", "VAR2": "other value"}, + } + }, + "platforms": { + "amd64": None, + "armhf": {"build-for": ["armhf", "arm64"]}, + "ibm": {"build-on": ["s390x"], "build-for": "s390x"}, + }, + "parts": {"hello": {"plugin": "nil", "stage-packages": ["hello"]}}, + } + + arches = get_target_archs(project) + assert arches == {"arm64", "armhf", "amd64"} + + +def test_configure_matrices(): + """Test correct configuration of build matrices from project's target arches""" + + build_matrices = configure_matrices(["amd64"], {"amd64": "ubuntu-22.04"}, False) + expected_result = { + "runner-build-matrix": { + "include": [{"architecture": "amd64", "runner": "ubuntu-22.04"}] + }, + "lpci-build-matrix": {"include": []}, + } + + assert build_matrices == expected_result + + +def test_configure_matrices_fallback_exception(): + """Test proper exception is raised when target arch is not buildable""" + with pytest.raises(MissingArchSupport): + configure_matrices(["arm64"], {"amd64": "ubuntu-22.04"}, False) + + +def test_configure_matrices_lpci_fallback(): + """Test lpci fallback logic when target cannot be built on a runner""" + build_matrices = configure_matrices(["arm64"], {"amd64": "ubuntu-22.04"}, True) + expected_result = { + "runner-build-matrix": {"include": []}, + "lpci-build-matrix": {"include": [{"architecture": "arm64"}]}, + } + + assert build_matrices == expected_result + + +def test_set_build_config_outputs(): + """Test correct generation of build matrices.""" + + test_build_matrices = { + "runner-build-matrix": { + "include": [{"architecture": "amd64", "runner": "ubuntu-22.04"}] + }, + "lpci-build-matrix": {"include": []}, + } + + with TemporaryDirectory() as tmp: + + env_path = Path(tmp) / "env" + + set_build_config_outputs("test", test_build_matrices, output_path=env_path) + + with open(env_path, "r") as fh: + gh_output = fh.read() + + expected_result = """rock-name=test +runner-build-matrix={"include": [{"architecture": "amd64", "runner": "ubuntu-22.04"}]} +lpci-build-matrix={"include": []} +""" + + assert gh_output == expected_result diff --git a/tests/unit/test_github_output.py b/tests/unit/test_github_output.py new file mode 100755 index 00000000..9e24a1be --- /dev/null +++ b/tests/unit/test_github_output.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +from src.shared.github_output import write, format_value +from io import StringIO +import pytest + + +@pytest.fixture +def text_buffer(): + with StringIO() as buffer: + yield buffer + + +def test_write(text_buffer): + """Test github_output write function""" + + outputs = { + "hello-world": 42, + } + expected_result = "hello-world=42\n" + + write(text_buffer, **outputs) + + text_buffer.seek(0) + result = text_buffer.read() + + assert result == expected_result + + +def test_format_value_string(): + """Test formatting of string for outputs""" + + expected_result = "foo" + result = format_value("foo") + + assert expected_result == result + + +def test_format_value_number(): + """Test formatting of number for outputs""" + + expected_result = "1" + result = format_value(1) + + assert expected_result == result + + +def test_format_value_json(): + """Test formatting of JSON for outputs""" + + expected_result = '{"foo": "bar"}' + result = format_value({"foo": "bar"}) + + assert expected_result == result From 962aa3cd3d640c911ade60e020dcd47f11143602 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Fri, 6 Sep 2024 11:48:36 +0000 Subject: [PATCH 02/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/10737688171 --- oci/mock-rock/_releases.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index f3740785..b14c173a 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -13,13 +13,13 @@ }, "1.0-22.04": { "candidate": { - "target": "481" + "target": "487" }, "beta": { - "target": "481" + "target": "487" }, "edge": { - "target": "481" + "target": "487" }, "end-of-life": "2025-05-01T00:00:00Z" }, @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "482" + "target": "488" }, "beta": { - "target": "482" + "target": "488" }, "edge": { - "target": "482" + "target": "488" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "482" + "target": "488" }, "beta": { - "target": "482" + "target": "488" }, "edge": { - "target": "482" + "target": "488" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "483" + "target": "489" }, "edge": { "target": "1.2-22.04_beta" From 3007b0bcb5a03332d723fae35b4d9f0e9ee14385 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Fri, 6 Sep 2024 14:03:42 +0200 Subject: [PATCH 03/86] feat: added runner triplets to Image workflow --- .github/workflows/Image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index 8325b895..adbf9004 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -127,7 +127,7 @@ jobs: rock-repo: ${{ matrix.source }} rock-repo-commit: ${{ matrix.commit }} rockfile-directory: ${{ matrix.directory }} - arch-map: '{"amd64": "ubuntu-22.04", "arm64": "Ubuntu_ARM64_4C_16G_01"}' + arch-map: '{"amd64": ["jammy", "X64", "large"], "arm64": ["jammy", "ARM64", "large"]}' lpci-fallback: true secrets: inherit From a70a819ebfe584dba869a773e2f26fdac426bce0 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Sun, 8 Sep 2024 21:49:34 +0200 Subject: [PATCH 04/86] feat: added GithubOutput class --- .../configure/generate_build_matrix.py | 15 ++--- src/shared/github_output.py | 55 ++++++++++++++----- tests/fixtures/buffers.py | 16 ++++++ tests/unit/test_generate_build_matrix.py | 15 ++--- tests/unit/test_github_output.py | 27 ++++----- 5 files changed, 76 insertions(+), 52 deletions(-) diff --git a/src/build_rock/configure/generate_build_matrix.py b/src/build_rock/configure/generate_build_matrix.py index dae4f2a0..9e33258c 100755 --- a/src/build_rock/configure/generate_build_matrix.py +++ b/src/build_rock/configure/generate_build_matrix.py @@ -5,8 +5,7 @@ import argparse import json from enum import Enum -from typing import Optional -from ...shared import github_output +from ...shared.github_output import GithubOutput class MATRIX_NAMES(Enum): @@ -71,19 +70,13 @@ def configure_matrices(target_archs: list, arch_map: dict, lp_fallback: bool) -> return build_matrices -def set_build_config_outputs( - rock_name: str, build_matrices: dict, output_path: Optional[str] = None -): +def set_build_config_outputs(rock_name: str, build_matrices: dict): """Update GITHUB_OUTPUT with build configuration.""" outputs = {"rock-name": rock_name, **build_matrices} - # set default when not testing - if output_path is None: - output_path = os.environ["GITHUB_OUTPUT"] - - with open(output_path, "a") as fh: - github_output.write(fh, **outputs) + with GithubOutput() as github_output: + github_output.write(**outputs) def main(): diff --git a/src/shared/github_output.py b/src/shared/github_output.py index 2bc6a0bc..ab9fe70f 100755 --- a/src/shared/github_output.py +++ b/src/shared/github_output.py @@ -1,27 +1,52 @@ #!/usr/bin/env python3 -from io import TextIOBase import json +from os import environ """This module provides support for writing Github Outputs.""" +# locate +GITHUB_OUTPUT = environ.get("GITHUB_OUTPUT", None) -def write(output: TextIOBase = None, **kwargs): - """Format kwargs for Github Outputs and write to `output` File Object""" - for key, value in kwargs.items(): +class GithubOutput: - formatted_value = format_value(value) - print(f"{key}={formatted_value}", file=output) + def __init__(self): + self.output_path = environ["GITHUB_OUTPUT"] -def format_value(value): - """Format `value` such that it can be stored as a github output""" + def __enter__(self): - if isinstance(value, str): - # str is an exception to casting with json.dumps as we do - # not need to represent the string itself, but just the data - return value - else: - json_value = json.dumps(value) - return json_value + self.file_handler = open(self.output_path, "a") + + return self + + def __exit__(self, exc_type, exc_value, traceback): + + self.file_handler.close() + del self.file_handler + + def write(self, **kwargs): + """Format kwargs for Github Outputs and write to `output` File Object""" + + if not getattr(self, "file_handler", None): + raise AttributeError( + "file_handler not available. Please use in context block." + ) + + for key, value in kwargs.items(): + + formatted_value = self.format_value(value) + print(f"{key}={formatted_value}", file=self.file_handler) + + @staticmethod + def format_value(value): + """Format `value` such that it can be stored as a github output""" + + if isinstance(value, str): + # str is an exception to casting with json.dumps as we do + # not need to represent the string itself, but just the data + return value + else: + json_value = json.dumps(value) + return json_value diff --git a/tests/fixtures/buffers.py b/tests/fixtures/buffers.py index 694e9a44..1f7abd48 100644 --- a/tests/fixtures/buffers.py +++ b/tests/fixtures/buffers.py @@ -1,5 +1,8 @@ import pytest from io import StringIO +import os +from pathlib import Path +from tempfile import TemporaryDirectory @pytest.fixture @@ -7,3 +10,16 @@ def str_buff(): """String IO fixture for simulating a file object""" with StringIO() as buffer: yield buffer + + +@pytest.fixture +def github_output(monkeypatch): + + with TemporaryDirectory() as tmp: + + env_path = Path(tmp) / "env" + env_path.touch() + + monkeypatch.setitem(os.environ, "GITHUB_OUTPUT", str(env_path)) + + yield env_path diff --git a/tests/unit/test_generate_build_matrix.py b/tests/unit/test_generate_build_matrix.py index 7ee89a7b..aced0f90 100644 --- a/tests/unit/test_generate_build_matrix.py +++ b/tests/unit/test_generate_build_matrix.py @@ -6,9 +6,8 @@ MissingArchSupport, set_build_config_outputs, ) -from pathlib import Path import pytest -from tempfile import TemporaryDirectory +from ..fixtures.buffers import github_output def test_get_target_archs(): @@ -74,7 +73,7 @@ def test_configure_matrices_lpci_fallback(): assert build_matrices == expected_result -def test_set_build_config_outputs(): +def test_set_build_config_outputs(github_output): """Test correct generation of build matrices.""" test_build_matrices = { @@ -84,14 +83,10 @@ def test_set_build_config_outputs(): "lpci-build-matrix": {"include": []}, } - with TemporaryDirectory() as tmp: + set_build_config_outputs("test", test_build_matrices) - env_path = Path(tmp) / "env" - - set_build_config_outputs("test", test_build_matrices, output_path=env_path) - - with open(env_path, "r") as fh: - gh_output = fh.read() + with open(github_output, "r") as fh: + gh_output = fh.read() expected_result = """rock-name=test runner-build-matrix={"include": [{"architecture": "amd64", "runner": "ubuntu-22.04"}]} diff --git a/tests/unit/test_github_output.py b/tests/unit/test_github_output.py index 9e24a1be..5cf11445 100755 --- a/tests/unit/test_github_output.py +++ b/tests/unit/test_github_output.py @@ -1,17 +1,10 @@ #!/usr/bin/env python3 -from src.shared.github_output import write, format_value -from io import StringIO -import pytest +from src.shared.github_output import GithubOutput +from ..fixtures.buffers import github_output -@pytest.fixture -def text_buffer(): - with StringIO() as buffer: - yield buffer - - -def test_write(text_buffer): +def test_write(github_output): """Test github_output write function""" outputs = { @@ -19,10 +12,12 @@ def test_write(text_buffer): } expected_result = "hello-world=42\n" - write(text_buffer, **outputs) + with GithubOutput() as output: + + output.write(**outputs) - text_buffer.seek(0) - result = text_buffer.read() + with open(github_output, "r") as fh: + result = fh.read() assert result == expected_result @@ -31,7 +26,7 @@ def test_format_value_string(): """Test formatting of string for outputs""" expected_result = "foo" - result = format_value("foo") + result = GithubOutput.format_value("foo") assert expected_result == result @@ -40,7 +35,7 @@ def test_format_value_number(): """Test formatting of number for outputs""" expected_result = "1" - result = format_value(1) + result = GithubOutput.format_value(1) assert expected_result == result @@ -49,6 +44,6 @@ def test_format_value_json(): """Test formatting of JSON for outputs""" expected_result = '{"foo": "bar"}' - result = format_value({"foo": "bar"}) + result = GithubOutput.format_value({"foo": "bar"}) assert expected_result == result From f3514efa1c07c47c0bb18712e65e38c298cde131 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 9 Sep 2024 09:34:35 +0200 Subject: [PATCH 05/86] feat: applied suggested changes from zhijie-yang --- .github/workflows/Build-Rock.yaml | 2 +- .github/workflows/Image.yaml | 3 +- .../configure/generate_build_matrix.py | 16 ++------- src/build_rock/lpci_build/lpci_build.sh | 6 ++-- tests/data/rockcraft.yaml | 18 ++++++++++ tests/fixtures/junit_et.py | 13 ------- tests/fixtures/sample_data.py | 26 ++++++++++++++ .../test_convert_junit_xml_to_markdown.py | 2 +- .../test_junit_to_markdown_output.py | 2 +- tests/unit/test_generate_build_matrix.py | 34 +++++-------------- 10 files changed, 63 insertions(+), 59 deletions(-) create mode 100644 tests/data/rockcraft.yaml delete mode 100644 tests/fixtures/junit_et.py create mode 100644 tests/fixtures/sample_data.py diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 20dc4ca7..9c86d397 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -224,4 +224,4 @@ jobs: with: name: ${{ inputs.oci-archive-name }} path: ${{ inputs.oci-archive-name }} - if-no-files-found: error \ No newline at end of file + if-no-files-found: error diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index adbf9004..5042929d 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -132,7 +132,7 @@ jobs: secrets: inherit tmp-cache-job: - # Note: This is a temporary job that will be removed when the refactored test job is merged. + # TODO: This is a temporary job that will be removed when the refactored test job is merged. # Going forward we download the built rocks from artifacts instead of cache. This job takes # the uploaded rocks then re-caches them for compatibility. name: Temporary step to cache rocks @@ -156,6 +156,7 @@ jobs: test: needs: [prepare-build, run-build, tmp-cache-job] + # TODO: Remove tmp-cache-job when removing the job tmp-cache-job name: Test strategy: fail-fast: true diff --git a/src/build_rock/configure/generate_build_matrix.py b/src/build_rock/configure/generate_build_matrix.py index 9e33258c..3271dc62 100755 --- a/src/build_rock/configure/generate_build_matrix.py +++ b/src/build_rock/configure/generate_build_matrix.py @@ -6,6 +6,7 @@ import json from enum import Enum from ...shared.github_output import GithubOutput +from pydantic import TypeAdapter class MATRIX_NAMES(Enum): @@ -92,7 +93,7 @@ def main(): "--lpci-fallback", help="Revert to lpci if architectures are not supported. ", required=True, - type=str, + type=TypeAdapter(bool).validate_python, ) parser.add_argument( @@ -110,19 +111,8 @@ def main(): # load config arch_map = json.loads(args.config) - # check input of lpci_fallback which should be an explicit boolean - try: - # use json.loads for conveniently casting string to bool - lpci_fallback = json.loads(args.lpci_fallback.lower()) - - if not isinstance(lpci_fallback, bool): - raise TypeError("Expected bool type") - - except (TypeError, json.decoder.JSONDecodeError) as exc: - raise ValueError('--lpci-fallback expected "true" or "false" value') from exc - target_archs = get_target_archs(rockcraft_yaml) - build_matrices = configure_matrices(target_archs, arch_map, lpci_fallback) + build_matrices = configure_matrices(target_archs, arch_map, args.lpci_fallback) # set github outputs for use in later steps set_build_config_outputs(rockcraft_yaml["name"], build_matrices) diff --git a/src/build_rock/lpci_build/lpci_build.sh b/src/build_rock/lpci_build/lpci_build.sh index 35849730..f1900694 100755 --- a/src/build_rock/lpci_build/lpci_build.sh +++ b/src/build_rock/lpci_build/lpci_build.sh @@ -21,7 +21,7 @@ do ROCKCRAFT_DIR="$OPTARG" ;; c) - LC_CREDENTIALS_B64="$OPTARG" + LP_CREDENTIALS_B64="$OPTARG" ;; ?) usage @@ -37,7 +37,7 @@ then exit 1 fi -if [ -z "$LC_CREDENTIALS_B64" ] +if [ -z "$LP_CREDENTIALS_B64" ] then echo "Error: Missing launchpad credentials argument (-c)" usage @@ -54,5 +54,5 @@ ${rocks_toolbox}/rockcraft_lpci_build/requirements.sh pip3 install -r ${rocks_toolbox}/rockcraft_lpci_build/requirements.txt python3 ${rocks_toolbox}/rockcraft_lpci_build/rockcraft_lpci_build.py \ - --lp-credentials-b64 "$LC_CREDENTIALS_B64" \ + --lp-credentials-b64 "$LP_CREDENTIALS_B64" \ --launchpad-accept-public-upload diff --git a/tests/data/rockcraft.yaml b/tests/data/rockcraft.yaml new file mode 100644 index 00000000..2cfe0f22 --- /dev/null +++ b/tests/data/rockcraft.yaml @@ -0,0 +1,18 @@ +# Metadata section + +name: hello +summary: Hello World +description: The most basic example of a rock. +version: "latest" +license: Apache-2.0 + +base: bare +build-base: ubuntu@22.04 +platforms: + amd64: + +parts: + hello: + plugin: nil + stage-packages: + - hello \ No newline at end of file diff --git a/tests/fixtures/junit_et.py b/tests/fixtures/junit_et.py deleted file mode 100644 index 31616c82..00000000 --- a/tests/fixtures/junit_et.py +++ /dev/null @@ -1,13 +0,0 @@ -import pytest -import xml.etree.ElementTree as ET -from .. import DATA_DIR - - -@pytest.fixture -def junit_with_failure(): - """Load ET of junit xml report with failure""" - sample = DATA_DIR / "junit_xml_failure.xml" - - tree = ET.parse(sample) - root = tree.getroot() - return root diff --git a/tests/fixtures/sample_data.py b/tests/fixtures/sample_data.py new file mode 100644 index 00000000..c3df9af1 --- /dev/null +++ b/tests/fixtures/sample_data.py @@ -0,0 +1,26 @@ +import pytest +import xml.etree.ElementTree as ET +import yaml +from .. import DATA_DIR + + +@pytest.fixture +def junit_with_failure(): + """Load ET of junit xml report with failure.""" + sample_file = DATA_DIR / "junit_xml_failure.xml" + + tree = ET.parse(sample_file) + root = tree.getroot() + return root + + +@pytest.fixture +def rockcraft_project(): + """Get sample rockcraft project file for testing.""" + + sample = DATA_DIR / "rockcraft.yaml" + + with open(sample) as rf: + project = yaml.safe_load(rf) + + return project diff --git a/tests/integration/test_convert_junit_xml_to_markdown.py b/tests/integration/test_convert_junit_xml_to_markdown.py index 41938951..9305985c 100644 --- a/tests/integration/test_convert_junit_xml_to_markdown.py +++ b/tests/integration/test_convert_junit_xml_to_markdown.py @@ -1,5 +1,5 @@ from ..fixtures.buffers import str_buff -from ..fixtures.junit_et import junit_with_failure +from ..fixtures.sample_data import junit_with_failure import tools.junit_to_markdown.convert as report diff --git a/tests/integration/test_junit_to_markdown_output.py b/tests/integration/test_junit_to_markdown_output.py index 41938951..9305985c 100644 --- a/tests/integration/test_junit_to_markdown_output.py +++ b/tests/integration/test_junit_to_markdown_output.py @@ -1,5 +1,5 @@ from ..fixtures.buffers import str_buff -from ..fixtures.junit_et import junit_with_failure +from ..fixtures.sample_data import junit_with_failure import tools.junit_to_markdown.convert as report diff --git a/tests/unit/test_generate_build_matrix.py b/tests/unit/test_generate_build_matrix.py index aced0f90..7fca208d 100644 --- a/tests/unit/test_generate_build_matrix.py +++ b/tests/unit/test_generate_build_matrix.py @@ -8,37 +8,19 @@ ) import pytest from ..fixtures.buffers import github_output +from ..fixtures.sample_data import rockcraft_project -def test_get_target_archs(): +def test_get_target_archs(rockcraft_project): """Test extraction of target architectures from rockcraft project configuration""" - project = { - "name": "hello-world", - "title": "Hello World", - "summary": "An Hello World rock", - "description": "This is just an example of a Rockcraft project\nfor a Hello World rock.\n", - "version": "latest", - "base": "bare", - "build-base": "ubuntu@22.04", - "license": "Apache-2.0", - "run-user": "_daemon_", - "environment": {"FOO": "bar"}, - "services": { - "hello": { - "override": "replace", - "command": "/usr/bin/hello -t", - "environment": {"VAR1": "value", "VAR2": "other value"}, - } - }, - "platforms": { - "amd64": None, - "armhf": {"build-for": ["armhf", "arm64"]}, - "ibm": {"build-on": ["s390x"], "build-for": "s390x"}, - }, - "parts": {"hello": {"plugin": "nil", "stage-packages": ["hello"]}}, + + rockcraft_project["platforms"] = { + "amd64": None, + "armhf": {"build-for": ["armhf", "arm64"]}, + "ibm": {"build-on": ["s390x"], "build-for": "s390x"}, } - arches = get_target_archs(project) + arches = get_target_archs(rockcraft_project) assert arches == {"arm64", "armhf", "amd64"} From 3902e8236809c8304bd68a734becb909d9ee993b Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 9 Sep 2024 10:20:48 +0200 Subject: [PATCH 06/86] feat: added suggested changes from linostar --- .github/workflows/Build-Rock.yaml | 3 ++- src/build_rock/configure/generate_build_matrix.py | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 9c86d397..f395ba5e 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -188,7 +188,7 @@ jobs: assemble-rock: # Assemble individual single-arch rocks into multi-arch rocks - needs: [configure-build, runner-build, lpci-build] + needs: [runner-build, lpci-build] runs-on: ubuntu-22.04 # Always run even if one of the *-build jobs are skipped # Nice example from benjamin-bergia/github-workflow-patterns... @@ -210,6 +210,7 @@ jobs: id: download with: path: ${{ env.ROCK_CI_FOLDER }} + pattern: ${{ inputs.oci-archive-name }}-* - name: Assemble Multi Arch Rock diff --git a/src/build_rock/configure/generate_build_matrix.py b/src/build_rock/configure/generate_build_matrix.py index 3271dc62..5ef1cde4 100755 --- a/src/build_rock/configure/generate_build_matrix.py +++ b/src/build_rock/configure/generate_build_matrix.py @@ -28,8 +28,6 @@ def get_target_archs(rockcraft: dict) -> list: for platf, values in rock_platforms.items(): if isinstance(values, dict) and "build-for" in values: - # TODO: Should this be "build-on"? - # https://documentation.ubuntu.com/rockcraft/en/latest/reference/rockcraft.yaml/#platforms-entry-build-on if isinstance(arches := values["build-for"], list): target_archs.update(arches) elif isinstance(values, str): From 7f362cbb65632a034cdd2f6339b4edb54d3b5463 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 9 Sep 2024 10:42:35 +0200 Subject: [PATCH 07/86] fix(src/build_rock/configure/requirements.txt): added pydantic --- src/build_rock/configure/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/build_rock/configure/requirements.txt b/src/build_rock/configure/requirements.txt index aa4d4d06..f71072f4 100644 --- a/src/build_rock/configure/requirements.txt +++ b/src/build_rock/configure/requirements.txt @@ -1 +1,2 @@ pyyaml==6.0.2 +pydantic==2.8.2 \ No newline at end of file From 94a5722651d8dd4bc1b93669525c7ef55c64e7c1 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Mon, 9 Sep 2024 09:00:49 +0000 Subject: [PATCH 08/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/10769692657 --- oci/mock-rock/_releases.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index b14c173a..79ac6310 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -13,13 +13,13 @@ }, "1.0-22.04": { "candidate": { - "target": "487" + "target": "501" }, "beta": { - "target": "487" + "target": "501" }, "edge": { - "target": "487" + "target": "501" }, "end-of-life": "2025-05-01T00:00:00Z" }, @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "488" + "target": "502" }, "beta": { - "target": "488" + "target": "502" }, "edge": { - "target": "488" + "target": "502" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "488" + "target": "502" }, "beta": { - "target": "488" + "target": "502" }, "edge": { - "target": "488" + "target": "502" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "489" + "target": "503" }, "edge": { "target": "1.2-22.04_beta" From a17542926854e3e37a30fea9cd7d9fe6223abbc4 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Mon, 16 Sep 2024 11:48:57 +0000 Subject: [PATCH 09/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/10883006125 --- oci/mock-rock/_releases.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 0740e939..c039fff4 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -13,13 +13,13 @@ }, "1.0-22.04": { "candidate": { - "target": "533" + "target": "536" }, "beta": { - "target": "533" + "target": "536" }, "edge": { - "target": "533" + "target": "536" }, "end-of-life": "2025-05-01T00:00:00Z" }, @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "534" + "target": "537" }, "beta": { - "target": "534" + "target": "537" }, "edge": { - "target": "534" + "target": "537" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "534" + "target": "537" }, "beta": { - "target": "534" + "target": "537" }, "edge": { - "target": "534" + "target": "537" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "535" + "target": "538" }, "edge": { "target": "1.2-22.04_beta" From 448b8a219f04e3dbadf739e570c40a26c0a7146c Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 23 Sep 2024 13:47:37 +0200 Subject: [PATCH 10/86] refactor: remove arch-map value from call to build-rock in Image workflow --- .github/workflows/Image.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index b185e863..353f2b50 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -135,7 +135,6 @@ jobs: rock-repo: ${{ matrix.source }} rock-repo-commit: ${{ matrix.commit }} rockfile-directory: ${{ matrix.directory }} - arch-map: '{"amd64": ["jammy", "X64", "large"], "arm64": ["jammy", "ARM64", "large"]}' lpci-fallback: true secrets: inherit From 3c5d2954408cdf09473d819e44c45a53515580f5 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 23 Sep 2024 13:48:19 +0200 Subject: [PATCH 11/86] feat: make default arch-map value use labels instead of runner name --- .github/workflows/Build-Rock.yaml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index f44fc6e5..4611b040 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -3,21 +3,13 @@ name: Build Rock on: workflow_call: inputs: - # build configuration + # build parameters oci-archive-name: description: "Final filename of the Rock OCI archive." type: string required: true - arch-map: - description: "JSON string mapping target architecture to runner." - type: string - default: '{"amd64": "ubuntu-22.04"}' - lpci-fallback: - description: 'Enable fallback to Launchpad build when runners for target arch are not available.' - type: boolean - default: false - # source configuration + # source parameters rock-repo: description: "Public Git repo where to build the rock from." type: string @@ -31,6 +23,17 @@ on: type: string required: true + # optional parameters for multi-arch builds + arch-map: + description: "JSON string mapping target architecture to runners." + type: string + default: '{"amd64": ["linux", "X64"], "arm64": ["linux", "ARM64"]}' + lpci-fallback: + description: 'Enable fallback to Launchpad build when runners for target arch are not available.' + type: boolean + default: false + + env: ROCK_REPO_DIR: rock-repo # path where the image repo is cloned to From c3e30c9283a42222b6a18fb275b6277d19417d27 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Mon, 23 Sep 2024 12:01:15 +0000 Subject: [PATCH 12/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/10993623923 --- oci/mock-rock/_releases.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index c039fff4..c846ec12 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -13,13 +13,13 @@ }, "1.0-22.04": { "candidate": { - "target": "536" + "target": "559" }, "beta": { - "target": "536" + "target": "559" }, "edge": { - "target": "536" + "target": "559" }, "end-of-life": "2025-05-01T00:00:00Z" }, @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "537" + "target": "560" }, "beta": { - "target": "537" + "target": "560" }, "edge": { - "target": "537" + "target": "560" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "537" + "target": "560" }, "beta": { - "target": "537" + "target": "560" }, "edge": { - "target": "537" + "target": "560" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "538" + "target": "561" }, "edge": { "target": "1.2-22.04_beta" From dacd870594f9bcf5f0fef434ea99ef61ccf26f89 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 7 Oct 2024 12:35:01 +0000 Subject: [PATCH 13/86] fix: "Rock" now uses sentance case --- .github/workflows/Build-Rock.yaml | 10 +++++----- .github/workflows/Image.yaml | 2 +- src/build_rock/assemble_rock/assemble.sh | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 4611b040..8787e71b 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -1,11 +1,11 @@ -name: Build Rock +name: Build rock on: workflow_call: inputs: # build parameters oci-archive-name: - description: "Final filename of the Rock OCI archive." + description: "Final filename of the rock OCI archive." type: string required: true @@ -216,7 +216,7 @@ jobs: - run: src/build_rock/assemble_rock/requirements.sh - - name: Download Single Arch Rocks + - name: Download Single Arch rocks uses: actions/download-artifact@v4 id: download with: @@ -224,14 +224,14 @@ jobs: pattern: ${{ inputs.oci-archive-name }}-* - - name: Assemble Multi Arch Rock + - name: Assemble Multi Arch rock run: | src/build_rock/assemble_rock/assemble.sh \ -n "${{ inputs.oci-archive-name }}" \ -d "${{ env.ROCK_CI_FOLDER }}" - - name: Upload Multi Arch Rock + - name: Upload Multi Arch rock uses: actions/upload-artifact@v4 with: name: ${{ inputs.oci-archive-name }} diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index 353f2b50..e0cc45cf 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -150,7 +150,7 @@ jobs: matrix: ${{ fromJSON(needs.prepare-build.outputs.build-matrix) }} steps: - - name: Download Rock + - name: Download rock uses: actions/download-artifact@v4 with: name: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} diff --git a/src/build_rock/assemble_rock/assemble.sh b/src/build_rock/assemble_rock/assemble.sh index 3d149477..f2c3d8dd 100755 --- a/src/build_rock/assemble_rock/assemble.sh +++ b/src/build_rock/assemble_rock/assemble.sh @@ -7,7 +7,7 @@ function usage(){ echo echo "$(basename "$0") -d -n " echo - echo "Merge multiple OCI Rock images into one multi arch image." + echo "Merge multiple OCI rock images into one multi arch image." echo echo -e "-d \\t Directory to search for rock OCI images in." echo -e "-n \\t Final output archive name. " From 55ed79629bbf3c49a89eb4fd93559c91c157d035 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 7 Oct 2024 12:40:42 +0000 Subject: [PATCH 14/86] fix(tests/data/rockcraft.yaml): added missing newline --- tests/data/rockcraft.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/data/rockcraft.yaml b/tests/data/rockcraft.yaml index 2cfe0f22..531a45bf 100644 --- a/tests/data/rockcraft.yaml +++ b/tests/data/rockcraft.yaml @@ -15,4 +15,5 @@ parts: hello: plugin: nil stage-packages: - - hello \ No newline at end of file + - hello + \ No newline at end of file From 403d55910daec72e033f647a0e0c536cd48c0aa1 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 7 Oct 2024 13:07:25 +0000 Subject: [PATCH 15/86] refactor(tests/etc/requirements.txt): test requirements.txt now refrences other requirements.txt --- tests/etc/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/etc/requirements.txt b/tests/etc/requirements.txt index fe93bd52..21465760 100644 --- a/tests/etc/requirements.txt +++ b/tests/etc/requirements.txt @@ -1 +1,2 @@ pytest==8.3.2 +-r ../../src/build_rock/configure/requirements.txt \ No newline at end of file From 1bb9f6d95bd4ea8d3434b1dbbe9a88c55e969fd5 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 7 Oct 2024 13:24:05 +0000 Subject: [PATCH 16/86] refactor: ran autoformatter on edited yaml files --- .github/workflows/Build-Rock.yaml | 60 ++++++++---------------- .github/workflows/Image.yaml | 25 +++++----- .github/workflows/_Test-OCI-Factory.yaml | 10 ++-- tests/data/rockcraft.yaml | 3 +- 4 files changed, 34 insertions(+), 64 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 8787e71b..090fefa7 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -8,7 +8,7 @@ on: description: "Final filename of the rock OCI archive." type: string required: true - + # source parameters rock-repo: description: "Public Git repo where to build the rock from." @@ -29,31 +29,27 @@ on: type: string default: '{"amd64": ["linux", "X64"], "arm64": ["linux", "ARM64"]}' lpci-fallback: - description: 'Enable fallback to Launchpad build when runners for target arch are not available.' + description: "Enable fallback to Launchpad build when runners for target arch are not available." type: boolean default: false - - env: ROCK_REPO_DIR: rock-repo # path where the image repo is cloned to ROCK_CI_FOLDER: ci-rocks # path of uploaded/downloaded artifacts - + OCI_FACTORY_REPO: canonical/oci-factory # TODO: update before final merge OCI_FACTORY_BRANCH: ROCKS-1452/oci-factory-refactor-build-rock-to-be-externally-reusable # required for external workflow calls. jobs: - configure-build: # configure-build reads the rockcraft.yaml, creating one or more *-build job runs # depending on the target architecture. runs-on: ubuntu-22.04 outputs: - runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} - lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} + runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} + lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} steps: - # Job Setup - uses: actions/checkout@v4 with: @@ -75,14 +71,12 @@ jobs: - run: pip install -r src/build_rock/configure/requirements.txt - - uses: actions/checkout@v4 with: repository: ${{ inputs.rock-repo }} path: ${{ env.ROCK_REPO_DIR }} ref: ${{ inputs.rock-repo-commit }} - submodules: 'recursive' - + submodules: "recursive" # Configure matrices for each *-build job - name: Configure @@ -93,7 +87,6 @@ jobs: --lpci-fallback "${{ toJSON(inputs.lpci-fallback) }}" \ --config ${{ toJSON(inputs.arch-map) }} # important: do not use quotes here - runner-build: # runner-build builds rocks per target architecture using pre configured runner images. needs: [configure-build] @@ -101,18 +94,16 @@ jobs: strategy: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.runner-build-matrix) }} - runs-on: ${{ matrix.runner }} - name: 'runner-build | ${{ matrix.architecture }} ' + runs-on: ${{ matrix.runner }} + name: "runner-build | ${{ matrix.architecture }} " steps: - - name: Clone Repo uses: actions/checkout@v4 with: repository: ${{ inputs.rock-repo }} path: ${{ env.ROCK_REPO_DIR }} ref: ${{ inputs.rock-repo-commit }} - submodules: 'recursive' - + submodules: "recursive" - name: Build Target id: rockcraft @@ -121,13 +112,11 @@ jobs: path: "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}" verbosity: debug - - name: Collect Artifacts id: collect-artifacts run: | - mkdir -p ${{ env.ROCK_CI_FOLDER }} && cp ${{ steps.rockcraft.outputs.rock }} "$_" - echo "filename=$(basename ${{ steps.rockcraft.outputs.rock }})" >> $GITHUB_OUTPUT - + mkdir -p ${{ env.ROCK_CI_FOLDER }} && cp ${{ steps.rockcraft.outputs.rock }} "$_" + echo "filename=$(basename ${{ steps.rockcraft.outputs.rock }})" >> $GITHUB_OUTPUT - name: Upload Artifacts uses: actions/upload-artifact@v4 @@ -136,28 +125,25 @@ jobs: path: ${{ env.ROCK_CI_FOLDER }} if-no-files-found: error - lpci-build: - # lpci-build is a fallback for building rocks if no suitable runners are + # lpci-build is a fallback for building rocks if no suitable runners are # configured for the required architecture. Builds in this job will be - # outsourced to Launchpad for completion. + # outsourced to Launchpad for completion. # Note the Secret needs: [configure-build] if: fromJSON(needs.configure-build.outputs.lpci-build-matrix).include[0] != '' - strategy: + strategy: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.lpci-build-matrix) }} runs-on: ubuntu-22.04 - name: 'lpci-build | ${{ matrix.architecture }} ' + name: "lpci-build | ${{ matrix.architecture }} " steps: - # Job Setup - uses: actions/checkout@v4 with: repository: ${{ env.OCI_FACTORY_REPO }} ref: ${{ env.OCI_FACTORY_BRANCH }} fetch-depth: 1 - - name: Clone Repo uses: actions/checkout@v4 @@ -165,8 +151,7 @@ jobs: repository: ${{ inputs.rock-repo }} path: ${{ env.ROCK_REPO_DIR }} ref: ${{ inputs.rock-repo-commit }} - submodules: 'recursive' - + submodules: "recursive" - name: Build Target # TODO: Replace this retry action with bash equivalent for better testing @@ -181,13 +166,11 @@ jobs: -c "${{ secrets.LP_CREDENTIALS_B64 }}" \ -d "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}" - - name: Collect Artifacts id: collect-artifacts run: | - mkdir -p ${{ env.ROCK_CI_FOLDER }} && cp ${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/*.rock "$_" - echo "filename=${{ matrix.rock-name }}_${{ matrix.architecture }}" >> $GITHUB_OUTPUT - + mkdir -p ${{ env.ROCK_CI_FOLDER }} && cp ${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/*.rock "$_" + echo "filename=${{ matrix.rock-name }}_${{ matrix.architecture }}" >> $GITHUB_OUTPUT - name: Upload Artifacts uses: actions/upload-artifact@v4 @@ -196,7 +179,6 @@ jobs: path: ${{ env.ROCK_CI_FOLDER }} if-no-files-found: error - assemble-rock: # Assemble individual single-arch rocks into multi-arch rocks needs: [runner-build, lpci-build] @@ -205,7 +187,6 @@ jobs: # Nice example from benjamin-bergia/github-workflow-patterns... if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }} steps: - # Job Setup - uses: actions/checkout@v4 with: @@ -215,22 +196,19 @@ jobs: - run: src/build_rock/assemble_rock/requirements.sh - - name: Download Single Arch rocks uses: actions/download-artifact@v4 id: download with: - path: ${{ env.ROCK_CI_FOLDER }} + path: ${{ env.ROCK_CI_FOLDER }} pattern: ${{ inputs.oci-archive-name }}-* - - name: Assemble Multi Arch rock run: | src/build_rock/assemble_rock/assemble.sh \ -n "${{ inputs.oci-archive-name }}" \ -d "${{ env.ROCK_CI_FOLDER }}" - - name: Upload Multi Arch rock uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index e0cc45cf..943fd568 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -1,5 +1,5 @@ name: Image -run-name: 'Image - ${{ inputs.oci-image-name || github.triggering_actor }} - ${{ github.ref }}' +run-name: "Image - ${{ inputs.oci-image-name || github.triggering_actor }} - ${{ github.ref }}" on: push: @@ -25,7 +25,7 @@ on: type: boolean default: false external_ref_id: # (1) - description: 'Optional ID for unique run detection' + description: "Optional ID for unique run detection" required: false type: string default: "default-id" @@ -123,7 +123,6 @@ jobs: --oci-path ${{ steps.validate-image.outputs.img-path }} \ --revision-data-dir ${{ env.DATA_DIR }} - run-build: needs: [prepare-build] strategy: @@ -131,7 +130,7 @@ jobs: matrix: ${{ fromJSON(needs.prepare-build.outputs.build-matrix) }} uses: ./.github/workflows/Build-Rock.yaml with: - oci-archive-name: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} + oci-archive-name: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} rock-repo: ${{ matrix.source }} rock-repo-commit: ${{ matrix.commit }} rockfile-directory: ${{ matrix.directory }} @@ -141,7 +140,7 @@ jobs: tmp-cache-job: # TODO: This is a temporary job that will be removed when the refactored test job is merged. # Going forward we download the built rocks from artifacts instead of cache. This job takes - # the uploaded rocks then re-caches them for compatibility. + # the uploaded rocks then re-caches them for compatibility. name: Temporary step to cache rocks runs-on: ubuntu-22.04 needs: [prepare-build, run-build] @@ -149,7 +148,6 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.prepare-build.outputs.build-matrix) }} steps: - - name: Download rock uses: actions/download-artifact@v4 with: @@ -157,10 +155,9 @@ jobs: - uses: actions/cache/save@v4 with: - key: ${{ github.run_id }}-${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} + key: ${{ github.run_id }}-${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} path: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} - test: needs: [prepare-build, run-build, tmp-cache-job] # TODO: Remove tmp-cache-job when removing the job tmp-cache-job @@ -173,10 +170,9 @@ jobs: oci-image-name: "${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }}" oci-image-path: "oci/${{ matrix.name }}" test-from: "cache" - cache-key: ${{ github.run_id }}-${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} + cache-key: ${{ github.run_id }}-${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} secrets: inherit - prepare-upload: runs-on: ubuntu-22.04 needs: [prepare-build, run-build, test] @@ -599,15 +595,16 @@ jobs: notify: runs-on: ubuntu-22.04 name: Notify - needs: [prepare-build, run-build, upload, prepare-releases, generate-provenance] + needs: + [prepare-build, run-build, upload, prepare-releases, generate-provenance] if: ${{ !cancelled() && contains(needs.*.result, 'failure') && github.event_name != 'pull_request' }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.x' - + python-version: "3.x" + - name: Summarize workflow failure message id: get-summary run: | @@ -629,7 +626,7 @@ jobs: URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} SUMMARY: ${{ steps.get-summary.outputs.summary }} FOOTER: "Triggered by ${{ github.triggering_actor }}. Ref: ${{ github.ref }}. Attempts: ${{ github.run_attempt }}" - TITLE: '${{ needs.prepare-build.outputs.oci-img-name }}: failed to build->upload->release' + TITLE: "${{ needs.prepare-build.outputs.oci-img-name }}: failed to build->upload->release" run: | for channel in $(echo ${{ steps.get-contacts.outputs.mattermost-channels }} | tr ',' ' ') do diff --git a/.github/workflows/_Test-OCI-Factory.yaml b/.github/workflows/_Test-OCI-Factory.yaml index 8b06dcca..e11c18eb 100644 --- a/.github/workflows/_Test-OCI-Factory.yaml +++ b/.github/workflows/_Test-OCI-Factory.yaml @@ -24,7 +24,6 @@ env: # path of pytest junit output PYTEST_RESULT_PATH: pytest_results.xml - jobs: access-check: name: Validate access to mock-rock @@ -42,7 +41,6 @@ jobs: name: pytest runs-on: ubuntu-22.04 steps: - # Job Setup - uses: actions/checkout@v4 with: @@ -51,15 +49,14 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.x" - - # Note: Add additional dependency installation lines as required below + + # Note: Add additional dependency installation lines as required below # test-oci-factory/pytest requirements - run: pip install -r tests/etc/requirements.txt - # build_rock/configure requirements + # build_rock/configure requirements - run: pip install -r src/build_rock/configure/requirements.txt - - name: Run pytest continue-on-error: true run: | @@ -83,7 +80,6 @@ jobs: name: bats runs-on: ubuntu-22.04 steps: - # Job Setup - uses: actions/checkout@v4 with: diff --git a/tests/data/rockcraft.yaml b/tests/data/rockcraft.yaml index 531a45bf..a26aeabe 100644 --- a/tests/data/rockcraft.yaml +++ b/tests/data/rockcraft.yaml @@ -9,11 +9,10 @@ license: Apache-2.0 base: bare build-base: ubuntu@22.04 platforms: - amd64: + amd64: parts: hello: plugin: nil stage-packages: - hello - \ No newline at end of file From 4cbf7c2da71bfd9c8fd9dc2f83d322a336341bec Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Tue, 8 Oct 2024 10:15:24 +0000 Subject: [PATCH 17/86] refactor(tests/fixtures/buffers.py): switch to tmp_path fixture --- tests/fixtures/buffers.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/fixtures/buffers.py b/tests/fixtures/buffers.py index 1f7abd48..30993191 100644 --- a/tests/fixtures/buffers.py +++ b/tests/fixtures/buffers.py @@ -2,7 +2,6 @@ from io import StringIO import os from pathlib import Path -from tempfile import TemporaryDirectory @pytest.fixture @@ -13,13 +12,11 @@ def str_buff(): @pytest.fixture -def github_output(monkeypatch): +def github_output(monkeypatch, tmp_path): - with TemporaryDirectory() as tmp: + env_path = tmp_path / "env" + env_path.touch() - env_path = Path(tmp) / "env" - env_path.touch() + monkeypatch.setitem(os.environ, "GITHUB_OUTPUT", str(env_path)) - monkeypatch.setitem(os.environ, "GITHUB_OUTPUT", str(env_path)) - - yield env_path + yield env_path From 001dddee3cf7df70efed8a2f4cba81f646bf2d54 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Tue, 8 Oct 2024 11:37:09 +0000 Subject: [PATCH 18/86] fix: repair configure workflow after merge --- .github/workflows/Build-Rock.yaml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index ce1e87dc..2f5ea903 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -50,6 +50,8 @@ jobs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} steps: + + # ** Workflow authorization and job validation ** # Checkout the OCI Factory repo for the actor validation - uses: actions/checkout@v4 if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} @@ -71,8 +73,10 @@ jobs: id: clone-image-repo continue-on-error: true with: - repository: ${{ env.OCI_FACTORY_REPO }} - ref: ${{ env.OCI_FACTORY_BRANCH }} + repository: ${{ inputs.rock-repo }} + path: ${{ env.ROCK_REPO_DIR }} + ref: ${{ inputs.rock-repo-commit }} + submodules: "recursive" fetch-depth: 1 - run: git checkout ${{ inputs.rock-repo-commit }} @@ -81,7 +85,7 @@ jobs: - name: Validate image naming and base working-directory: ${{ inputs.rockfile-directory }} run: | - rock_name=`cat rockcraft.y*ml | yq -r .name` + rock_name=`cat ${{ env.ROCK_REPO_DIR }}/rockcraft.y*ml | yq -r .name` if [[ "${{ inputs.oci-factory-path }}" != *"${rock_name}"* ]] then echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name!" @@ -91,14 +95,16 @@ jobs: with: python-version: "3.x" + # ** Workflow job configuration ** + - run: pip install -r src/build_rock/configure/requirements.txt - - uses: actions/checkout@v4 - with: - repository: ${{ inputs.rock-repo }} - path: ${{ env.ROCK_REPO_DIR }} - ref: ${{ inputs.rock-repo-commit }} - submodules: "recursive" + # - uses: actions/checkout@v4 + # with: + # repository: ${{ inputs.rock-repo }} + # path: ${{ env.ROCK_REPO_DIR }} + # ref: ${{ inputs.rock-repo-commit }} + # submodules: "recursive" # Configure matrices for each *-build job - name: Configure From 922dd2324acf8f069ebd89b30a528944dcf28a23 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Tue, 8 Oct 2024 14:17:50 +0200 Subject: [PATCH 19/86] Update .github/workflows/Build-Rock.yaml Co-authored-by: Cristovao Cordeiro --- .github/workflows/Build-Rock.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 2f5ea903..efee2954 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -223,7 +223,6 @@ jobs: fetch-depth: 1 - run: src/build_rock/assemble_rock/requirements.sh - - name: Download Single Arch rocks uses: actions/download-artifact@v4 id: download From 22a6236c134c2dead77fbdc9983b844de33837b5 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Tue, 8 Oct 2024 12:18:39 +0000 Subject: [PATCH 20/86] refactor: remove dead step from repair --- .github/workflows/Build-Rock.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 2f5ea903..8374c98f 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -96,16 +96,8 @@ jobs: python-version: "3.x" # ** Workflow job configuration ** - - run: pip install -r src/build_rock/configure/requirements.txt - # - uses: actions/checkout@v4 - # with: - # repository: ${{ inputs.rock-repo }} - # path: ${{ env.ROCK_REPO_DIR }} - # ref: ${{ inputs.rock-repo-commit }} - # submodules: "recursive" - # Configure matrices for each *-build job - name: Configure id: configure From 73ef99aa8851c499329e67235c576fb1bdb4ba23 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Tue, 8 Oct 2024 12:21:59 +0000 Subject: [PATCH 21/86] fix: stray checkout --- .github/workflows/Build-Rock.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 59af5852..4c0287e1 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -79,7 +79,6 @@ jobs: submodules: "recursive" fetch-depth: 1 - - run: git checkout ${{ inputs.rock-repo-commit }} - run: sudo snap install yq --channel=v4/stable - name: Validate image naming and base From b2ecdcf8ea2829a9eb0e9eb52d8c50b5cb7f2650 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Tue, 8 Oct 2024 13:09:17 +0000 Subject: [PATCH 22/86] refactor(src/build_rock/configure/generate_build_matrix.py): used default iterator in set cast --- src/build_rock/configure/generate_build_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build_rock/configure/generate_build_matrix.py b/src/build_rock/configure/generate_build_matrix.py index 5ef1cde4..8c1dc9cf 100755 --- a/src/build_rock/configure/generate_build_matrix.py +++ b/src/build_rock/configure/generate_build_matrix.py @@ -45,7 +45,7 @@ def configure_matrices(target_archs: list, arch_map: dict, lp_fallback: bool) -> build_matrices = {name.value: {"include": []} for name in MATRIX_NAMES} # Check if we have runners for all supported architectures - if missing_archs := set(target_archs) - set(arch_map.keys()): + if missing_archs := set(target_archs) - set(arch_map): # raise exception if we cannot fallback to LP builds if not lp_fallback: From 34d14cd6df8846ad6e19d075b5bc8a45537ee656 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Tue, 8 Oct 2024 13:09:28 +0000 Subject: [PATCH 23/86] refactor(.github/workflows/Build-Rock.yaml): extra line --- .github/workflows/Build-Rock.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 4c0287e1..9e1ad237 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -79,7 +79,6 @@ jobs: submodules: "recursive" fetch-depth: 1 - - run: sudo snap install yq --channel=v4/stable - name: Validate image naming and base working-directory: ${{ inputs.rockfile-directory }} From a22eb9de58a27fac499187c352eced50e585114c Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Tue, 8 Oct 2024 21:08:27 +0000 Subject: [PATCH 24/86] test build: prototype dynamic branch selection --- .github/workflows/Build-Rock.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 9e1ad237..c6646a17 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -49,10 +49,18 @@ jobs: outputs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} + oci-factory-branch: ${{ steps.oci-factory-branch.outputs.branch }} steps: # ** Workflow authorization and job validation ** # Checkout the OCI Factory repo for the actor validation + + # move this to an action since it may be used frequently + - name: Select oci-factory branch + id: oci-factory-branch + run: echo "branch=$(${{ github.repository == 'canonical/oci-factory' }} && echo something || echo ${{ env.OCI_FACTORY_BRANCH }})" >> $GITHUB_OUTPUT + + - uses: actions/checkout@v4 if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} @@ -160,7 +168,7 @@ jobs: - uses: actions/checkout@v4 with: repository: ${{ env.OCI_FACTORY_REPO }} - ref: ${{ env.OCI_FACTORY_BRANCH }} + ref: ${{ needs.configure-build.outputs.oci-factory-branch }} fetch-depth: 1 - name: Clone Repo @@ -209,7 +217,7 @@ jobs: - uses: actions/checkout@v4 with: repository: ${{ env.OCI_FACTORY_REPO }} - ref: ${{ env.OCI_FACTORY_BRANCH }} + ref: ${{ needs.configure-build.outputs.oci-factory-branch }} fetch-depth: 1 - run: src/build_rock/assemble_rock/requirements.sh From ac8dee47c7e4006eba38ff7dab45993d7332d2b2 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 06:35:41 +0000 Subject: [PATCH 25/86] fix: set select branch name --- .github/workflows/Build-Rock.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index c6646a17..5f8b3123 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -39,7 +39,7 @@ env: OCI_FACTORY_REPO: canonical/oci-factory # TODO: update before final merge - OCI_FACTORY_BRANCH: ROCKS-1452/oci-factory-refactor-build-rock-to-be-externally-reusable # required for external workflow calls. + OCI_FACTORY_BRANCH: main # required for external workflow calls. jobs: configure-build: @@ -58,11 +58,14 @@ jobs: # move this to an action since it may be used frequently - name: Select oci-factory branch id: oci-factory-branch - run: echo "branch=$(${{ github.repository == 'canonical/oci-factory' }} && echo something || echo ${{ env.OCI_FACTORY_BRANCH }})" >> $GITHUB_OUTPUT - + run: echo "branch=$(${{ github.repository == 'canonical/oci-factory' }} && echo ${{ github.ref }} || echo ${{ env.OCI_FACTORY_BRANCH }})" >> $GITHUB_OUTPUT - uses: actions/checkout@v4 if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} + with: + repository: ${{ env.OCI_FACTORY_REPO }} + ref: ${{ steps.configure-build.outputs.branch }} + fetch-depth: 1 - name: Validate access to triggered image uses: ./.github/actions/validate-actor From c0a869cb955429eeb92f9bb6be6eb726c5266dd6 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 07:13:14 +0000 Subject: [PATCH 26/86] fix: switch to ref name --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 5f8b3123..5bd6a071 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -58,7 +58,7 @@ jobs: # move this to an action since it may be used frequently - name: Select oci-factory branch id: oci-factory-branch - run: echo "branch=$(${{ github.repository == 'canonical/oci-factory' }} && echo ${{ github.ref }} || echo ${{ env.OCI_FACTORY_BRANCH }})" >> $GITHUB_OUTPUT + run: echo "branch=$(${{ github.repository == 'canonical/oci-factory' }} && echo ${{ github.ref_name }} || echo ${{ env.OCI_FACTORY_BRANCH }})" >> $GITHUB_OUTPUT - uses: actions/checkout@v4 if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} From 34a2bbea4a8ce7488c4211777d19a1f71e4b9b20 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 07:26:11 +0000 Subject: [PATCH 27/86] fix: corrected validation paths --- .github/workflows/Build-Rock.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 5bd6a071..bd6ea47f 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -92,9 +92,8 @@ jobs: - run: sudo snap install yq --channel=v4/stable - name: Validate image naming and base - working-directory: ${{ inputs.rockfile-directory }} run: | - rock_name=`cat ${{ env.ROCK_REPO_DIR }}/rockcraft.y*ml | yq -r .name` + rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/rockcraft.y*ml" | yq -r .name` if [[ "${{ inputs.oci-factory-path }}" != *"${rock_name}"* ]] then echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name!" From bdabf43dd241a4dfe3c061987b7795eafd14024b Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 07:30:23 +0000 Subject: [PATCH 28/86] test buidl with debug statment --- .github/workflows/Build-Rock.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index bd6ea47f..3e178d8e 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -93,6 +93,7 @@ jobs: - run: sudo snap install yq --channel=v4/stable - name: Validate image naming and base run: | + ls -lashR rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/rockcraft.y*ml" | yq -r .name` if [[ "${{ inputs.oci-factory-path }}" != *"${rock_name}"* ]] then From cc48df3f90b219a4c0b03f01eb80181f844b7353 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 07:36:27 +0000 Subject: [PATCH 29/86] test build --- .github/workflows/Build-Rock.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 3e178d8e..2571a62f 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -93,7 +93,8 @@ jobs: - run: sudo snap install yq --channel=v4/stable - name: Validate image naming and base run: | - ls -lashR + # ls -lashR + cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/rockcraft.y*ml" rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/rockcraft.y*ml" | yq -r .name` if [[ "${{ inputs.oci-factory-path }}" != *"${rock_name}"* ]] then From 842aa07a3c0d3d9a63337bda77d47f3fb6b74b63 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 07:43:29 +0000 Subject: [PATCH 30/86] fix: correct glob behavior --- .github/workflows/Build-Rock.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 2571a62f..aa3936c7 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -93,9 +93,7 @@ jobs: - run: sudo snap install yq --channel=v4/stable - name: Validate image naming and base run: | - # ls -lashR - cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/rockcraft.y*ml" - rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/rockcraft.y*ml" | yq -r .name` + rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` if [[ "${{ inputs.oci-factory-path }}" != *"${rock_name}"* ]] then echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name!" From d73c3233e1eb35c8c8c771425fe4b8b9b040c720 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 07:48:20 +0000 Subject: [PATCH 31/86] fix: correct folder name validation --- .github/workflows/Build-Rock.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index aa3936c7..3a6cc35d 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -94,7 +94,8 @@ jobs: - name: Validate image naming and base run: | rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` - if [[ "${{ inputs.oci-factory-path }}" != *"${rock_name}"* ]] + folder_name=`basename "${{ inputs.rockfile-directory }}"` + if [[ "${folder_name}" != "${rock_name}" ]] then echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name!" exit 1 From 296eb2380d174ba02257dcee5308142ba2b25835 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 07:50:30 +0000 Subject: [PATCH 32/86] test build: check folder_name --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 3a6cc35d..eef29372 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -97,7 +97,7 @@ jobs: folder_name=`basename "${{ inputs.rockfile-directory }}"` if [[ "${folder_name}" != "${rock_name}" ]] then - echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name!" + echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name '${folder_name}'" exit 1 fi - uses: actions/setup-python@v5 From 3670096e8758a01f0ac77ed3191f0c1020ef9454 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 07:55:42 +0000 Subject: [PATCH 33/86] fix: disable image folder validation --- .github/workflows/Build-Rock.yaml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index eef29372..9054136a 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -90,19 +90,19 @@ jobs: submodules: "recursive" fetch-depth: 1 - - run: sudo snap install yq --channel=v4/stable - - name: Validate image naming and base - run: | - rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` - folder_name=`basename "${{ inputs.rockfile-directory }}"` - if [[ "${folder_name}" != "${rock_name}" ]] - then - echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name '${folder_name}'" - exit 1 - fi - - uses: actions/setup-python@v5 - with: - python-version: "3.x" + # - run: sudo snap install yq --channel=v4/stable + # - name: Validate image naming and base + # run: | + # rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` + # folder_name=`basename "${{ inputs.rockfile-directory }}"` + # if [[ "${folder_name}" != "${rock_name}" ]] + # then + # echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name '${folder_name}'" + # exit 1 + # fi + # - uses: actions/setup-python@v5 + # with: + # python-version: "3.x" # ** Workflow job configuration ** - run: pip install -r src/build_rock/configure/requirements.txt From 616f4db9b1e7669cac13b25c48a9c057a25fe4ea Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 08:14:48 +0000 Subject: [PATCH 34/86] test build --- .github/workflows/Build-Rock.yaml | 5 +++-- src/build_rock/configure/requirements.txt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 9054136a..c47f7f4c 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -76,8 +76,8 @@ jobs: github-token: ${{ secrets.ROCKSBOT_TOKEN }} # We clear the working directory to make space for the rock repo - - run: rm -rf ./* - if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} + # - run: rm -rf ./* + # if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} - name: Clone GitHub image repository uses: actions/checkout@v4 @@ -105,6 +105,7 @@ jobs: # python-version: "3.x" # ** Workflow job configuration ** + - run: ls -lashR src - run: pip install -r src/build_rock/configure/requirements.txt # Configure matrices for each *-build job diff --git a/src/build_rock/configure/requirements.txt b/src/build_rock/configure/requirements.txt index f71072f4..d04c0606 100644 --- a/src/build_rock/configure/requirements.txt +++ b/src/build_rock/configure/requirements.txt @@ -1,2 +1,2 @@ pyyaml==6.0.2 -pydantic==2.8.2 \ No newline at end of file +pydantic==2.8.2 From 3d342f31cc00b19252b31bc840a1fa3bfe88808a Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 08:43:55 +0000 Subject: [PATCH 35/86] feat: add access validation job --- .github/workflows/Build-Rock.yaml | 86 +++++++++++++++++-------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index c47f7f4c..711af159 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -39,49 +39,67 @@ env: OCI_FACTORY_REPO: canonical/oci-factory # TODO: update before final merge - OCI_FACTORY_BRANCH: main # required for external workflow calls. + OCI_FACTORY_BRANCH: ${{ github.repository == 'canonical/oci-factory' && github.ref_name || main }} # required for external workflow calls. jobs: - configure-build: - # configure-build reads the rockcraft.yaml, creating one or more *-build job runs - # depending on the target architecture. + + access-validation: runs-on: ubuntu-22.04 - outputs: - runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} - lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} - oci-factory-branch: ${{ steps.oci-factory-branch.outputs.branch }} + if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} steps: - # ** Workflow authorization and job validation ** - # Checkout the OCI Factory repo for the actor validation - - # move this to an action since it may be used frequently - - name: Select oci-factory branch - id: oci-factory-branch - run: echo "branch=$(${{ github.repository == 'canonical/oci-factory' }} && echo ${{ github.ref_name }} || echo ${{ env.OCI_FACTORY_BRANCH }})" >> $GITHUB_OUTPUT - - uses: actions/checkout@v4 - if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} with: repository: ${{ env.OCI_FACTORY_REPO }} ref: ${{ steps.configure-build.outputs.branch }} fetch-depth: 1 + - name: Clone GitHub image repository + uses: actions/checkout@v4 + with: + repository: ${{ inputs.rock-repo }} + path: ${{ env.ROCK_REPO_DIR }} + ref: ${{ inputs.rock-repo-commit }} + submodules: "recursive" + fetch-depth: 1 + - name: Validate access to triggered image uses: ./.github/actions/validate-actor - if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} with: admin-only: true image-path: ${{ inputs.oci-factory-path }} github-token: ${{ secrets.ROCKSBOT_TOKEN }} - # We clear the working directory to make space for the rock repo - # - run: rm -rf ./* - # if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} + + - run: sudo snap install yq --channel=v4/stable + - name: Validate image naming and base + run: | + rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` + folder_name=`basename "${{ inputs.rockfile-directory }}"` + if [[ "${folder_name}" != "${rock_name}" ]] + then + echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name '${folder_name}'" + exit 1 + fi + + configure-build: + # configure-build reads the rockcraft.yaml, creating one or more *-build job runs + # depending on the target architecture. + needs: [access-validation] + runs-on: ubuntu-22.04 + outputs: + runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} + lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} + steps: + + - uses: actions/checkout@v4 + with: + repository: ${{ env.OCI_FACTORY_REPO }} + ref: ${{ steps.configure-build.outputs.branch }} + fetch-depth: 1 - name: Clone GitHub image repository uses: actions/checkout@v4 - id: clone-image-repo continue-on-error: true with: repository: ${{ inputs.rock-repo }} @@ -90,22 +108,10 @@ jobs: submodules: "recursive" fetch-depth: 1 - # - run: sudo snap install yq --channel=v4/stable - # - name: Validate image naming and base - # run: | - # rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` - # folder_name=`basename "${{ inputs.rockfile-directory }}"` - # if [[ "${folder_name}" != "${rock_name}" ]] - # then - # echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name '${folder_name}'" - # exit 1 - # fi - # - uses: actions/setup-python@v5 - # with: - # python-version: "3.x" - - # ** Workflow job configuration ** - - run: ls -lashR src + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + - run: pip install -r src/build_rock/configure/requirements.txt # Configure matrices for each *-build job @@ -172,7 +178,7 @@ jobs: - uses: actions/checkout@v4 with: repository: ${{ env.OCI_FACTORY_REPO }} - ref: ${{ needs.configure-build.outputs.oci-factory-branch }} + ref: ${{ env.OCI_FACTORY_BRANCH }} fetch-depth: 1 - name: Clone Repo @@ -221,7 +227,7 @@ jobs: - uses: actions/checkout@v4 with: repository: ${{ env.OCI_FACTORY_REPO }} - ref: ${{ needs.configure-build.outputs.oci-factory-branch }} + ref: ${{ env.OCI_FACTORY_BRANCH }} fetch-depth: 1 - run: src/build_rock/assemble_rock/requirements.sh From d44fa58737e64def887c60a7c9019f3cbbe566d0 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 08:46:25 +0000 Subject: [PATCH 36/86] trigger test build --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 711af159..56233570 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -34,7 +34,7 @@ on: default: false env: - ROCK_REPO_DIR: rock-repo # path where the image repo is cloned to + ROCK_REPO_DIR: rock-repo # path where the image repo is cloned into ROCK_CI_FOLDER: ci-rocks # path of uploaded/downloaded artifacts OCI_FACTORY_REPO: canonical/oci-factory From f4319ef1fe8542bbbac28be4137b0c9d554a1080 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 08:48:02 +0000 Subject: [PATCH 37/86] fix(.github/workflows/Build-Rock.yaml): invalid yaml syntax --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 56233570..36581eb1 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -39,7 +39,7 @@ env: OCI_FACTORY_REPO: canonical/oci-factory # TODO: update before final merge - OCI_FACTORY_BRANCH: ${{ github.repository == 'canonical/oci-factory' && github.ref_name || main }} # required for external workflow calls. + OCI_FACTORY_BRANCH: ${{ github.repository == 'canonical/oci-factory' && github.ref_name || 'main' }} # required for external workflow calls. jobs: From 168bc23389559dd4580a02d4d5576209ca152a93 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 09:03:35 +0000 Subject: [PATCH 38/86] fix: path validation and step namea --- .github/workflows/Build-Rock.yaml | 68 +++++++++++++++++-------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 36581eb1..51537b2b 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -38,7 +38,6 @@ env: ROCK_CI_FOLDER: ci-rocks # path of uploaded/downloaded artifacts OCI_FACTORY_REPO: canonical/oci-factory - # TODO: update before final merge OCI_FACTORY_BRANCH: ${{ github.repository == 'canonical/oci-factory' && github.ref_name || 'main' }} # required for external workflow calls. jobs: @@ -48,12 +47,21 @@ jobs: if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} steps: - - uses: actions/checkout@v4 + - name: Cloning OCI Factory + uses: actions/checkout@v4 with: repository: ${{ env.OCI_FACTORY_REPO }} ref: ${{ steps.configure-build.outputs.branch }} fetch-depth: 1 + - name: Validate access to triggered image + uses: ./.github/actions/validate-actor + with: + admin-only: true + image-path: ${{ inputs.oci-factory-path }} + github-token: ${{ secrets.ROCKSBOT_TOKEN }} + + - name: Clone GitHub image repository uses: actions/checkout@v4 with: @@ -63,22 +71,16 @@ jobs: submodules: "recursive" fetch-depth: 1 - - name: Validate access to triggered image - uses: ./.github/actions/validate-actor - with: - admin-only: true - image-path: ${{ inputs.oci-factory-path }} - github-token: ${{ secrets.ROCKSBOT_TOKEN }} - + - name: Installing yq + run: sudo snap install yq --channel=v4/stable - - run: sudo snap install yq --channel=v4/stable - name: Validate image naming and base run: | rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` - folder_name=`basename "${{ inputs.rockfile-directory }}"` - if [[ "${folder_name}" != "${rock_name}" ]] + folder_name="${{ inputs.oci-factory-path }}" + if [[ "${folder_name}" != *"${rock_name}"* ]] then - echo "ERROR: the rock's name '${rock_name}' must match the OCI folder name '${folder_name}'" + echo "ERROR: the OCI folder name '${folder_name}', must contain the rock's name '${rock_name}'." exit 1 fi @@ -92,13 +94,14 @@ jobs: lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} steps: - - uses: actions/checkout@v4 + - name: Cloning OCI Factory + uses: actions/checkout@v4 with: repository: ${{ env.OCI_FACTORY_REPO }} ref: ${{ steps.configure-build.outputs.branch }} fetch-depth: 1 - - name: Clone GitHub image repository + - name: Cloning Target Repo uses: actions/checkout@v4 continue-on-error: true with: @@ -108,14 +111,16 @@ jobs: submodules: "recursive" fetch-depth: 1 - - uses: actions/setup-python@v5 + - name: Installing Python + uses: actions/setup-python@v5 with: python-version: "3.x" - - run: pip install -r src/build_rock/configure/requirements.txt + - name: Installing Python requirements + run: pip install -r src/build_rock/configure/requirements.txt # Configure matrices for each *-build job - - name: Configure + - name: Configuring Jobs id: configure run: | python3 -m src.build_rock.configure.generate_build_matrix \ @@ -133,7 +138,7 @@ jobs: runs-on: ${{ matrix.runner }} name: "runner-build | ${{ matrix.architecture }} " steps: - - name: Clone Repo + - name: Cloning Target Repo uses: actions/checkout@v4 with: repository: ${{ inputs.rock-repo }} @@ -141,20 +146,20 @@ jobs: ref: ${{ inputs.rock-repo-commit }} submodules: "recursive" - - name: Build Target + - name: Building Target id: rockcraft uses: canonical/craft-actions/rockcraft-pack@main with: path: "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}" verbosity: debug - - name: Collect Artifacts + - name: Collecting Artifacts id: collect-artifacts run: | mkdir -p ${{ env.ROCK_CI_FOLDER }} && cp ${{ steps.rockcraft.outputs.rock }} "$_" echo "filename=$(basename ${{ steps.rockcraft.outputs.rock }})" >> $GITHUB_OUTPUT - - name: Upload Artifacts + - name: Uploading Artifacts uses: actions/upload-artifact@v4 with: name: ${{ inputs.oci-archive-name }}-${{ steps.collect-artifacts.outputs.filename }} @@ -174,14 +179,15 @@ jobs: runs-on: ubuntu-22.04 name: "lpci-build | ${{ matrix.architecture }} " steps: - # Job Setup - - uses: actions/checkout@v4 + + - name: Cloning OCI Factory + uses: actions/checkout@v4 with: repository: ${{ env.OCI_FACTORY_REPO }} ref: ${{ env.OCI_FACTORY_BRANCH }} fetch-depth: 1 - - name: Clone Repo + - name: Cloning Target Repo uses: actions/checkout@v4 with: repository: ${{ inputs.rock-repo }} @@ -189,7 +195,7 @@ jobs: ref: ${{ inputs.rock-repo-commit }} submodules: "recursive" - - name: Build Target + - name: Building Target # TODO: Replace this retry action with bash equivalent for better testing uses: nick-fields/retry@v3.0.0 with: @@ -202,13 +208,13 @@ jobs: -c "${{ secrets.LP_CREDENTIALS_B64 }}" \ -d "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}" - - name: Collect Artifacts + - name: Collecting Artifacts id: collect-artifacts run: | mkdir -p ${{ env.ROCK_CI_FOLDER }} && cp ${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}/*.rock "$_" echo "filename=${{ matrix.rock-name }}_${{ matrix.architecture }}" >> $GITHUB_OUTPUT - - name: Upload Artifacts + - name: Uploading Artifacts uses: actions/upload-artifact@v4 with: name: ${{ inputs.oci-archive-name }}-${{ steps.collect-artifacts.outputs.filename }} @@ -231,20 +237,20 @@ jobs: fetch-depth: 1 - run: src/build_rock/assemble_rock/requirements.sh - - name: Download Single Arch rocks + - name: Downloading Single Arch rocks uses: actions/download-artifact@v4 id: download with: path: ${{ env.ROCK_CI_FOLDER }} pattern: ${{ inputs.oci-archive-name }}-* - - name: Assemble Multi Arch rock + - name: Assembling Multi Arch rock run: | src/build_rock/assemble_rock/assemble.sh \ -n "${{ inputs.oci-archive-name }}" \ -d "${{ env.ROCK_CI_FOLDER }}" - - name: Upload Multi Arch rock + - name: Uploading Multi Arch rock uses: actions/upload-artifact@v4 with: name: ${{ inputs.oci-archive-name }} From 445c324c5d5629306e2b7647c8131fc834e1e849 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 09:18:03 +0000 Subject: [PATCH 39/86] refactor: move path validation outside of build rock repo --- .github/workflows/Build-Rock.yaml | 44 ------------------------------- .github/workflows/Image.yaml | 14 ++++++++++ 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 51537b2b..50aa5dcc 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -41,53 +41,9 @@ env: OCI_FACTORY_BRANCH: ${{ github.repository == 'canonical/oci-factory' && github.ref_name || 'main' }} # required for external workflow calls. jobs: - - access-validation: - runs-on: ubuntu-22.04 - if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} - steps: - - - name: Cloning OCI Factory - uses: actions/checkout@v4 - with: - repository: ${{ env.OCI_FACTORY_REPO }} - ref: ${{ steps.configure-build.outputs.branch }} - fetch-depth: 1 - - - name: Validate access to triggered image - uses: ./.github/actions/validate-actor - with: - admin-only: true - image-path: ${{ inputs.oci-factory-path }} - github-token: ${{ secrets.ROCKSBOT_TOKEN }} - - - - name: Clone GitHub image repository - uses: actions/checkout@v4 - with: - repository: ${{ inputs.rock-repo }} - path: ${{ env.ROCK_REPO_DIR }} - ref: ${{ inputs.rock-repo-commit }} - submodules: "recursive" - fetch-depth: 1 - - - name: Installing yq - run: sudo snap install yq --channel=v4/stable - - - name: Validate image naming and base - run: | - rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` - folder_name="${{ inputs.oci-factory-path }}" - if [[ "${folder_name}" != *"${rock_name}"* ]] - then - echo "ERROR: the OCI folder name '${folder_name}', must contain the rock's name '${rock_name}'." - exit 1 - fi - configure-build: # configure-build reads the rockcraft.yaml, creating one or more *-build job runs # depending on the target architecture. - needs: [access-validation] runs-on: ubuntu-22.04 outputs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index 9bc25913..d591c54b 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -123,6 +123,20 @@ jobs: --oci-path ${{ steps.validate-image.outputs.img-path }} \ --revision-data-dir ${{ env.DATA_DIR }} + - name: Installing yq + run: sudo snap install yq --channel=v4/stable + + - name: Validate image naming and base + run: | + rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` + folder_name="${{ inputs.oci-factory-path }}" + if [[ "${folder_name}" != *"${rock_name}"* ]] + then + echo "ERROR: the OCI folder name '${folder_name}', must contain the rock's name '${rock_name}'." + exit 1 + fi + + run-build: needs: [prepare-build] strategy: From 3b0933be141ac8cb90799d68fd92e506ffb274df Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 09:32:33 +0000 Subject: [PATCH 40/86] feat: added job to image workflow for matrix validation --- .github/workflows/Image.yaml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index d591c54b..f761f956 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -123,13 +123,30 @@ jobs: --oci-path ${{ steps.validate-image.outputs.img-path }} \ --revision-data-dir ${{ env.DATA_DIR }} + validate-matrix: + # validate matrix previously prepared for oci-factory + runs-on: ubuntu-22.04 + needs: [prepare-build] + strategy: + fail-fast: true + matrix: ${{ fromJSON(needs.prepare-build.outputs.build-matrix) }} + steps: + + - name: Clone GitHub image repository + uses: actions/checkout@v4 + with: + repository: ${{ matrix.source }} + ref: ${{ matrix.commit }} + submodules: "recursive" + fetch-depth: 1 + - name: Installing yq run: sudo snap install yq --channel=v4/stable - name: Validate image naming and base run: | - rock_name=`cat "${{ env.ROCK_REPO_DIR }}/${{ inputs.rockfile-directory }}"/rockcraft.y*ml | yq -r .name` - folder_name="${{ inputs.oci-factory-path }}" + rock_name=`cat "${{ matrix.directory }}"/rockcraft.y*ml | yq -r .name` + folder_name="${{ matrix.path }}" if [[ "${folder_name}" != *"${rock_name}"* ]] then echo "ERROR: the OCI folder name '${folder_name}', must contain the rock's name '${rock_name}'." @@ -138,7 +155,7 @@ jobs: run-build: - needs: [prepare-build] + needs: [prepare-build, validate-build] strategy: fail-fast: true matrix: ${{ fromJSON(needs.prepare-build.outputs.build-matrix) }} From 426cdff847882796983f1aca36b308b7c98302a8 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 09:37:01 +0000 Subject: [PATCH 41/86] fix(Image.yaml): bad job name --- .github/workflows/Image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index f761f956..cdf348c6 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -155,7 +155,7 @@ jobs: run-build: - needs: [prepare-build, validate-build] + needs: [prepare-build, validate-matrix] strategy: fail-fast: true matrix: ${{ fromJSON(needs.prepare-build.outputs.build-matrix) }} From f98894119c6410b8768b32d56f5b98f733904b7b Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 09:42:07 +0000 Subject: [PATCH 42/86] refactor(Image.yaml): adjust whitespace and comments --- .github/workflows/Image.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index cdf348c6..1ff883b2 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -124,7 +124,7 @@ jobs: --revision-data-dir ${{ env.DATA_DIR }} validate-matrix: - # validate matrix previously prepared for oci-factory + # validate matrix prepared in previous job before running Build-Rock workflow. runs-on: ubuntu-22.04 needs: [prepare-build] strategy: @@ -153,7 +153,6 @@ jobs: exit 1 fi - run-build: needs: [prepare-build, validate-matrix] strategy: From 3511bce6f01a5a70b5b3b162afa39fe121580786 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Wed, 9 Oct 2024 09:47:42 +0000 Subject: [PATCH 43/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11252315563 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 679461d1..21373197 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "584" + "target": "592" }, "beta": { - "target": "584" + "target": "592" }, "edge": { - "target": "584" + "target": "592" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "584" + "target": "592" }, "beta": { - "target": "584" + "target": "592" }, "edge": { - "target": "584" + "target": "592" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "585" + "target": "593" }, "edge": { "target": "1.2-22.04_beta" From 51968d12bc54ae12af75b7bb319f699b78d71b8f Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 11:22:15 +0000 Subject: [PATCH 44/86] test: github property exposing wf call params --- .github/workflows/Build-Rock.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 50aa5dcc..a05d99f4 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -50,6 +50,9 @@ jobs: lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} steps: + - run: echo WORKFLOW REF "${{ github.workflow_ref }}" + - run: echo WORKFLOW SHA "${{ github.workflow_sha }}" + - name: Cloning OCI Factory uses: actions/checkout@v4 with: From 9e214700ea08fc01bd080ba1c33f2b107824386c Mon Sep 17 00:00:00 2001 From: clay-lake Date: Wed, 9 Oct 2024 11:36:42 +0000 Subject: [PATCH 45/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11253931903 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 21373197..de9a016c 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "592" + "target": "594" }, "beta": { - "target": "592" + "target": "594" }, "edge": { - "target": "592" + "target": "594" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "592" + "target": "594" }, "beta": { - "target": "592" + "target": "594" }, "edge": { - "target": "592" + "target": "594" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "593" + "target": "595" }, "edge": { "target": "1.2-22.04_beta" From 9430e88f9607570309903dfca2ba051985c4972c Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 12:01:33 +0000 Subject: [PATCH 46/86] feat: forward workflow ref to self checkout --- .github/workflows/Build-Rock.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index a05d99f4..324a93a2 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -37,9 +37,6 @@ env: ROCK_REPO_DIR: rock-repo # path where the image repo is cloned into ROCK_CI_FOLDER: ci-rocks # path of uploaded/downloaded artifacts - OCI_FACTORY_REPO: canonical/oci-factory - OCI_FACTORY_BRANCH: ${{ github.repository == 'canonical/oci-factory' && github.ref_name || 'main' }} # required for external workflow calls. - jobs: configure-build: # configure-build reads the rockcraft.yaml, creating one or more *-build job runs @@ -48,16 +45,19 @@ jobs: outputs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} + oci-factory-branch: ${{ steps.select-oci-factory-branch.outputs.oci-factory-branch }} steps: - - run: echo WORKFLOW REF "${{ github.workflow_ref }}" - - run: echo WORKFLOW SHA "${{ github.workflow_sha }}" + - name: Select OCI Factory Branch + id: select-oci-factory-branch + run: | + echo "oci-factory-branch=$(echo "${{ github.workflow_ref }}" | sed s/.*@//)">> GITHUB_OUTPUT - name: Cloning OCI Factory uses: actions/checkout@v4 with: - repository: ${{ env.OCI_FACTORY_REPO }} - ref: ${{ steps.configure-build.outputs.branch }} + repository: canonical/oci-factory + ref: ${{ steps.select-oci-factory-branch.outputs.oci-factory-branch }} fetch-depth: 1 - name: Cloning Target Repo @@ -142,8 +142,8 @@ jobs: - name: Cloning OCI Factory uses: actions/checkout@v4 with: - repository: ${{ env.OCI_FACTORY_REPO }} - ref: ${{ env.OCI_FACTORY_BRANCH }} + repository: canonical/oci-factory + ref: ${{ needs.configure-build.outputs.oci-factory-branch }} fetch-depth: 1 - name: Cloning Target Repo @@ -191,8 +191,8 @@ jobs: # Job Setup - uses: actions/checkout@v4 with: - repository: ${{ env.OCI_FACTORY_REPO }} - ref: ${{ env.OCI_FACTORY_BRANCH }} + repository: canonical/oci-factory + ref: ${{ needs.configure-build.outputs.oci-factory-branch }} fetch-depth: 1 - run: src/build_rock/assemble_rock/requirements.sh From 786af957226aeddc960d04280ff56f48159a1031 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 12:18:10 +0000 Subject: [PATCH 47/86] test build --- .github/workflows/Build-Rock.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 324a93a2..302f29df 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -48,6 +48,9 @@ jobs: oci-factory-branch: ${{ steps.select-oci-factory-branch.outputs.oci-factory-branch }} steps: + - run: cat github.event_path ${{ github.event_path }} + - run: cat github.event ${{ github.event }} + - name: Select OCI Factory Branch id: select-oci-factory-branch run: | From 42012403319f11c7d8bf41c0829ec73582e8d067 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 13:30:22 +0000 Subject: [PATCH 48/86] test: canonical/get-workflow-version-action@v1 --- .github/workflows/Build-Rock.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 302f29df..683fff2b 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -48,8 +48,14 @@ jobs: oci-factory-branch: ${{ steps.select-oci-factory-branch.outputs.oci-factory-branch }} steps: - - run: cat github.event_path ${{ github.event_path }} - - run: cat github.event ${{ github.event }} + - name: Get workflow version + id: workflow-version + uses: canonical/get-workflow-version-action@v1 + with: + repository-name: canonical/oci-factory + file-name: Build-Rock.yaml + + - run: echo workflow-version ${{ steps.workflow-version.outputs }} - name: Select OCI Factory Branch id: select-oci-factory-branch From 5bd360cfc6a2024a64ae8dc4bd98a1280dc55aae Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 13:34:37 +0000 Subject: [PATCH 49/86] fix: missing toJSON call --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 683fff2b..e1470480 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -55,7 +55,7 @@ jobs: repository-name: canonical/oci-factory file-name: Build-Rock.yaml - - run: echo workflow-version ${{ steps.workflow-version.outputs }} + - run: echo workflow-version ${{ toJSON(steps.workflow-version.outputs) }} - name: Select OCI Factory Branch id: select-oci-factory-branch From d1e0edb01d2f3fa917f1157b208546d7437744de Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 13:40:49 +0000 Subject: [PATCH 50/86] test: checkout self according to sha --- .github/workflows/Build-Rock.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index e1470480..e2cc2651 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -45,7 +45,7 @@ jobs: outputs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} - oci-factory-branch: ${{ steps.select-oci-factory-branch.outputs.oci-factory-branch }} + oci-factory-ref: ${{ steps.select-oci-factory-ref.outputs.oci-factory-ref }} steps: - name: Get workflow version @@ -55,18 +55,18 @@ jobs: repository-name: canonical/oci-factory file-name: Build-Rock.yaml - - run: echo workflow-version ${{ toJSON(steps.workflow-version.outputs) }} + - run: echo workflow-version ${{ steps.workflow-version.outputs.sha }} - name: Select OCI Factory Branch - id: select-oci-factory-branch + id: select-oci-factory-ref run: | - echo "oci-factory-branch=$(echo "${{ github.workflow_ref }}" | sed s/.*@//)">> GITHUB_OUTPUT + echo "oci-factory-ref=$(echo "${{ steps.workflow-version.outputs.sha }}">> GITHUB_OUTPUT - name: Cloning OCI Factory uses: actions/checkout@v4 with: repository: canonical/oci-factory - ref: ${{ steps.select-oci-factory-branch.outputs.oci-factory-branch }} + ref: ${{ steps.select-oci-factory-ref.outputs.oci-factory-ref }} fetch-depth: 1 - name: Cloning Target Repo @@ -152,7 +152,7 @@ jobs: uses: actions/checkout@v4 with: repository: canonical/oci-factory - ref: ${{ needs.configure-build.outputs.oci-factory-branch }} + ref: ${{ needs.configure-build.outputs.oci-factory-ref }} fetch-depth: 1 - name: Cloning Target Repo @@ -201,7 +201,7 @@ jobs: - uses: actions/checkout@v4 with: repository: canonical/oci-factory - ref: ${{ needs.configure-build.outputs.oci-factory-branch }} + ref: ${{ needs.configure-build.outputs.oci-factory-ref }} fetch-depth: 1 - run: src/build_rock/assemble_rock/requirements.sh From df5df0d934af68ec4e6cb6c9396ec457c0035c0f Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 13:43:45 +0000 Subject: [PATCH 51/86] fix: bash syntax error --- .github/workflows/Build-Rock.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index e2cc2651..94f3ce16 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -55,12 +55,10 @@ jobs: repository-name: canonical/oci-factory file-name: Build-Rock.yaml - - run: echo workflow-version ${{ steps.workflow-version.outputs.sha }} - - name: Select OCI Factory Branch id: select-oci-factory-ref run: | - echo "oci-factory-ref=$(echo "${{ steps.workflow-version.outputs.sha }}">> GITHUB_OUTPUT + echo "oci-factory-ref=$(echo "${{ steps.workflow-version.outputs.sha }})">> GITHUB_OUTPUT - name: Cloning OCI Factory uses: actions/checkout@v4 From 271c535a6f036b968f2a895831366d1fddc16d14 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 13:48:52 +0000 Subject: [PATCH 52/86] fix: bash syntax error --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 94f3ce16..bdde1f84 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -58,7 +58,7 @@ jobs: - name: Select OCI Factory Branch id: select-oci-factory-ref run: | - echo "oci-factory-ref=$(echo "${{ steps.workflow-version.outputs.sha }})">> GITHUB_OUTPUT + echo "oci-factory-ref=$(echo "${{ steps.workflow-version.outputs.sha }}")>> GITHUB_OUTPUT - name: Cloning OCI Factory uses: actions/checkout@v4 From dc7b5339bf56afd78cc8a1193728c71c5c3d5277 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 13:52:31 +0000 Subject: [PATCH 53/86] fix: syntax errors in workflow --- .github/workflows/Build-Rock.yaml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index bdde1f84..c6335275 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -45,7 +45,7 @@ jobs: outputs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} - oci-factory-ref: ${{ steps.select-oci-factory-ref.outputs.oci-factory-ref }} + oci-factory-ref: ${{ steps.workflow-version.outputs.sha }} steps: - name: Get workflow version @@ -55,16 +55,11 @@ jobs: repository-name: canonical/oci-factory file-name: Build-Rock.yaml - - name: Select OCI Factory Branch - id: select-oci-factory-ref - run: | - echo "oci-factory-ref=$(echo "${{ steps.workflow-version.outputs.sha }}")>> GITHUB_OUTPUT - - name: Cloning OCI Factory uses: actions/checkout@v4 with: repository: canonical/oci-factory - ref: ${{ steps.select-oci-factory-ref.outputs.oci-factory-ref }} + ref: ${{ steps.workflow-version.outputs.sha }} fetch-depth: 1 - name: Cloning Target Repo From b6d8a238b007032ec9fa4e024aa504a22de1aee0 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 13:55:31 +0000 Subject: [PATCH 54/86] fix: correct step name --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index c6335275..244734c6 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -48,7 +48,7 @@ jobs: oci-factory-ref: ${{ steps.workflow-version.outputs.sha }} steps: - - name: Get workflow version + - name: Get Workflow Version id: workflow-version uses: canonical/get-workflow-version-action@v1 with: From d7e543b9f98fc1e0766ef8365845ec9a9742baf7 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 15:16:43 +0000 Subject: [PATCH 55/86] test: adaptor git checkout action --- .github/actions/checkout/action.yaml | 49 ++++++++++++++++++++++++++++ .github/workflows/Build-Rock.yaml | 6 ++-- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 .github/actions/checkout/action.yaml diff --git a/.github/actions/checkout/action.yaml b/.github/actions/checkout/action.yaml new file mode 100644 index 00000000..b60954ec --- /dev/null +++ b/.github/actions/checkout/action.yaml @@ -0,0 +1,49 @@ +name: Git Checkout +description: 'Checkout action supporting both github and non github repositories.' + + +inputs: + repository: + description: 'Repository name with owner (formatted owner/name) or git URL' + required: true + ref: + description: 'The branch, tag or SHA to checkout' + default: '' + path: + description: 'Relative path under $GITHUB_WORKSPACE to place the repository' + default: '.' + submodules: + description: 'Whether to checkout submodules. true|false|recuresive according to actions/checkout@v4' + default: 'false' + github-server-url: + description: 'The base URL for the GitHub instance that you are trying to clone from' + default: 'https://github.com' + +runs: + using: "composite" + steps: + - name: Checkout + shell: bash + run: | + + if [[ "${{ inputs.repository }}" =~ https?:// ]] + then + git_url="${{ inputs.repository }}" + else + git_url="${{ inputs.github-server-url }}/${{ inputs.repository }}" + fi + + repo_path="$GITHUB_WORKSPACE/${{ inputs.path }}" + + git clone $git_url "$repo_path" + cd "$repo_path" + + git checkout ${{ inputs.ref }} + + if ${{ inputs.submodules == 'true' || inputs.submodules == 'recuresive' }} + then + git submodule update ${{ inputs.submodules == 'recuresive' && '--recursive' || '' }} + fi + git checkout ${{ inputs.ref }} + + diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 244734c6..a4ad2694 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -49,6 +49,8 @@ jobs: steps: - name: Get Workflow Version + # Note: we may need to pass a github token when working with private repositories. + # https://github.com/canonical/get-workflow-version-action id: workflow-version uses: canonical/get-workflow-version-action@v1 with: @@ -63,14 +65,12 @@ jobs: fetch-depth: 1 - name: Cloning Target Repo - uses: actions/checkout@v4 - continue-on-error: true + uses: ./.github/actions/validate-actor with: repository: ${{ inputs.rock-repo }} path: ${{ env.ROCK_REPO_DIR }} ref: ${{ inputs.rock-repo-commit }} submodules: "recursive" - fetch-depth: 1 - name: Installing Python uses: actions/setup-python@v5 From fb7ee58e71e34f4a99bbbaa22b01e67c4ed5dd3f Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 15:17:21 +0000 Subject: [PATCH 56/86] fix: missing file extension --- .github/actions/checkout/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/checkout/action.yaml b/.github/actions/checkout/action.yaml index b60954ec..609dde0c 100644 --- a/.github/actions/checkout/action.yaml +++ b/.github/actions/checkout/action.yaml @@ -30,7 +30,7 @@ runs: then git_url="${{ inputs.repository }}" else - git_url="${{ inputs.github-server-url }}/${{ inputs.repository }}" + git_url="${{ inputs.github-server-url }}/${{ inputs.repository }}.git" fi repo_path="$GITHUB_WORKSPACE/${{ inputs.path }}" From 0e848d3d55b44eaebcc1fc408dfb1caf1b716093 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 15:19:53 +0000 Subject: [PATCH 57/86] fix: bad action path --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index a4ad2694..c929ff68 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -65,7 +65,7 @@ jobs: fetch-depth: 1 - name: Cloning Target Repo - uses: ./.github/actions/validate-actor + uses: ./.github/actions/checkout with: repository: ${{ inputs.rock-repo }} path: ${{ env.ROCK_REPO_DIR }} From 67947b03c11cb86ed0d2f5e9392c0819becbf57b Mon Sep 17 00:00:00 2001 From: clay-lake Date: Wed, 9 Oct 2024 15:37:23 +0000 Subject: [PATCH 58/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11258034237 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index de9a016c..a410ad2b 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "594" + "target": "600" }, "beta": { - "target": "594" + "target": "600" }, "edge": { - "target": "594" + "target": "600" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "594" + "target": "600" }, "beta": { - "target": "594" + "target": "600" }, "edge": { - "target": "594" + "target": "600" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "595" + "target": "601" }, "edge": { "target": "1.2-22.04_beta" From d50080752c8e4ace1cb3f5a8034d52d528cd84ca Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 19:40:19 +0000 Subject: [PATCH 59/86] fix: ignore detached head --- .github/actions/checkout/action.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/actions/checkout/action.yaml b/.github/actions/checkout/action.yaml index 609dde0c..b73eb64a 100644 --- a/.github/actions/checkout/action.yaml +++ b/.github/actions/checkout/action.yaml @@ -4,7 +4,7 @@ description: 'Checkout action supporting both github and non github repositories inputs: repository: - description: 'Repository name with owner (formatted owner/name) or git URL' + description: 'Github repository in the format owner/repo or external http(s) URL' required: true ref: description: 'The branch, tag or SHA to checkout' @@ -13,7 +13,7 @@ inputs: description: 'Relative path under $GITHUB_WORKSPACE to place the repository' default: '.' submodules: - description: 'Whether to checkout submodules. true|false|recuresive according to actions/checkout@v4' + description: 'Whether to checkout submodules. true|false|recursive according to actions/checkout@v4' default: 'false' github-server-url: description: 'The base URL for the GitHub instance that you are trying to clone from' @@ -26,6 +26,7 @@ runs: shell: bash run: | + # If URL lacks the protocol, assume it is a github repo if [[ "${{ inputs.repository }}" =~ https?:// ]] then git_url="${{ inputs.repository }}" @@ -33,17 +34,21 @@ runs: git_url="${{ inputs.github-server-url }}/${{ inputs.repository }}.git" fi + # create repo path relative to GITHUB_WORKSPACE as per actions/checkout@v4 repo_path="$GITHUB_WORKSPACE/${{ inputs.path }}" + # clone the repo and cd into it git clone $git_url "$repo_path" cd "$repo_path" + # checkout the correct ref + git config advice.detachedHead false git checkout ${{ inputs.ref }} - if ${{ inputs.submodules == 'true' || inputs.submodules == 'recuresive' }} + # and update sub modules if required + if ${{ inputs.submodules == 'true' || inputs.submodules == 'recursive' }} then - git submodule update ${{ inputs.submodules == 'recuresive' && '--recursive' || '' }} + git submodule update ${{ inputs.submodules == 'recursive' && '--recursive' || '' }} fi - git checkout ${{ inputs.ref }} From a2d47eacda3b570524ec62badd0d5ba9a23418bc Mon Sep 17 00:00:00 2001 From: clay-lake Date: Wed, 9 Oct 2024 19:52:05 +0000 Subject: [PATCH 60/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11261915875 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index a410ad2b..97c2c74b 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "600" + "target": "602" }, "beta": { - "target": "600" + "target": "602" }, "edge": { - "target": "600" + "target": "602" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "600" + "target": "602" }, "beta": { - "target": "600" + "target": "602" }, "edge": { - "target": "600" + "target": "602" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "601" + "target": "603" }, "edge": { "target": "1.2-22.04_beta" From b1b62d7b0236ba9ebdf36d932d685c38963e0944 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 9 Oct 2024 20:14:30 +0000 Subject: [PATCH 61/86] fix: replace standard checkout procedure --- .github/actions/checkout/action.yaml | 1 - .github/workflows/Build-Rock.yaml | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/checkout/action.yaml b/.github/actions/checkout/action.yaml index b73eb64a..a20d4123 100644 --- a/.github/actions/checkout/action.yaml +++ b/.github/actions/checkout/action.yaml @@ -51,4 +51,3 @@ runs: git submodule update ${{ inputs.submodules == 'recursive' && '--recursive' || '' }} fi - diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index c929ff68..000c5c7c 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -99,8 +99,9 @@ jobs: runs-on: ${{ matrix.runner }} name: "runner-build | ${{ matrix.architecture }} " steps: + - name: Cloning Target Repo - uses: actions/checkout@v4 + uses: ./.github/actions/checkout with: repository: ${{ inputs.rock-repo }} path: ${{ env.ROCK_REPO_DIR }} @@ -149,7 +150,7 @@ jobs: fetch-depth: 1 - name: Cloning Target Repo - uses: actions/checkout@v4 + uses: ./.github/actions/checkout with: repository: ${{ inputs.rock-repo }} path: ${{ env.ROCK_REPO_DIR }} From 54befd26f3e7a9c0e59b8d8e99e9c2110a7ea434 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Thu, 10 Oct 2024 14:45:00 +0000 Subject: [PATCH 62/86] fix: clone self in runner-build --- .github/workflows/Build-Rock.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 000c5c7c..f91e9421 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -100,6 +100,13 @@ jobs: name: "runner-build | ${{ matrix.architecture }} " steps: + - name: Cloning OCI Factory + uses: actions/checkout@v4 + with: + repository: canonical/oci-factory + ref: ${{ steps.workflow-version.outputs.sha }} + fetch-depth: 1 + - name: Cloning Target Repo uses: ./.github/actions/checkout with: From 23eefcb7b01ddd94e1549599646e3b9ed41a03de Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Thu, 10 Oct 2024 14:45:49 +0000 Subject: [PATCH 63/86] fix: path in self checkout --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index f91e9421..44d4db83 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -104,7 +104,7 @@ jobs: uses: actions/checkout@v4 with: repository: canonical/oci-factory - ref: ${{ steps.workflow-version.outputs.sha }} + ref: ${{ needs.configure-build.outputs.oci-factory-ref }} fetch-depth: 1 - name: Cloning Target Repo From 068107aa825c04b254d6b77c5bc5fd73a316707d Mon Sep 17 00:00:00 2001 From: clay-lake Date: Thu, 10 Oct 2024 14:57:29 +0000 Subject: [PATCH 64/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11276461819 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 97c2c74b..5977cfde 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "602" + "target": "604" }, "beta": { - "target": "602" + "target": "604" }, "edge": { - "target": "602" + "target": "604" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "602" + "target": "604" }, "beta": { - "target": "602" + "target": "604" }, "edge": { - "target": "602" + "target": "604" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "603" + "target": "605" }, "edge": { "target": "1.2-22.04_beta" From 69c255be8db6dc052a3e199d8c9e8a96d1ecf105 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Fri, 11 Oct 2024 07:58:31 +0000 Subject: [PATCH 65/86] fix: add rock identifier to each step in build. --- .github/workflows/Build-Rock.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 44d4db83..946a7db2 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -46,6 +46,7 @@ jobs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} oci-factory-ref: ${{ steps.workflow-version.outputs.sha }} + name: "configure-build | ${{ inputs.oci-archive-name }}" steps: - name: Get Workflow Version @@ -97,7 +98,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.runner-build-matrix) }} runs-on: ${{ matrix.runner }} - name: "runner-build | ${{ matrix.architecture }} " + name: "runner-build | ${{ inputs.oci-archive-name }} | | ${{ matrix.architecture }} " steps: - name: Cloning OCI Factory @@ -146,7 +147,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.lpci-build-matrix) }} runs-on: ubuntu-22.04 - name: "lpci-build | ${{ matrix.architecture }} " + name: "lpci-build | ${{ inputs.oci-archive-name }} | ${{ matrix.architecture }} " steps: - name: Cloning OCI Factory @@ -197,6 +198,7 @@ jobs: # Always run even if one of the *-build jobs are skipped # Nice example from benjamin-bergia/github-workflow-patterns... if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }} + name: "assemble-rock | ${{ inputs.oci-archive-name }}" steps: # Job Setup - uses: actions/checkout@v4 From 0ef45126571effbaefe0ab93b10edf70bc2f7edb Mon Sep 17 00:00:00 2001 From: clay-lake Date: Fri, 11 Oct 2024 08:10:36 +0000 Subject: [PATCH 66/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11288569131 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 5977cfde..515c98ba 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "604" + "target": "606" }, "beta": { - "target": "604" + "target": "606" }, "edge": { - "target": "604" + "target": "606" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "604" + "target": "606" }, "beta": { - "target": "604" + "target": "606" }, "edge": { - "target": "604" + "target": "606" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "605" + "target": "607" }, "edge": { "target": "1.2-22.04_beta" From b5af3fd258e6aa87e81a99d5ef0b7550de5337da Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Fri, 11 Oct 2024 08:15:43 +0000 Subject: [PATCH 67/86] feat: added optional build identifier --- .github/workflows/Build-Rock.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 946a7db2..0091b868 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -8,6 +8,10 @@ on: description: "Final filename of the rock OCI archive." type: string required: true + build-id-override: + description: "Optional identifier for managing job in GitHub UI. Defaults to oci-archive-name." + type: string + default: "" # source parameters rock-repo: @@ -36,6 +40,7 @@ on: env: ROCK_REPO_DIR: rock-repo # path where the image repo is cloned into ROCK_CI_FOLDER: ci-rocks # path of uploaded/downloaded artifacts + BUILD_ID: ${{ inputs.build-id-override || inputs.oci-archive-name }} jobs: configure-build: @@ -46,7 +51,7 @@ jobs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} oci-factory-ref: ${{ steps.workflow-version.outputs.sha }} - name: "configure-build | ${{ inputs.oci-archive-name }}" + name: "configure-build | ${{ env.BUILD_ID }}" steps: - name: Get Workflow Version @@ -98,7 +103,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.runner-build-matrix) }} runs-on: ${{ matrix.runner }} - name: "runner-build | ${{ inputs.oci-archive-name }} | | ${{ matrix.architecture }} " + name: "runner-build - ${{ matrix.architecture }} | ${{ env.BUILD_ID }}" steps: - name: Cloning OCI Factory @@ -147,7 +152,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.lpci-build-matrix) }} runs-on: ubuntu-22.04 - name: "lpci-build | ${{ inputs.oci-archive-name }} | ${{ matrix.architecture }} " + name: "lpci-build - ${{ matrix.architecture }} | ${{ env.BUILD_ID }}" steps: - name: Cloning OCI Factory @@ -198,7 +203,7 @@ jobs: # Always run even if one of the *-build jobs are skipped # Nice example from benjamin-bergia/github-workflow-patterns... if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }} - name: "assemble-rock | ${{ inputs.oci-archive-name }}" + name: "assemble-rock | ${{ env.BUILD_ID }}" steps: # Job Setup - uses: actions/checkout@v4 From bc097266d4d19c58df9a5664b46e5b0b050dd9c7 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Fri, 11 Oct 2024 08:22:24 +0000 Subject: [PATCH 68/86] test build --- .github/workflows/Build-Rock.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 0091b868..d10d2aa3 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -8,10 +8,10 @@ on: description: "Final filename of the rock OCI archive." type: string required: true - build-id-override: + build-id: description: "Optional identifier for managing job in GitHub UI. Defaults to oci-archive-name." type: string - default: "" + default: "${{ inputs.oci-archive-name }}" # source parameters rock-repo: @@ -40,7 +40,6 @@ on: env: ROCK_REPO_DIR: rock-repo # path where the image repo is cloned into ROCK_CI_FOLDER: ci-rocks # path of uploaded/downloaded artifacts - BUILD_ID: ${{ inputs.build-id-override || inputs.oci-archive-name }} jobs: configure-build: @@ -51,7 +50,7 @@ jobs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} oci-factory-ref: ${{ steps.workflow-version.outputs.sha }} - name: "configure-build | ${{ env.BUILD_ID }}" + name: "configure-build | ${{ inputs.build-id || inputs.oci-archive-name }}" steps: - name: Get Workflow Version @@ -103,7 +102,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.runner-build-matrix) }} runs-on: ${{ matrix.runner }} - name: "runner-build - ${{ matrix.architecture }} | ${{ env.BUILD_ID }}" + name: "runner-build - ${{ matrix.architecture }} | ${{ inputs.build-id || inputs.oci-archive-name }}" steps: - name: Cloning OCI Factory @@ -203,7 +202,7 @@ jobs: # Always run even if one of the *-build jobs are skipped # Nice example from benjamin-bergia/github-workflow-patterns... if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }} - name: "assemble-rock | ${{ env.BUILD_ID }}" + name: "assemble-rock | ${{ inputs.build-id || inputs.oci-archive-name }}" steps: # Job Setup - uses: actions/checkout@v4 From 598dd9174fb854803c83bd58076d65a8c277f528 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Fri, 11 Oct 2024 08:24:59 +0000 Subject: [PATCH 69/86] test build --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index d10d2aa3..65692e2d 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -151,7 +151,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.lpci-build-matrix) }} runs-on: ubuntu-22.04 - name: "lpci-build - ${{ matrix.architecture }} | ${{ env.BUILD_ID }}" + name: "lpci-build - ${{ matrix.architecture }} | ${{ inputs.build-id || inputs.oci-archive-name }}" steps: - name: Cloning OCI Factory From 7f7e6052b797b4fb635004f087aa8a77645ad9e5 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Fri, 11 Oct 2024 08:26:07 +0000 Subject: [PATCH 70/86] test build --- .github/workflows/Build-Rock.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 65692e2d..321e5743 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -50,7 +50,7 @@ jobs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} oci-factory-ref: ${{ steps.workflow-version.outputs.sha }} - name: "configure-build | ${{ inputs.build-id || inputs.oci-archive-name }}" + name: "configure-build | ${{ inputs.build-id }}" steps: - name: Get Workflow Version @@ -102,7 +102,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.runner-build-matrix) }} runs-on: ${{ matrix.runner }} - name: "runner-build - ${{ matrix.architecture }} | ${{ inputs.build-id || inputs.oci-archive-name }}" + name: "runner-build - ${{ matrix.architecture }} | ${{ inputs.build-id }}" steps: - name: Cloning OCI Factory @@ -151,7 +151,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.lpci-build-matrix) }} runs-on: ubuntu-22.04 - name: "lpci-build - ${{ matrix.architecture }} | ${{ inputs.build-id || inputs.oci-archive-name }}" + name: "lpci-build - ${{ matrix.architecture }} | ${{ inputs.build-id }}" steps: - name: Cloning OCI Factory @@ -202,7 +202,7 @@ jobs: # Always run even if one of the *-build jobs are skipped # Nice example from benjamin-bergia/github-workflow-patterns... if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }} - name: "assemble-rock | ${{ inputs.build-id || inputs.oci-archive-name }}" + name: "assemble-rock | ${{ inputs.build-id }}" steps: # Job Setup - uses: actions/checkout@v4 From 5ead99ba30c3dad38f6add87f4994d46b557fe4a Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 14 Oct 2024 09:17:07 +0000 Subject: [PATCH 71/86] test: build with optional build id --- .github/workflows/Build-Rock.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 321e5743..832563de 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -9,7 +9,7 @@ on: type: string required: true build-id: - description: "Optional identifier for managing job in GitHub UI. Defaults to oci-archive-name." + description: "Optional identifier for managing job in GitHub UI" type: string default: "${{ inputs.oci-archive-name }}" @@ -50,7 +50,7 @@ jobs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} oci-factory-ref: ${{ steps.workflow-version.outputs.sha }} - name: "configure-build | ${{ inputs.build-id }}" + name: "configure-build ${{ inputs.build-id && '| ' + inputs.build-id || ' '}}" steps: - name: Get Workflow Version From 7be1b4c56b06b346865a09cfa945bddcddc65793 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 14 Oct 2024 09:19:54 +0000 Subject: [PATCH 72/86] test: same as last build, fixed syntax --- .github/workflows/Build-Rock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 832563de..0219d150 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -50,7 +50,7 @@ jobs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} oci-factory-ref: ${{ steps.workflow-version.outputs.sha }} - name: "configure-build ${{ inputs.build-id && '| ' + inputs.build-id || ' '}}" + name: "configure-build ${{ inputs.build-id && format('| {0}', inputs.build-id) || ' '}}" steps: - name: Get Workflow Version From 85a9f295788a3fdaffd84f1415400b212412a3c0 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 14 Oct 2024 09:24:15 +0000 Subject: [PATCH 73/86] test build --- .github/workflows/Build-Rock.yaml | 3 +-- .github/workflows/Image.yaml | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 0219d150..808cbcf6 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -11,7 +11,6 @@ on: build-id: description: "Optional identifier for managing job in GitHub UI" type: string - default: "${{ inputs.oci-archive-name }}" # source parameters rock-repo: @@ -50,7 +49,7 @@ jobs: runner-build-matrix: ${{ steps.configure.outputs.runner-build-matrix }} lpci-build-matrix: ${{ steps.configure.outputs.lpci-build-matrix }} oci-factory-ref: ${{ steps.workflow-version.outputs.sha }} - name: "configure-build ${{ inputs.build-id && format('| {0}', inputs.build-id) || ' '}}" + name: "configure-build ${{ inputs.build-id != '' && format('| {0}', inputs.build-id) || ' '}}" steps: - name: Get Workflow Version diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index 1ff883b2..0ba4c7c3 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -161,6 +161,7 @@ jobs: uses: ./.github/workflows/Build-Rock.yaml with: oci-archive-name: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} + build-id: ${{ matrix.name }} rock-repo: ${{ matrix.source }} rock-repo-commit: ${{ matrix.commit }} rockfile-directory: ${{ matrix.directory }} From d1ad5741033eaa02a2e2056009c0f42958b42487 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 14 Oct 2024 09:26:37 +0000 Subject: [PATCH 74/86] test build without build-id --- .github/workflows/Image.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index 0ba4c7c3..1ff883b2 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -161,7 +161,6 @@ jobs: uses: ./.github/workflows/Build-Rock.yaml with: oci-archive-name: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} - build-id: ${{ matrix.name }} rock-repo: ${{ matrix.source }} rock-repo-commit: ${{ matrix.commit }} rockfile-directory: ${{ matrix.directory }} From 5f29eb98124845bee2917fcedfe674aad970d8de Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 14 Oct 2024 09:33:29 +0000 Subject: [PATCH 75/86] test build --- .github/workflows/Build-Rock.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 808cbcf6..cf046f5d 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -101,7 +101,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.runner-build-matrix) }} runs-on: ${{ matrix.runner }} - name: "runner-build - ${{ matrix.architecture }} | ${{ inputs.build-id }}" + name: "runner-build - ${{ matrix.architecture }}" steps: - name: Cloning OCI Factory @@ -150,7 +150,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.lpci-build-matrix) }} runs-on: ubuntu-22.04 - name: "lpci-build - ${{ matrix.architecture }} | ${{ inputs.build-id }}" + name: "lpci-build - ${{ matrix.architecture }}}}" steps: - name: Cloning OCI Factory @@ -201,7 +201,7 @@ jobs: # Always run even if one of the *-build jobs are skipped # Nice example from benjamin-bergia/github-workflow-patterns... if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }} - name: "assemble-rock | ${{ inputs.build-id }}" + name: "assemble-rock" steps: # Job Setup - uses: actions/checkout@v4 From b0c0a073f039d29dd81f9df3fc754295cd3cd704 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Mon, 14 Oct 2024 09:57:44 +0000 Subject: [PATCH 76/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11324839553 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 515c98ba..e2b35ce6 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "606" + "target": "610" }, "beta": { - "target": "606" + "target": "610" }, "edge": { - "target": "606" + "target": "610" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "606" + "target": "610" }, "beta": { - "target": "606" + "target": "610" }, "edge": { - "target": "606" + "target": "610" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "607" + "target": "611" }, "edge": { "target": "1.2-22.04_beta" From d5d56759158809783a51964c487d4f1b05cb8991 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 14 Oct 2024 11:25:32 +0000 Subject: [PATCH 77/86] feat: build-id paramter for identifying worflow jobs --- .github/workflows/Build-Rock.yaml | 10 +++++----- .github/workflows/Image.yaml | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index cf046f5d..6d211cdc 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -9,7 +9,7 @@ on: type: string required: true build-id: - description: "Optional identifier for managing job in GitHub UI" + description: "Optional string for identifying workflow jobs in GitHub UI" type: string # source parameters @@ -26,7 +26,7 @@ on: type: string required: true - # optional parameters for multi-arch builds + # parameters for multi-arch builds arch-map: description: "JSON string mapping target architecture to runners." type: string @@ -101,7 +101,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.runner-build-matrix) }} runs-on: ${{ matrix.runner }} - name: "runner-build - ${{ matrix.architecture }}" + name: "runner-build | ${{ matrix.architecture }} ${{ inputs.build-id != '' && format('| {0}', inputs.build-id) || ' '}}" steps: - name: Cloning OCI Factory @@ -150,7 +150,7 @@ jobs: fail-fast: true matrix: ${{ fromJSON(needs.configure-build.outputs.lpci-build-matrix) }} runs-on: ubuntu-22.04 - name: "lpci-build - ${{ matrix.architecture }}}}" + name: "lpci-build | ${{ matrix.architecture }} ${{ inputs.build-id != '' && format('| {0}', inputs.build-id) || ' '}}" steps: - name: Cloning OCI Factory @@ -201,7 +201,7 @@ jobs: # Always run even if one of the *-build jobs are skipped # Nice example from benjamin-bergia/github-workflow-patterns... if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }} - name: "assemble-rock" + name: "assemble-rock ${{ inputs.build-id != '' && format('| {0}', inputs.build-id) || ' '}}" steps: # Job Setup - uses: actions/checkout@v4 diff --git a/.github/workflows/Image.yaml b/.github/workflows/Image.yaml index 1ff883b2..0ba4c7c3 100644 --- a/.github/workflows/Image.yaml +++ b/.github/workflows/Image.yaml @@ -161,6 +161,7 @@ jobs: uses: ./.github/workflows/Build-Rock.yaml with: oci-archive-name: ${{ matrix.name }}_${{ matrix.commit }}_${{ matrix.dir_identifier }} + build-id: ${{ matrix.name }} rock-repo: ${{ matrix.source }} rock-repo-commit: ${{ matrix.commit }} rockfile-directory: ${{ matrix.directory }} From a2978b2ee2031aad3482f2f312cb29614f1aa601 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Mon, 14 Oct 2024 12:22:21 +0000 Subject: [PATCH 78/86] refactor: reformatted python and applied yamllint fixes --- .github/actions/checkout/action.yaml | 1 - .github/workflows/Tests.yaml | 16 ++++++++-------- src/docs/schema/triggers.py | 1 + src/image/prepare_single_image_build_matrix.py | 7 ++++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/actions/checkout/action.yaml b/.github/actions/checkout/action.yaml index a20d4123..f2f0dcf1 100644 --- a/.github/actions/checkout/action.yaml +++ b/.github/actions/checkout/action.yaml @@ -50,4 +50,3 @@ runs: then git submodule update ${{ inputs.submodules == 'recursive' && '--recursive' || '' }} fi - diff --git a/.github/workflows/Tests.yaml b/.github/workflows/Tests.yaml index 15c205bd..09be6e99 100644 --- a/.github/workflows/Tests.yaml +++ b/.github/workflows/Tests.yaml @@ -69,14 +69,14 @@ jobs: access-check: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 - - name: Validate access to triggered image - uses: ./.github/actions/validate-actor - if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} - with: - admin-only: true - image-path: ${{ inputs.oci-image-path }} - github-token: ${{ secrets.ROCKSBOT_TOKEN }} + - uses: actions/checkout@v4 + - name: Validate access to triggered image + uses: ./.github/actions/validate-actor + if: ${{ github.repository == 'canonical/oci-factory' && !github.event.pull_request.head.repo.fork }} + with: + admin-only: true + image-path: ${{ inputs.oci-image-path }} + github-token: ${{ secrets.ROCKSBOT_TOKEN }} fetch-oci-image: runs-on: ubuntu-22.04 diff --git a/src/docs/schema/triggers.py b/src/docs/schema/triggers.py index d9de4900..7cae1b3f 100755 --- a/src/docs/schema/triggers.py +++ b/src/docs/schema/triggers.py @@ -2,6 +2,7 @@ this module is the pydantic version of the documentation.yaml schema. """ + from typing import Optional from pydantic import BaseModel, Extra, constr, conlist diff --git a/src/image/prepare_single_image_build_matrix.py b/src/image/prepare_single_image_build_matrix.py index f94dfa6a..09cecc66 100755 --- a/src/image/prepare_single_image_build_matrix.py +++ b/src/image/prepare_single_image_build_matrix.py @@ -106,9 +106,10 @@ def validate_image_trigger(data: dict) -> None: # set an output as a marker for later knowing if we need to release if "release" in builds[img_number]: - min_eol = datetime.strptime(min( - v["end-of-life"] for v in builds[img_number]["release"].values() - ), "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc) + min_eol = datetime.strptime( + min(v["end-of-life"] for v in builds[img_number]["release"].values()), + "%Y-%m-%dT%H:%M:%SZ", + ).replace(tzinfo=timezone.utc) if min_eol < datetime.now(timezone.utc): print("Track skipped because it reached its end of life") del builds[img_number] From b85c44de06e12e8e444f06e576063f213eae8321 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Mon, 14 Oct 2024 12:42:16 +0000 Subject: [PATCH 79/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11327593165 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index e2b35ce6..12b84ab5 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "610" + "target": "612" }, "beta": { - "target": "610" + "target": "612" }, "edge": { - "target": "610" + "target": "612" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "610" + "target": "612" }, "beta": { - "target": "610" + "target": "612" }, "edge": { - "target": "610" + "target": "612" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "611" + "target": "613" }, "edge": { "target": "1.2-22.04_beta" From 072878a40b509eb16da043234008a49f5cfe1e7a Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Tue, 15 Oct 2024 08:55:44 +0000 Subject: [PATCH 80/86] feat: add new non-EOL track for mock rock 1.0 --- oci/mock-rock/image.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oci/mock-rock/image.yaml b/oci/mock-rock/image.yaml index 75e22f84..e9689880 100644 --- a/oci/mock-rock/image.yaml +++ b/oci/mock-rock/image.yaml @@ -19,6 +19,12 @@ upload: - candidate - edge - beta + 1.0.1-22.04: + end-of-life: "2025-05-01T00:00:00Z" + risks: + - candidate + - edge + - beta - source: "canonical/rocks-toolbox" commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f directory: mock_rock/1.1 From 428f6d1525df3ee0db891cd5a1c6d9fc6f04d6fc Mon Sep 17 00:00:00 2001 From: clay-lake Date: Tue, 15 Oct 2024 09:14:32 +0000 Subject: [PATCH 81/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11342808747 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 12b84ab5..89cc05fa 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "612" + "target": "617" }, "beta": { - "target": "612" + "target": "617" }, "edge": { - "target": "612" + "target": "617" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "612" + "target": "617" }, "beta": { - "target": "612" + "target": "617" }, "edge": { - "target": "612" + "target": "617" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "613" + "target": "618" }, "edge": { "target": "1.2-22.04_beta" From 96614233d87481c5442cd4505194235c8d4fdc13 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Wed, 16 Oct 2024 12:01:26 +0000 Subject: [PATCH 82/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11365021701 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 89cc05fa..004dabff 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "617" + "target": "619" }, "beta": { - "target": "617" + "target": "619" }, "edge": { - "target": "617" + "target": "619" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "617" + "target": "619" }, "beta": { - "target": "617" + "target": "619" }, "edge": { - "target": "617" + "target": "619" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "618" + "target": "620" }, "edge": { "target": "1.2-22.04_beta" From 3eb2c735b69c7000394148bf9c8b1c339d522104 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 16 Oct 2024 12:06:05 +0000 Subject: [PATCH 83/86] Revert "feat: add new non-EOL track for mock rock 1.0" This reverts commit 072878a40b509eb16da043234008a49f5cfe1e7a. --- oci/mock-rock/image.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/oci/mock-rock/image.yaml b/oci/mock-rock/image.yaml index e9689880..75e22f84 100644 --- a/oci/mock-rock/image.yaml +++ b/oci/mock-rock/image.yaml @@ -19,12 +19,6 @@ upload: - candidate - edge - beta - 1.0.1-22.04: - end-of-life: "2025-05-01T00:00:00Z" - risks: - - candidate - - edge - - beta - source: "canonical/rocks-toolbox" commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f directory: mock_rock/1.1 From 18d5a161fffb56d0b36d4484cef29a21195d0042 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Wed, 16 Oct 2024 12:28:00 +0000 Subject: [PATCH 84/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11365421745 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 004dabff..5919d937 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "619" + "target": "621" }, "beta": { - "target": "619" + "target": "621" }, "edge": { - "target": "619" + "target": "621" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "619" + "target": "621" }, "beta": { - "target": "619" + "target": "621" }, "edge": { - "target": "619" + "target": "621" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "620" + "target": "622" }, "edge": { "target": "1.2-22.04_beta" From 8edab43d9636930d89832502e198573d75bfe3ad Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Wed, 16 Oct 2024 12:32:24 +0000 Subject: [PATCH 85/86] fix(/workspaces/oci-factory/.github/workflows/Build-Rock.yaml): missing "needs" item --- .github/workflows/Build-Rock.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build-Rock.yaml b/.github/workflows/Build-Rock.yaml index 6d211cdc..31dc1ef8 100644 --- a/.github/workflows/Build-Rock.yaml +++ b/.github/workflows/Build-Rock.yaml @@ -196,7 +196,7 @@ jobs: assemble-rock: # Assemble individual single-arch rocks into multi-arch rocks - needs: [runner-build, lpci-build] + needs: [runner-build, lpci-build, configure-build] runs-on: ubuntu-22.04 # Always run even if one of the *-build jobs are skipped # Nice example from benjamin-bergia/github-workflow-patterns... @@ -204,7 +204,8 @@ jobs: name: "assemble-rock ${{ inputs.build-id != '' && format('| {0}', inputs.build-id) || ' '}}" steps: # Job Setup - - uses: actions/checkout@v4 + - name: Cloning OCI Factory + uses: actions/checkout@v4 with: repository: canonical/oci-factory ref: ${{ needs.configure-build.outputs.oci-factory-ref }} From f3b2a5a43d1d4a2ac2a690e649050e11c51f1a10 Mon Sep 17 00:00:00 2001 From: clay-lake Date: Wed, 16 Oct 2024 12:43:45 +0000 Subject: [PATCH 86/86] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/11365706243 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 5919d937..ff3c7794 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "621" + "target": "623" }, "beta": { - "target": "621" + "target": "623" }, "edge": { - "target": "621" + "target": "623" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "621" + "target": "623" }, "beta": { - "target": "621" + "target": "623" }, "edge": { - "target": "621" + "target": "623" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "622" + "target": "624" }, "edge": { "target": "1.2-22.04_beta"