Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 49 additions & 61 deletions .github/actions/integration-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,41 +35,26 @@ runs:

# BTP Auth
# Uncomment when you want to run hybrid integration tests
# - name: Authenticate with Cloud Foundry
# shell: bash
# run: |
# echo "::debug::CF_API=${{ inputs.CF_API }}"
# for i in {1..3}; do
# cf login -a ${{ inputs.CF_API }} -u ${{ inputs.CF_USERNAME }} -p ${{ inputs.CF_PASSWORD }} -o ${{ inputs.CF_ORG }} -s ${{ inputs.CF_SPACE }} && break
# echo "cf login failed, retrying ($i/3)..."
# sleep 10
# if [ "$i" -eq 3 ]; then
# echo "❌ cf login failed after 3 attempts."
# exit 1
# fi
# done
- name: Authenticate with Cloud Foundry
shell: bash
run: |
echo "::debug::CF_API=${{ inputs.CF_API }}"
for i in {1..3}; do
cf login -a ${{ inputs.CF_API }} -u ${{ inputs.CF_USERNAME }} -p ${{ inputs.CF_PASSWORD }} -o ${{ inputs.CF_ORG }} -s ${{ inputs.CF_SPACE }} && break
echo "cf login failed, retrying ($i/3)..."
sleep 10
if [ "$i" -eq 3 ]; then
echo "❌ cf login failed after 3 attempts."
exit 1
fi
done

- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Set CDS version-specific dependencies
shell: bash
run: |
if [ "${{ matrix.cds-version }}" == "8" ]; then
echo "Installing CDS 8 compatible packages..."
npm pkg set "devDependencies.@cap-js/sqlite=^1.0.0"
npm pkg set "overrides.@cap-js/sqlite=^1.0.0"
npm pkg set "overrides.@cap-js/hana=^1.0.0"
npm pkg set "overrides.@cap-js/db-service=^1.0.0"
cd tests/bookshop
npm pkg set "dependencies.@cap-js/hana=^1.0.0"
npm pkg set "dependencies.@cap-js/db-service=^1.0.0"
cd ../..
fi

- name: Install global CDS
shell: bash
run: npm i -g @sap/cds-dk@${{ matrix.cds-version }}
Expand All @@ -78,49 +63,52 @@ runs:
run: |
npm install @sap/cds@${{ matrix.cds-version }}
npm install
- name: Generate Types for sample project
shell: bash
run: cd tests/bookshop && npm run cds-typer

# HANA Cloud Deployment and binding
# Uncomment when you want to run your hybrid integration tests against HANA Cloud
# Replace your-project with your actual project name
# - name: Set node env for HANA
# run: echo "NODE_VERSION_HANA=$(echo ${{ inputs.NODE_VERSION }} | tr . _)" >> $GITHUB_ENV
# shell: bash
# Replace process with your actual project name
- name: Set node env for HANA
run: echo "NODE_VERSION_HANA=$(echo ${{ inputs.NODE_VERSION }} | tr . _)" >> $GITHUB_ENV
shell: bash
# Deploy model to HANA
# - name: Create HDI Container
# shell: bash
# run: cf create-service hana hdi-shared cap-js-your-project-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }}
# - run: cd tests/bookshop/ && cds deploy --to hana:cap-js-your-project-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }}
# shell: bash
# # Bind HANA Cloud instance
# - run: cds bind db -2 cap-js-your-project-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }} -o package.json
# shell: bash
- name: Create HDI Container
shell: bash
run: cf create-service hana hdi-shared cap-js-process-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }}
- run: cd tests/bookshop/ && cds deploy --to hana:cap-js-process-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }}
shell: bash
# Bind HANA Cloud instance
- run: cds bind db -2 cap-js-process-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }} -o package.json
shell: bash

# Bind against BTP services
# Uncomment when actual BTP services should be used. The first argument of `cds bind` is only needed for CAP v8
# - run: cds bind <your-service> -2 <your-service> -o package.json
# shell: bash
- run: cds bind process -2 sbpa-service-instance -o package.json
shell: bash
# Run tests in hybrid mode
- run: npm run test:hybrid
shell: bash

# HANA Cleanup
# Uncomment when you want to run your hybrid integration tests against HANA Cloud
# Replace your-project with your actual project name
# - name: Delete HDI Container Key
# if: ${{ always() }}
# run: cf delete-service-key cap-js-your-project-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }} cap-js-your-project-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }}-key -f
# shell: bash
# # Somehow first delete always fails with a "ongoing operation on service binding" error
# - name: Delete HDI Container
# if: ${{ always() }}
# shell: bash
# run: |
# for i in {1..3}; do
# cf delete-service cap-js-your-project-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }} -f && break
# echo "HDI container delete failed, retrying ($i/3)..."
# sleep 10
# if [ "$i" -eq 3 ]; then
# echo "❌ HDI container delete failed after 3 attempts."
# exit 1
# fi
# done
# Replace process with your actual project name
- name: Delete HDI Container Key
if: ${{ always() }}
run: cf delete-service-key cap-js-process-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }} cap-js-process-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }}-key -f
shell: bash
# Somehow first delete always fails with a "ongoing operation on service binding" error
- name: Delete HDI Container
if: ${{ always() }}
shell: bash
run: |
for i in {1..3}; do
cf delete-service cap-js-process-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }} -f && break
echo "HDI container delete failed, retrying ($i/3)..."
sleep 10
if [ "$i" -eq 3 ]; then
echo "❌ HDI container delete failed after 3 attempts."
exit 1
fi
done
39 changes: 19 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,22 @@ jobs:
- run: npm run build
- run: cd tests/bookshop && npm i && npm run build
- run: npm run test
# integration-tests:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# node-version: [20.x, 22.x]
# cds-version: [latest, 8]
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Integration tests
# uses: ./.github/actions/integration-tests
# with:
# CF_API: ${{ secrets.CF_API }}
# CF_USERNAME: ${{ secrets.CF_USERNAME }}
# CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
# CF_ORG: ${{ secrets.CF_ORG }}
# CF_SPACE: ${{ secrets.CF_SPACE }}
# NODE_VERSION: ${{ matrix.node-version }}
# - run: npm run test
integration-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [20.x, 22.x]
cds-version: [latest]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Integration tests
uses: ./.github/actions/integration-tests
with:
CF_API: ${{ secrets.CF_API }}
CF_USERNAME: ${{ secrets.CF_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE }}
NODE_VERSION: ${{ matrix.node-version }}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"test": "jest --silent",
"test:watch": "jest --watch",
"test:integration": "jest tests/integration",
"test:hybrid": "npx jest tests/integration/annotations/lifeCycleAnnotation.test.ts",
"build": "npm run cds-build && npm run cds-typer",
"cds-build": "cds-tsx build",
"cds-typer": "npx @cap-js/cds-typer \"*\" --outputDirectory @cds-models",
Expand Down Expand Up @@ -42,6 +43,9 @@
"[development]": {
"kind": "local-process-service"
},
"[hybrid]": {
"kind": "deployed-process-service"
},
"[production]": {
"kind": "deployed-process-service"
}
Expand Down
9 changes: 8 additions & 1 deletion tests/bookshop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"version": "1.0.0",
"description": "A simple CAP project.",
"dependencies": {
"@cap-js/process": "file:../../"
"@cap-js/process": "file:../../",
"@sap-cloud-sdk/connectivity": "^4",
"@sap-cloud-sdk/http-client": "^4",
"@sap-cloud-sdk/resilience": "^4"
},
"devDependencies": {
"@cap-js/sqlite": "^2",
Expand Down Expand Up @@ -33,6 +36,10 @@
"eu12.bpm-horizon-walkme.sdshipmentprocessor.ShipmentHandlerService": {
"kind": "external",
"model": "srv/external/eu12.bpm-horizon-walkme.sdshipmentprocessor.shipmentHandler"
},
"eu12.cdsmunich.capprocesspluginhybridtest.Lifecycle_Test_ProcessService": {
"kind": "external",
"model": "srv/external/eu12.cdsmunich.capprocesspluginhybridtest.lifecycle_Test_Process"
}
}
},
Expand Down
Loading
Loading