Feature/ios optional approov plist #147
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| build-and-test: | |
| runs-on: macos-latest | |
| timeout-minutes: 45 | |
| env: | |
| WORKSPACE: "${{ github.workspace }}" | |
| GIT_BRANCH: "${{ github.ref }}" | |
| CURRENT_TAG: "${{ github.ref_name }}" | |
| # Worker endpoints: consumed from GitHub organisation variables first. | |
| TESTING_REPLY_URL: ${{ vars.TESTING_REPLY_URL }} | |
| TESTING_REPLY_URL_UNPROTECTED: ${{ vars.TESTING_REPLY_URL_UNPROTECTED }} | |
| # Required for the redeploy script invocation on failure | |
| CLOUDFLARE_API_TOKEN_WORKERS_DEV: ${{ secrets.CLOUDFLARE_API_TOKEN_WORKERS_DEV }} | |
| CLOUDFLARE_ACCOUNT_ID_WORKERS_DEV: ${{ secrets.CLOUDFLARE_ACCOUNT_ID_WORKERS_DEV }} | |
| steps: | |
| # ----------------------------------------------------------------------- | |
| # 1. Checkout this repository | |
| # ----------------------------------------------------------------------- | |
| - name: Set up Git | |
| run: git config --global --add safe.directory '*' | |
| - name: Checkout approov-service-react-native | |
| uses: actions/checkout@v5 | |
| with: | |
| path: approov-service-react-native | |
| # ----------------------------------------------------------------------- | |
| # 2. Clone core-service-layers-testing as a sibling directory | |
| # Native build scripts expect: ../core-service-layers-testing/... | |
| # ----------------------------------------------------------------------- | |
| - name: Checkout core-service-layers-testing | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: approov/core-service-layers-testing | |
| token: ${{ secrets.CORE_SERVICE_LAYERS_TESTING_PAT }} | |
| path: core-service-layers-testing | |
| # ----------------------------------------------------------------------- | |
| # 3. Verify worker endpoints (with auto-redeploy) | |
| # ----------------------------------------------------------------------- | |
| - name: Verify worker endpoints | |
| run: | | |
| # ── URL resolution ────────────────────────────────────────────────── | |
| # URLs MUST be set as GitHub organisation or repository variables. | |
| # No hardcoded fallback is provided to avoid exposing endpoints | |
| # in the public repository. | |
| if [[ -z "$TESTING_REPLY_URL" || -z "$TESTING_REPLY_URL_UNPROTECTED" ]]; then | |
| echo "ERROR: TESTING_REPLY_URL and TESTING_REPLY_URL_UNPROTECTED must be" | |
| echo " set as GitHub organisation or repository variables." | |
| echo " See CONTRIBUTING.md for setup instructions." | |
| exit 1 | |
| fi | |
| PROTECTED_URL="$TESTING_REPLY_URL" | |
| UNPROTECTED_URL="$TESTING_REPLY_URL_UNPROTECTED" | |
| echo "TESTING_REPLY_URL=$PROTECTED_URL" >> "$GITHUB_ENV" | |
| echo "TESTING_REPLY_URL_UNPROTECTED=$UNPROTECTED_URL" >> "$GITHUB_ENV" | |
| # ── Probe function ────────────────────────────────────────────────── | |
| probe_worker() { | |
| local url="$1" | |
| curl --silent --show-error --fail --max-time 10 \ | |
| -X POST "$url" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"check":"probe"}' | grep -q '"body"' | |
| } | |
| echo "==> Probing workers..." | |
| if probe_worker "$PROTECTED_URL" && probe_worker "$UNPROTECTED_URL"; then | |
| echo " All workers are healthy." | |
| exit 0 | |
| fi | |
| echo " WARNING: One or more workers are down. Attempting redeploy..." | |
| ./core-service-layers-testing/cloudflare-workers/redeploy-workers.sh | |
| echo "==> Verifying after redeploy..." | |
| for i in {1..3}; do | |
| if probe_worker "$PROTECTED_URL" && probe_worker "$UNPROTECTED_URL"; then | |
| echo " Workers successfully restored." | |
| exit 0 | |
| fi | |
| echo " Waiting for propagation (attempt $i/3)..." | |
| sleep 5 | |
| done | |
| echo "ERROR: Workers are still unreachable after redeployment effort." | |
| exit 1 | |
| # ----------------------------------------------------------------------- | |
| # 4. Environment setup | |
| # ----------------------------------------------------------------------- | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| # ----------------------------------------------------------------------- | |
| # 5. Dependencies and Build | |
| # ----------------------------------------------------------------------- | |
| - name: Install dependencies | |
| working-directory: approov-service-react-native | |
| run: npm install | |
| - name: Build Android library | |
| working-directory: approov-service-react-native | |
| run: npm run build:android | |
| # ----------------------------------------------------------------------- | |
| # 6. Run Tests | |
| # ----------------------------------------------------------------------- | |
| - name: Run JS tests (Jest) | |
| working-directory: approov-service-react-native | |
| run: npm run test:js | |
| - name: Run Android tests (JUnit) | |
| working-directory: approov-service-react-native | |
| run: npm run test:android | |
| env: | |
| TESTING_REPLY_URL: ${{ env.TESTING_REPLY_URL }} | |
| TESTING_REPLY_URL_UNPROTECTED: ${{ env.TESTING_REPLY_URL_UNPROTECTED }} | |
| - name: Run iOS native tests | |
| working-directory: approov-service-react-native | |
| run: npm run test:ios | |
| env: | |
| TESTING_REPLY_URL: ${{ env.TESTING_REPLY_URL }} | |
| TESTING_REPLY_URL_UNPROTECTED: ${{ env.TESTING_REPLY_URL_UNPROTECTED }} | |
| # ----------------------------------------------------------------------- | |
| # 7. Upload Artifacts | |
| # ----------------------------------------------------------------------- | |
| - name: Upload Test Results | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: react-native-test-results | |
| path: | | |
| approov-service-react-native/android/build/test-results/ | |
| approov-service-react-native/test-report.html |