|
| 1 | +name: e2e-ubuntu |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + arch: |
| 6 | + type: string |
| 7 | + required: true |
| 8 | + output-arch: |
| 9 | + type: string |
| 10 | + required: true |
| 11 | + |
| 12 | +env: |
| 13 | + GO111MODULE: on |
| 14 | + GO_VERSION: '1.24.0' |
| 15 | + |
| 16 | +jobs: |
| 17 | + get-latest-tag: |
| 18 | + name: Get the latest release tag |
| 19 | + runs-on: ubuntu-latest |
| 20 | + timeout-minutes: 2 |
| 21 | + outputs: |
| 22 | + tag: ${{ steps.latest-tag.outputs.tag }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + - name: 'Get the latest tag' |
| 28 | + id: latest-tag |
| 29 | + uses: "WyriHaximus/github-action-get-previous-tag@04e8485ecb6487243907e330d522ff60f02283ce" # v1.4.0 |
| 30 | + |
| 31 | + get-tag-and-version: |
| 32 | + needs: get-latest-tag |
| 33 | + name: Get tag name |
| 34 | + runs-on: ubuntu-latest |
| 35 | + timeout-minutes: 2 |
| 36 | + outputs: |
| 37 | + tag: ${{ steps.check-tag.outputs.tag }} |
| 38 | + version: ${{ steps.check-tag.outputs.version }} |
| 39 | + steps: |
| 40 | + - name: Check tag from workflow input and github ref |
| 41 | + id: check-tag |
| 42 | + run: | |
| 43 | + if [ -n "${{ needs.get-latest-tag.outputs.tag }}" ]; then |
| 44 | + tag=${{ needs.get-latest-tag.outputs.tag }} |
| 45 | + else |
| 46 | + tag=${{ github.tag }} |
| 47 | + fi |
| 48 | + echo "tag=$tag" >> ${GITHUB_OUTPUT} |
| 49 | +
|
| 50 | + version=${tag#v} |
| 51 | + if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 52 | + echo "Version matches format: $version" |
| 53 | + else |
| 54 | + echo "Error: Version $version doesn't match format." |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + echo "version=$version" >> ${GITHUB_OUTPUT} |
| 58 | + |
| 59 | + e2e-test: |
| 60 | + needs: get-tag-and-version |
| 61 | + runs-on: codebuild-finch-${{ inputs.arch }}-2-instance-${{ github.run_id }}-${{ github.run_attempt }} |
| 62 | + timeout-minutes: 60 |
| 63 | + outputs: |
| 64 | + has_creds: ${{ steps.vars.outputs.has_creds}} |
| 65 | + vm_report: ${{ steps.set-multiple-vars.outputs.VM_REPORT }} |
| 66 | + container_report: ${{ steps.set-multiple-vars.outputs.CONTAINER_REPORT }} |
| 67 | + vm_serial_report: ${{ steps.set-multiple-vars.outputs.VM_SERIAL_REPORT }} |
| 68 | + steps: |
| 69 | + - name: Clean Ubuntu workspace |
| 70 | + run: | |
| 71 | + rm -rf ${{ github.workspace }}/* |
| 72 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 73 | + with: |
| 74 | + # We need to get all the git tags to make version injection work. See VERSION in Makefile for more detail. |
| 75 | + fetch-depth: 0 |
| 76 | + persist-credentials: false |
| 77 | + submodules: recursive |
| 78 | + - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 |
| 79 | + with: |
| 80 | + go-version: ${{ env.GO_VERSION }} |
| 81 | + cache: false |
| 82 | + - name: Set output variables |
| 83 | + id: vars |
| 84 | + run: | |
| 85 | + has_creds=${{ (github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name) && github.actor != 'dependabot[bot]' }} |
| 86 | + echo "has_creds=$has_creds" >> $GITHUB_OUTPUT |
| 87 | + - name: Install dependencies |
| 88 | + run: | |
| 89 | + sudo apt install build-essential -y |
| 90 | + sudo apt install libseccomp-dev -y |
| 91 | + sudo apt install pkg-config -y |
| 92 | + sudo apt install zlib1g-dev -y |
| 93 | + - name: Build for Ubuntu ${{ inputs.output-arch }} |
| 94 | + run: | |
| 95 | + make |
| 96 | + - name: Generate deb |
| 97 | + run: | |
| 98 | + ./contrib/packaging/deb/package.sh --${{ inputs.output-arch }} --version ${{ needs.get-tag-and-version.outputs.version }} |
| 99 | + - name: Install Finch |
| 100 | + run: | |
| 101 | + sudo apt install ./_output/deb/runfinch-finch_${{ needs.get-tag-and-version.outputs.version }}_${{ inputs.output-arch }}.deb -y |
| 102 | + sudo systemctl daemon-reload |
| 103 | + sudo systemctl start containerd.service |
| 104 | + sudo systemctl restart finch.socket |
| 105 | + sudo systemctl start finch.service |
| 106 | + sudo systemctl start finch-buildkit.service |
| 107 | + sudo systemctl start finch-soci.service |
| 108 | + - name: Set up REPORT_DIR |
| 109 | + run: | |
| 110 | + echo "REPORT_DIR=${{ github.workspace }}/reports" >> $GITHUB_ENV |
| 111 | + - name: Run e2e tests |
| 112 | + run: | |
| 113 | + git status |
| 114 | + git clean -f -d |
| 115 | + eval $(ssh-agent) |
| 116 | + sudo -E env "PATH=$PATH" INSTALLED=true make test-e2e-container |
| 117 | + sudo -E env "PATH=$PATH" INSTALLED=true make test-e2e-vm |
| 118 | + - name: Change ownership of reports |
| 119 | + if: always() |
| 120 | + run: | |
| 121 | + if [ ! -d "$REPORT_DIR" ]; then |
| 122 | + echo "Error: Directory $REPORT_DIR does not exist." |
| 123 | + exit 1 |
| 124 | + fi |
| 125 | +
|
| 126 | + USER=$(whoami) |
| 127 | + GROUP=$(id -gn) |
| 128 | +
|
| 129 | + if sudo chown -R "$USER:$GROUP" "$REPORT_DIR"; then |
| 130 | + echo "Ownership of $REPORT_DIR changed to $USER:$GROUP" |
| 131 | + else |
| 132 | + echo "Error: Failed to change ownership of $REPORT_DIR" |
| 133 | + exit 1 |
| 134 | + fi |
| 135 | + - name: Set artifacts name outputs |
| 136 | + if: always() |
| 137 | + id: set-multiple-vars |
| 138 | + run: | |
| 139 | + echo "VM_REPORT=${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json" >> $GITHUB_OUTPUT |
| 140 | + echo "CONTAINER_REPORT=${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json" >> $GITHUB_OUTPUT |
| 141 | + echo "VM_SERIAL_REPORT=${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-serial-report.json" >> $GITHUB_OUTPUT |
| 142 | + - name: Upload reports artifact |
| 143 | + if: always() |
| 144 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 145 | + with: |
| 146 | + name: ubuntu-test-e2e-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports |
| 147 | + path: ${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-*.json |
| 148 | + - name: Clean Up Previous Environment |
| 149 | + if: always() |
| 150 | + timeout-minutes: 2 |
| 151 | + run: | |
| 152 | + sudo apt remove runfinch-finch -y |
| 153 | + sudo apt remove build-essential -y |
| 154 | + sudo apt remove libseccomp-dev -y |
| 155 | + sudo apt remove pkg-config -y |
| 156 | + sudo apt remove zlib1g-dev -y |
0 commit comments