Update CI workflow to use new Cargo Chef based approach using pre-built Rust backend images for test stage
Some checks failed
Podman Rootless Demo / test-backend (push) Failing after 37s
Some checks failed
Podman Rootless Demo / test-backend (push) Failing after 37s
This commit is contained in:
parent
b1fb4739ae
commit
23a8281f5f
1 changed files with 36 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ jobs:
|
|||
RUN_ID: ${{ github.run_id }}
|
||||
POSTGRES_IMG_DIGEST: ${{ secrets.POSTGRES_IMG_DIGEST }}
|
||||
RUST_IMG_DIGEST: ${{ secrets.RUST_IMG_DIGEST }}
|
||||
PREBUILT_BACKEND_TEST_IMAGE: ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}/sharenet-test-rust
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
|
@ -35,9 +36,41 @@ jobs:
|
|||
podman --remote version
|
||||
podman --remote run --rm alpine:3.20 echo "Hello from host rootless Podman!"
|
||||
|
||||
- name: Login to container registry with PAT
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" | podman --remote login \
|
||||
-u "${{ secrets.REGISTRY_USERNAME }}" \
|
||||
--password-stdin \
|
||||
"${{ secrets.REGISTRY_HOST }}"
|
||||
|
||||
- name: Create network
|
||||
run: podman --remote network create integ-${{ env.RUN_ID }}
|
||||
|
||||
- name: Check if dependencies changed
|
||||
id: check-deps
|
||||
run: |
|
||||
# Get hash of Cargo.toml and Cargo.lock
|
||||
DEPS_HASH=$(sha256sum Cargo.toml Cargo.lock | sha256sum | cut -d' ' -f1)
|
||||
echo "deps_hash=$DEPS_HASH" >> $GITHUB_OUTPUT
|
||||
|
||||
# Check if image exists with this hash tag
|
||||
if podman --remote manifest inspect "$PREBUILT_BACKEND_TEST_IMAGE:$DEPS_HASH" >/dev/null 2>&1; then
|
||||
echo "rebuild_needed=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "rebuild_needed=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Build optimized Rust test image (if needed)
|
||||
if: steps.check-deps.outputs.rebuild_needed == 'true'
|
||||
run: |
|
||||
podman --remote build \
|
||||
-f backend/Dockerfile.test-rust \
|
||||
-t "$PREBUILT_BACKEND_TEST_IMAGE:${{ steps.check-deps.outputs.deps_hash }}" \
|
||||
-t "$PREBUILT_BACKEND_TEST_IMAGE:latest"
|
||||
|
||||
podman --remote push "$PREBUILT_BACKEND_TEST_IMAGE:${{ steps.check-deps.outputs.deps_hash }}"
|
||||
podman --remote push "$PREBUILT_BACKEND_TEST_IMAGE:latest"
|
||||
|
||||
- name: Start PostgreSQL
|
||||
run: |
|
||||
podman --remote run -d \
|
||||
|
|
@ -63,7 +96,7 @@ jobs:
|
|||
-v /home/ci-service/.cache:/c \
|
||||
alpine:3.20 sh -lc 'mkdir -p /c/cargo'
|
||||
|
||||
- name: Run backend tests (tar-pipe, no bind mount of source)
|
||||
- name: Run backend tests with cached dependencies
|
||||
run: |
|
||||
set -euo pipefail
|
||||
set -o pipefail
|
||||
|
|
@ -73,11 +106,12 @@ jobs:
|
|||
-e CARGO_HOME=/cargo \
|
||||
-e DATABASE_URL=postgres://postgres:password@test-postgres-${{ env.RUN_ID }}:5432/sharenet_test \
|
||||
-v /home/ci-service/.cache/cargo:/cargo \
|
||||
"$RUST_IMG_DIGEST" \
|
||||
"$PREBUILT_BACKEND_TEST_IMAGE:${{ steps.check-deps.outputs.deps_hash }}" \
|
||||
sh -euxc '
|
||||
mkdir -p /workspace
|
||||
tar -x -C /workspace
|
||||
cd /workspace/backend
|
||||
cargo chef cook --release --recipe-path /app/recipe.json
|
||||
cargo test --lib -- --test-threads=1
|
||||
'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue