|
| 1 | +name: e2e-ubuntu-finch-daemon |
| 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.6' |
| 15 | + |
| 16 | +permissions: |
| 17 | + id-token: write # used when getting AWS credentials |
| 18 | + contents: read |
| 19 | + |
| 20 | +jobs: |
| 21 | + get-latest-tag: |
| 22 | + name: Get the latest release tag |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + timeout-minutes: 2 |
| 27 | + outputs: |
| 28 | + tag: ${{ steps.latest-tag.outputs.tag }} |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + - name: 'Get the latest tag' |
| 34 | + id: latest-tag |
| 35 | + uses: "WyriHaximus/github-action-get-previous-tag@04e8485ecb6487243907e330d522ff60f02283ce" # v1.4.0 |
| 36 | + |
| 37 | + get-tag-and-version: |
| 38 | + needs: get-latest-tag |
| 39 | + name: Get tag name |
| 40 | + runs-on: ubuntu-latest |
| 41 | + permissions: |
| 42 | + contents: read |
| 43 | + timeout-minutes: 2 |
| 44 | + outputs: |
| 45 | + tag: ${{ steps.check-tag.outputs.tag }} |
| 46 | + version: ${{ steps.check-tag.outputs.version }} |
| 47 | + steps: |
| 48 | + - name: Check tag from workflow input and github ref |
| 49 | + id: check-tag |
| 50 | + run: | |
| 51 | + if [ -n "${{ needs.get-latest-tag.outputs.tag }}" ]; then |
| 52 | + tag=${{ needs.get-latest-tag.outputs.tag }} |
| 53 | + else |
| 54 | + tag=${{ github.tag }} |
| 55 | + fi |
| 56 | + echo "tag=$tag" >> ${GITHUB_OUTPUT} |
| 57 | +
|
| 58 | + version=${tag#v} |
| 59 | + if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 60 | + echo "Version matches format: $version" |
| 61 | + else |
| 62 | + echo "Error: Version $version doesn't match format." |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | + echo "version=$version" >> ${GITHUB_OUTPUT} |
| 66 | + |
| 67 | + e2e-test-finch-daemon: |
| 68 | + needs: get-tag-and-version |
| 69 | + runs-on: codebuild-finch-${{ inputs.arch }}-1-instance-${{ github.run_id }}-${{ github.run_attempt }} |
| 70 | + permissions: |
| 71 | + id-token: write # used when getting AWS credentials |
| 72 | + contents: read |
| 73 | + timeout-minutes: 60 |
| 74 | + outputs: |
| 75 | + has_creds: ${{ steps.vars.outputs.has_creds}} |
| 76 | + daemon_report: ${{ steps.set-multiple-vars.outputs.DAEMON_REPORT }} |
| 77 | + steps: |
| 78 | + - name: Clean Ubuntu workspace |
| 79 | + run: | |
| 80 | + rm -rf ${{ github.workspace }}/* |
| 81 | + - name: Clean existing Finch environment |
| 82 | + run: | |
| 83 | + # Stop services |
| 84 | + sudo systemctl stop finch.service || true |
| 85 | + sudo systemctl stop finch.socket || true |
| 86 | + sudo systemctl stop finch-buildkit.service || true |
| 87 | + sudo systemctl stop finch-soci.service || true |
| 88 | + sudo systemctl stop containerd.service || true |
| 89 | +
|
| 90 | + # Disable services to prevent auto-start |
| 91 | + sudo systemctl disable --now finch.service || true |
| 92 | + sudo systemctl disable --now finch.socket || true |
| 93 | + sudo systemctl disable --now finch-buildkit.service || true |
| 94 | + sudo systemctl disable --now finch-soci.service || true |
| 95 | +
|
| 96 | + # Remove all containerd finch mounts |
| 97 | + sudo umount -f $(sudo mount | grep "/run/containerd/io.containerd.runtime.v2.task/finch/" | awk '{print $3}') || true |
| 98 | +
|
| 99 | + # Remove existing finch packages |
| 100 | + sudo apt remove --purge runfinch-finch -y || true |
| 101 | + |
| 102 | + # Clean up any leftover finch directories and files |
| 103 | + sudo rm -rf /opt/finch || true |
| 104 | + sudo rm -rf /usr/local/bin/finch || true |
| 105 | + sudo rm -rf /etc/systemd/system/finch* || true |
| 106 | + sudo rm -rf /var/lib/finch || true |
| 107 | + sudo rm -rf ~/.finch || true |
| 108 | + sudo rm -rf /run/containerd || true |
| 109 | + sudo rm -rf /var/lib/containerd || true |
| 110 | + sudo rm -rf /var/lib/buildkit/ || true |
| 111 | + sudo rm -rf /var/lib/soci-snapshotter-grpc/ || true |
| 112 | + sudo rm -rf /var/lib/nerdctl || true |
| 113 | +
|
| 114 | + # Clean up root cache |
| 115 | + sudo rm -rf /root/.cache || true |
| 116 | +
|
| 117 | + # Reload systemd after cleanup |
| 118 | + sudo systemctl daemon-reload |
| 119 | + - name: Check available disk space |
| 120 | + run: | |
| 121 | + sudo df -h |
| 122 | + sudo df -h /tmp |
| 123 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 124 | + with: |
| 125 | + # We need to get all the git tags to make version injection work. See VERSION in Makefile for more detail. |
| 126 | + fetch-depth: 0 |
| 127 | + persist-credentials: false |
| 128 | + submodules: recursive |
| 129 | + - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 |
| 130 | + with: |
| 131 | + go-version: ${{ env.GO_VERSION }} |
| 132 | + cache: false |
| 133 | + - name: Set output variables |
| 134 | + id: vars |
| 135 | + run: | |
| 136 | + has_creds=${{ (github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name) && github.actor != 'dependabot[bot]' }} |
| 137 | + echo "has_creds=$has_creds" >> $GITHUB_OUTPUT |
| 138 | + - name: Clean iptable rules |
| 139 | + run: | |
| 140 | + sudo chmod +x ./scripts/clean-iptables.sh |
| 141 | + sudo ./scripts/clean-iptables.sh |
| 142 | + - name: Install dependencies |
| 143 | + run: | |
| 144 | + sudo apt install build-essential -y |
| 145 | + sudo apt install libseccomp-dev -y |
| 146 | + sudo apt install pkg-config -y |
| 147 | + sudo apt install zlib1g-dev -y |
| 148 | + sudo apt install iptables -y |
| 149 | + - name: Build for Ubuntu ${{ inputs.output-arch }} |
| 150 | + run: | |
| 151 | + make |
| 152 | + - name: Generate deb |
| 153 | + run: | |
| 154 | + ./contrib/packaging/deb/package.sh --${{ inputs.output-arch }} --version ${{ needs.get-tag-and-version.outputs.version }} |
| 155 | + |
| 156 | + - name: Install Finch |
| 157 | + run: | |
| 158 | + sudo apt install ./_output/deb/runfinch-finch_${{ needs.get-tag-and-version.outputs.version }}_${{ inputs.output-arch }}.deb -y |
| 159 | + sudo systemctl daemon-reload |
| 160 | + sudo systemctl restart containerd.service |
| 161 | + sudo systemctl restart finch.socket |
| 162 | + sudo systemctl restart finch.service |
| 163 | + sudo systemctl restart finch-buildkit.service |
| 164 | + sudo systemctl restart finch-soci.service |
| 165 | +
|
| 166 | + - name: Set up REPORT_DIR |
| 167 | + run: | |
| 168 | + echo "REPORT_DIR=${{ github.workspace }}/reports" >> $GITHUB_ENV |
| 169 | + - name: Run e2e finch daemon tests |
| 170 | + run: | |
| 171 | + sudo -E env "PATH=/usr/libexec/finch:/usr/libexec/finch/cni/bin/:/usr/local/bin:$PATH" NERDCTL_TOML=/etc/finch/nerdctl/nerdctl.toml BUILDKIT_HOST=unix:///var/lib/finch/buildkit/buildkitd.sock make test-e2e-daemon-linux |
| 172 | + - name: Change ownership of reports |
| 173 | + if: always() |
| 174 | + run: | |
| 175 | + if [ ! -d "$REPORT_DIR" ]; then |
| 176 | + echo "Error: Directory $REPORT_DIR does not exist." |
| 177 | + exit 1 |
| 178 | + fi |
| 179 | +
|
| 180 | + USER=$(whoami) |
| 181 | + GROUP=$(id -gn) |
| 182 | +
|
| 183 | + if sudo chown -R "$USER:$GROUP" "$REPORT_DIR"; then |
| 184 | + echo "Ownership of $REPORT_DIR changed to $USER:$GROUP" |
| 185 | + else |
| 186 | + echo "Error: Failed to change ownership of $REPORT_DIR" |
| 187 | + exit 1 |
| 188 | + fi |
| 189 | + - name: Set artifacts name outputs |
| 190 | + if: always() |
| 191 | + id: set-multiple-vars |
| 192 | + run: | |
| 193 | + echo "DAEMON_REPORT=${{ github.run_id }}-${{ github.run_attempt }}-e2e-daemon-report.json" >> $GITHUB_OUTPUT |
| 194 | + - name: Upload reports artifact |
| 195 | + if: always() |
| 196 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 197 | + with: |
| 198 | + name: ubuntu-test-e2e-finch-daemon-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports |
| 199 | + path: ${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-*.json |
| 200 | + - name: Clean Up Previous Environment |
| 201 | + if: always() |
| 202 | + timeout-minutes: 2 |
| 203 | + run: | |
| 204 | + sudo apt remove runfinch-finch -y |
| 205 | + sudo apt remove build-essential -y |
| 206 | + sudo apt remove libseccomp-dev -y |
| 207 | + sudo apt remove pkg-config -y |
| 208 | + sudo apt remove zlib1g-dev -y |
0 commit comments