Skip to content

@W-21340586 Add lock file for CI consistency #2

@W-21340586 Add lock file for CI consistency

@W-21340586 Add lock file for CI consistency #2

Workflow file for this run

name: PR Validation
# Trigger on pull requests to dev and pushes to dev (for verification)
on:
pull_request:
branches: [ dev ]
push:
branches: [ dev ]
# Cancel in-progress runs for the same PR/branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Job 1: Fast checks (lint, format, typecheck)
lint-and-typecheck:
name: Lint & Type Check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci --legacy-peer-deps --ignore-scripts
- name: Run ESLint
run: npm run lint
- name: Check formatting
run: npm run format
- name: Run TypeScript type check
run: npm run typecheck
# Job 2: Unit tests
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
needs: lint-and-typecheck # Only run if lint passes
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci --legacy-peer-deps --ignore-scripts
- name: Run tests
run: npm test -- --coverage --maxWorkers=2
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: always()
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
# Job 3: Build validation matrix (parallel builds)
build-validation:
name: Build ${{ matrix.platform }} - ${{ matrix.variant }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
needs: unit-tests # Only run if tests pass
strategy:
fail-fast: false # Don't cancel other builds if one fails
matrix:
include:
# Android builds (Linux runner)
- platform: Android
variant: Service Agent
os: ubuntu-latest
setup-script: node installandroid.js service
build-script: npm run build:android:service
cache-paths: |
~/.gradle/caches
~/.gradle/wrapper
android/.gradle
cache-key: gradle
- platform: Android
variant: Employee Agent
os: ubuntu-latest
setup-script: node installandroid.js employee
build-script: npm run build:android:employee
cache-paths: |
~/.gradle/caches
~/.gradle/wrapper
android/.gradle
cache-key: gradle
# iOS builds (macOS runner)
- platform: iOS
variant: Service Agent
os: macos-14
setup-script: node installios.js service
build-script: npm run build:ios:service
cache-paths: ios/Pods
cache-key: pods
- platform: iOS
variant: Employee Agent
os: macos-14
setup-script: node installios.js employee
build-script: npm run build:ios:employee
cache-paths: ios/Pods
cache-key: pods
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
# Java setup for Android builds
- name: Setup Java (Android only)
if: matrix.platform == 'Android'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
# Ruby setup for iOS builds (CocoaPods)
- name: Setup Ruby (iOS only)
if: matrix.platform == 'iOS'
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: false
# Install CocoaPods for iOS
- name: Install CocoaPods (iOS only)
if: matrix.platform == 'iOS'
run: |
gem install cocoapods -v 1.15.2
pod --version
# Install XcodeGen for iOS
- name: Install XcodeGen (iOS only)
if: matrix.platform == 'iOS'
run: |
brew install xcodegen
xcodegen --version
# Cache Gradle for Android
- name: Cache Gradle dependencies (Android only)
if: matrix.platform == 'Android'
uses: actions/cache@v4
with:
path: ${{ matrix.cache-paths }}
key: ${{ runner.os }}-${{ matrix.cache-key }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-${{ matrix.cache-key }}-
# Cache CocoaPods for iOS
- name: Cache CocoaPods (iOS only)
if: matrix.platform == 'iOS'
uses: actions/cache@v4
with:
path: ${{ matrix.cache-paths }}
key: ${{ runner.os }}-${{ matrix.cache-key }}-${{ hashFiles('ios/Podfile.*.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.cache-key }}-
- name: Install npm dependencies
run: npm ci --legacy-peer-deps --ignore-scripts
- name: Run platform setup
run: ${{ matrix.setup-script }}
- name: Build ${{ matrix.platform }} - ${{ matrix.variant }}
run: ${{ matrix.build-script }}
# Upload build logs on failure for debugging
- name: Upload build logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ matrix.platform }}-${{ matrix.variant }}
path: |
android/app/build/outputs/**/*.log
ios/build/Logs/**
retention-days: 7
if-no-files-found: ignore
# Summary job - all checks must pass
all-checks-passed:
name: All Checks Passed ✓
runs-on: ubuntu-latest
needs: [lint-and-typecheck, unit-tests, build-validation]
if: always()
steps:
- name: Check if all jobs succeeded
run: |
if [[ "${{ needs.lint-and-typecheck.result }}" != "success" ]] || \
[[ "${{ needs.unit-tests.result }}" != "success" ]] || \
[[ "${{ needs.build-validation.result }}" != "success" ]]; then
echo "❌ One or more checks failed"
exit 1
fi
echo "✅ All PR checks passed!"