|
| 1 | +name: e2e Testing Image Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + # There should be no need to pass in anything as we should have all we need |
| 7 | + # based on the github context |
| 8 | + repo: |
| 9 | + description: | |
| 10 | + This is the repo to simulate the testing from. |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + ref: |
| 14 | + description: | |
| 15 | + The ref that should be tested from. Could be a branch or PR. that should be used to pull all konveyor related repos. |
| 16 | + For example, if you wanted to set a nightly build for release-0.8, you would specify |
| 17 | + "release-0.8". |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + tag: |
| 21 | + description: | |
| 22 | + The tag to use for the images |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + workflow_dispatch: |
| 26 | + inputs: |
| 27 | + repo: |
| 28 | + description: | |
| 29 | + This is the repo to simulate the testing from. |
| 30 | + required: false |
| 31 | + type: string |
| 32 | + ref: |
| 33 | + description: | |
| 34 | + The ref that should be tested from. Could be a branch or PR. that should be used to pull all konveyor related repos. |
| 35 | + For example, if you wanted to set a nightly build for release-0.8, you would specify |
| 36 | + "release-0.8". |
| 37 | + required: false |
| 38 | + type: string |
| 39 | + tag: |
| 40 | + description: | |
| 41 | + The tag to use for the images |
| 42 | + required: false |
| 43 | + type: string |
| 44 | + |
| 45 | +jobs: |
| 46 | + prepare-matrix: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + outputs: |
| 49 | + matrix_0: ${{ steps.prepare.outputs.matrix_0 }} |
| 50 | + matrix_1: ${{ steps.prepare.outputs.matrix_1 }} |
| 51 | + matrix_2: ${{ steps.prepare.outputs.matrix_2 }} |
| 52 | + matrix_3: ${{ steps.prepare.outputs.matrix_3 }} |
| 53 | + steps: |
| 54 | + ## For now, just using main, but in the future we probably want this to |
| 55 | + # use the same ref that the workflow is being called at. I don't know |
| 56 | + # how to get that information right now |
| 57 | + - name: Checkout ci repo |
| 58 | + uses: actions/checkout@v5 |
| 59 | + with: |
| 60 | + repository: konveyor/ci |
| 61 | + ref: 'main' |
| 62 | + |
| 63 | + - name: Setup Python |
| 64 | + uses: actions/setup-python@v6 |
| 65 | + with: |
| 66 | + python-version: '3.12' |
| 67 | + |
| 68 | + - name: Prepare matrix configs |
| 69 | + id: prepare |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + |
| 73 | + pip install -r scripts/requirements.txt |
| 74 | + python scripts/parse_matrix_config.py .github/workflows/nightly-matrix-config.yaml -t ${{ inputs.tag || github.run_id }} -b ${{ github.base_ref || github.ref_name }} -r ${{ inputs.repo || github.repository }} out |
| 75 | +
|
| 76 | + # The output may be one ore more of these, we should handle the case where these are empty. |
| 77 | + matrix_0=$(cat out/level_0.json) |
| 78 | + matrix_1=$(cat out/level_1.json) |
| 79 | + matrix_2=$(cat out/level_2.json) |
| 80 | + matrix_3=$(cat out/level_3.json) |
| 81 | + |
| 82 | + { |
| 83 | + echo "matrix_0<<EOF" |
| 84 | + echo "$matrix_0" |
| 85 | + echo "EOF" |
| 86 | + } >> $GITHUB_OUTPUT |
| 87 | + { |
| 88 | + echo "matrix_1<<EOF" |
| 89 | + echo "$matrix_1" |
| 90 | + echo "EOF" |
| 91 | + } >> $GITHUB_OUTPUT |
| 92 | + { |
| 93 | + echo "matrix_2<<EOF" |
| 94 | + echo "$matrix_2" |
| 95 | + echo "EOF" |
| 96 | + } >> $GITHUB_OUTPUT |
| 97 | + { |
| 98 | + echo "matrix_3<<EOF" |
| 99 | + echo "$matrix_3" |
| 100 | + echo "EOF" |
| 101 | + } >> $GITHUB_OUTPUT |
| 102 | + |
| 103 | + build-images: |
| 104 | + name: "Build level 0 images" |
| 105 | + if: ${{ fromJSON(needs.prepare-matrix.outputs.matrix_0).image[0] != null }} |
| 106 | + needs: prepare-matrix |
| 107 | + uses: ./.github/workflows/build-nightly-images.yaml |
| 108 | + with: |
| 109 | + matrix-config: ${{ needs.prepare-matrix.outputs.matrix_0 }} |
| 110 | + branch: ${{ inputs.ref || github.ref }} |
| 111 | + tag: ${{ inputs.tag || github.run_id }} |
| 112 | + tested_repo: ${{ inputs.repo || github.repository }} |
| 113 | + |
| 114 | + build-level1-images: |
| 115 | + name: "Build level 1 images" |
| 116 | + if: ${{ !failure() && fromJSON(needs.prepare-matrix.outputs.matrix_1).image[0] != null }} |
| 117 | + needs: |
| 118 | + - prepare-matrix |
| 119 | + - build-images |
| 120 | + uses: ./.github/workflows/build-nightly-images.yaml |
| 121 | + with: |
| 122 | + matrix-config: ${{ needs.prepare-matrix.outputs.matrix_1 }} |
| 123 | + branch: ${{ inputs.ref || github.ref }} |
| 124 | + tag: ${{ inputs.tag || github.run_id }} |
| 125 | + tested_repo: ${{ inputs.repo || github.repository }} |
| 126 | + |
| 127 | + build-level2-images: |
| 128 | + name: "Build level 2 images" |
| 129 | + if: ${{ !failure() && fromJSON(needs.prepare-matrix.outputs.matrix_2).image[0] != null }} |
| 130 | + needs: |
| 131 | + - prepare-matrix |
| 132 | + - build-level1-images |
| 133 | + uses: ./.github/workflows/build-nightly-images.yaml |
| 134 | + with: |
| 135 | + matrix-config: ${{ needs.prepare-matrix.outputs.matrix_2 }} |
| 136 | + branch: ${{ inputs.ref || github.ref }} |
| 137 | + tag: ${{ inputs.tag || github.run_id }} |
| 138 | + tested_repo: ${{ inputs.repo || github.repository }} |
| 139 | + |
| 140 | + build-level3-images: |
| 141 | + name: "Build level 3 images" |
| 142 | + if: ${{ !failure() && fromJSON(needs.prepare-matrix.outputs.matrix_3).image[0] != null }} |
| 143 | + needs: |
| 144 | + - prepare-matrix |
| 145 | + - build-level2-images |
| 146 | + uses: ./.github/workflows/build-nightly-images.yaml |
| 147 | + with: |
| 148 | + matrix-config: ${{ needs.prepare-matrix.outputs.matrix_3 }} |
| 149 | + branch: ${{ inputs.ref || github.ref }} |
| 150 | + tag: ${{ inputs.tag || github.run_id }} |
| 151 | + tested_repo: ${{ inputs.repo || github.repository }} |
| 152 | + |
0 commit comments