|
| 1 | +name: "Integration tests" |
| 2 | +description: "Run tests with BTP services being bound" |
| 3 | +inputs: |
| 4 | + CF_API: |
| 5 | + description: "Cloud Foundry API endpoint" |
| 6 | + required: true |
| 7 | + CF_USERNAME: |
| 8 | + description: "Cloud Foundry username" |
| 9 | + required: true |
| 10 | + CF_PASSWORD: |
| 11 | + description: "Cloud Foundry password" |
| 12 | + required: true |
| 13 | + CF_ORG: |
| 14 | + description: "Cloud Foundry organization" |
| 15 | + required: true |
| 16 | + CF_SPACE: |
| 17 | + description: "Cloud Foundry space" |
| 18 | + required: true |
| 19 | + NODE_VERSION: |
| 20 | + description: "Node.js version to use for tests" |
| 21 | + required: true |
| 22 | +runs: |
| 23 | + using: "composite" |
| 24 | + steps: |
| 25 | + - name: Install dependencies and Cloud Foundry CLI (v8.9.0) |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + sudo apt-get update |
| 29 | + sudo apt-get install -y libc6 wget tar |
| 30 | + wget "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=8.9.0&source=github-rel" -O cf-cli.tar.gz |
| 31 | + tar -xvzf cf-cli.tar.gz |
| 32 | + sudo mv cf /usr/local/bin/ |
| 33 | + sudo mv cf8 /usr/local/bin/ |
| 34 | + cf --version |
| 35 | +
|
| 36 | + - name: Authenticate with Cloud Foundry |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + echo "::debug::CF_API=${{ inputs.CF_API }}" |
| 40 | + for i in {1..3}; do |
| 41 | + cf login -a ${{ inputs.CF_API }} -u ${{ inputs.CF_USERNAME }} -p ${{ inputs.CF_PASSWORD }} -o ${{ inputs.CF_ORG }} -s ${{ inputs.CF_SPACE }} && break |
| 42 | + echo "cf login failed, retrying ($i/3)..." |
| 43 | + sleep 10 |
| 44 | + if [ "$i" -eq 3 ]; then |
| 45 | + echo "❌ cf login failed after 3 attempts." |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | + done |
| 49 | +
|
| 50 | + - uses: actions/checkout@v2 |
| 51 | + - name: Use Node.js ${{ matrix.node-version }} |
| 52 | + uses: actions/setup-node@v2 |
| 53 | + with: |
| 54 | + node-version: ${{ matrix.node-version }} |
| 55 | + - run: npm i -g @sap/cds-dk |
| 56 | + shell: bash |
| 57 | + - run: npm i |
| 58 | + shell: bash |
| 59 | + - run: cd test/incidents-app && npm i |
| 60 | + shell: bash |
| 61 | + |
| 62 | + - name: Set node env for HANA |
| 63 | + run: echo "NODE_VERSION_HANA=$(echo ${{ inputs.NODE_VERSION }} | tr . _)" >> $GITHUB_ENV |
| 64 | + shell: bash |
| 65 | + # Deploy model to HANA |
| 66 | + - name: Create HDI Container |
| 67 | + shell: bash |
| 68 | + run: cf create-service hana hdi-shared cap-js-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA |
| 69 | + - run: cd test/incidents-app/ && cds deploy --to hana:cap-js-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA |
| 70 | + shell: bash |
| 71 | + # Bind against BTP services |
| 72 | + - run: cds bind db -2 cap-js-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA -o package.json |
| 73 | + shell: bash |
| 74 | + - run: cds bind -2 print-service -o package.json |
| 75 | + shell: bash |
| 76 | + # Run tests in hybrid mode |
| 77 | + - run: cds bind --exec npm run test |
| 78 | + shell: bash |
| 79 | + |
| 80 | + # Cleanup |
| 81 | + - name: Delete HDI Container Key |
| 82 | + if: ${{ always() }} |
| 83 | + run: cf delete-service-key cap-js-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA cap-js-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-key -f |
| 84 | + shell: bash |
| 85 | + # Somehow first delete always fails with a "ongoing operation on service binding" error |
| 86 | + - name: Delete HDI Container |
| 87 | + if: ${{ always() }} |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + for i in {1..3}; do |
| 91 | + cf delete-service cap-js-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA -f && break |
| 92 | + echo "HDI container delete failed, retrying ($i/3)..." |
| 93 | + sleep 10 |
| 94 | + if [ "$i" -eq 3 ]; then |
| 95 | + echo "❌ HDI container delete failed after 3 attempts." |
| 96 | + exit 1 |
| 97 | + fi |
| 98 | + done |
0 commit comments