|
| 1 | +name: "E2E sandbox prepare" |
| 2 | +description: >- |
| 3 | + Compute the sandbox id, copy the workspace into /tmp, and provision the Talos |
| 4 | + e2e sandbox (make prepare-env with the sanctioned 3x infra retry — the one |
| 5 | + retry justified by docs/agents/e2e-testing.md #1). Shared by the e2e and |
| 6 | + upgrade-e2e jobs so the sandbox bring-up lives in exactly one place. |
| 7 | +
|
| 8 | +inputs: |
| 9 | + sandbox-suffix: |
| 10 | + description: >- |
| 11 | + Appended to the sandbox id so jobs that run in parallel on the same |
| 12 | + workflow/ref (e2e vs upgrade-e2e) get distinct sandbox names. Empty |
| 13 | + reproduces the original single-job id byte-for-byte. |
| 14 | + required: false |
| 15 | + default: "" |
| 16 | + |
| 17 | +outputs: |
| 18 | + sandbox-name: |
| 19 | + description: "The computed sandbox container name (also exported as SANDBOX_NAME)." |
| 20 | + value: ${{ steps.set.outputs.sandbox-name }} |
| 21 | + |
| 22 | +runs: |
| 23 | + using: composite |
| 24 | + steps: |
| 25 | + - name: Set sandbox ID |
| 26 | + id: set |
| 27 | + shell: bash |
| 28 | + run: | |
| 29 | + key="${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" |
| 30 | + # Only extend the hash key when a suffix is given, so the default |
| 31 | + # (e2e) sandbox name is identical to the pre-composite behaviour. |
| 32 | + [ -n "${{ inputs.sandbox-suffix }}" ] && key="${key}:${{ inputs.sandbox-suffix }}" |
| 33 | + name="cozy-e2e-sandbox-$(echo "$key" | sha256sum | cut -c1-10)" |
| 34 | + echo "SANDBOX_NAME=$name" >> "$GITHUB_ENV" |
| 35 | + echo "sandbox-name=$name" >> "$GITHUB_OUTPUT" |
| 36 | +
|
| 37 | + - name: Prepare workspace |
| 38 | + shell: bash |
| 39 | + run: | |
| 40 | + rm -rf "/tmp/$SANDBOX_NAME" |
| 41 | + cp -r "${{ github.workspace }}" "/tmp/$SANDBOX_NAME" |
| 42 | +
|
| 43 | + - name: Prepare environment |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + cd "/tmp/$SANDBOX_NAME" |
| 47 | + attempt=0 |
| 48 | + until make SANDBOX_NAME=$SANDBOX_NAME prepare-env; do |
| 49 | + attempt=$((attempt + 1)) |
| 50 | + if [ $attempt -ge 3 ]; then |
| 51 | + echo "Attempt $attempt failed, exiting..." |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | + echo "Attempt $attempt failed, retrying..." |
| 55 | + done |
| 56 | + echo "Prepare environment completed after $((attempt + 1)) attempts" |
0 commit comments