feat: add workspace checkout step to CI workflow for improved reliability
This commit is contained in:
+109
-6
@@ -19,6 +19,28 @@ jobs:
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Ensure workspace checkout
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ws="${GITHUB_WORKSPACE:-$PWD}"
|
||||
if [ -d "$ws/backend" ]; then
|
||||
echo "Workspace already prepared at $ws"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p "$ws"
|
||||
repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||
if [ -n "${GITHUB_TOKEN:-}" ]; then
|
||||
repo_url="$(echo "$repo_url" | sed "s#https://#https://oauth2:${GITHUB_TOKEN}@#")"
|
||||
fi
|
||||
|
||||
git clone --depth 1 "$repo_url" "$ws"
|
||||
if [ -n "${GITHUB_SHA:-}" ]; then
|
||||
git -C "$ws" fetch --depth 1 origin "$GITHUB_SHA" || true
|
||||
git -C "$ws" checkout -f "$GITHUB_SHA" || true
|
||||
fi
|
||||
|
||||
- name: Install dependencies (backend)
|
||||
working-directory: ./backend
|
||||
run: npm ci
|
||||
@@ -59,6 +81,28 @@ jobs:
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Ensure workspace checkout
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ws="${GITHUB_WORKSPACE:-$PWD}"
|
||||
if [ -d "$ws/backend" ]; then
|
||||
echo "Workspace already prepared at $ws"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p "$ws"
|
||||
repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||
if [ -n "${GITHUB_TOKEN:-}" ]; then
|
||||
repo_url="$(echo "$repo_url" | sed "s#https://#https://oauth2:${GITHUB_TOKEN}@#")"
|
||||
fi
|
||||
|
||||
git clone --depth 1 "$repo_url" "$ws"
|
||||
if [ -n "${GITHUB_SHA:-}" ]; then
|
||||
git -C "$ws" fetch --depth 1 origin "$GITHUB_SHA" || true
|
||||
git -C "$ws" checkout -f "$GITHUB_SHA" || true
|
||||
fi
|
||||
|
||||
- name: Install dependencies (backend)
|
||||
working-directory: ./backend
|
||||
run: npm ci
|
||||
@@ -79,6 +123,28 @@ jobs:
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Ensure workspace checkout
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ws="${GITHUB_WORKSPACE:-$PWD}"
|
||||
if [ -d "$ws/backend" ]; then
|
||||
echo "Workspace already prepared at $ws"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p "$ws"
|
||||
repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||
if [ -n "${GITHUB_TOKEN:-}" ]; then
|
||||
repo_url="$(echo "$repo_url" | sed "s#https://#https://oauth2:${GITHUB_TOKEN}@#")"
|
||||
fi
|
||||
|
||||
git clone --depth 1 "$repo_url" "$ws"
|
||||
if [ -n "${GITHUB_SHA:-}" ]; then
|
||||
git -C "$ws" fetch --depth 1 origin "$GITHUB_SHA" || true
|
||||
git -C "$ws" checkout -f "$GITHUB_SHA" || true
|
||||
fi
|
||||
|
||||
- name: Install dependencies (backend)
|
||||
working-directory: ./backend
|
||||
run: npm ci
|
||||
@@ -118,13 +184,47 @@ jobs:
|
||||
- name: Verify Flutter toolchain on runner
|
||||
run: flutter --version
|
||||
|
||||
- name: Ensure workspace checkout
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ws="${GITHUB_WORKSPACE:-$PWD}"
|
||||
mkdir -p "$ws"
|
||||
repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||
if [ -n "${GITHUB_TOKEN:-}" ]; then
|
||||
repo_url="$(echo "$repo_url" | sed "s#https://#https://oauth2:${GITHUB_TOKEN}@#")"
|
||||
fi
|
||||
|
||||
if [ ! -d "$ws/.git" ]; then
|
||||
git -C "$ws" init
|
||||
git -C "$ws" remote add origin "$repo_url"
|
||||
else
|
||||
git -C "$ws" remote set-url origin "$repo_url"
|
||||
fi
|
||||
|
||||
ref="${GITHUB_SHA:-${GITHUB_REF_NAME:-main}}"
|
||||
git -C "$ws" fetch --depth 1 origin "$ref"
|
||||
git -C "$ws" checkout -f FETCH_HEAD
|
||||
|
||||
if [ ! -d "$ws/flutter" ]; then
|
||||
echo "Flutter directory missing after checkout: $ws/flutter"
|
||||
ls -la "$ws"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Install dependencies (flutter)
|
||||
working-directory: ./flutter
|
||||
run: flutter pub get
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE:-$PWD}/flutter"
|
||||
flutter pub get
|
||||
|
||||
- name: Analyze Flutter code
|
||||
working-directory: ./flutter
|
||||
run: flutter analyze
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE:-$PWD}/flutter"
|
||||
flutter analyze
|
||||
|
||||
- name: Set Flutter test mode
|
||||
shell: bash
|
||||
@@ -136,5 +236,8 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Run Flutter tests
|
||||
working-directory: ./flutter
|
||||
run: ${{ env.FLUTTER_TEST_CMD }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE:-$PWD}/flutter"
|
||||
${FLUTTER_TEST_CMD}
|
||||
|
||||
Reference in New Issue
Block a user