-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaction.yml
More file actions
118 lines (110 loc) · 4.5 KB
/
action.yml
File metadata and controls
118 lines (110 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: "Integration tests"
description: "Run tests with BTP services being bound"
inputs:
CF_API:
description: "Cloud Foundry API endpoint"
required: true
CF_USERNAME:
description: "Cloud Foundry username"
required: true
CF_PASSWORD:
description: "Cloud Foundry password"
required: true
CF_ORG:
description: "Cloud Foundry organization"
required: true
CF_SPACE:
description: "Cloud Foundry space"
required: true
NODE_VERSION:
description: "Node.js version to use for tests"
required: true
runs:
using: "composite"
steps:
- name: Install dependencies and Cloud Foundry CLI (v8.9.0)
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libc6 wget tar
wget "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=8.9.0&source=github-rel" -O cf-cli.tar.gz
tar -xvzf cf-cli.tar.gz
sudo mv cf /usr/local/bin/
sudo mv cf8 /usr/local/bin/
cf --version
- 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 test/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 }}
- name: Install root dependencies
shell: bash
run: |
npm install @sap/cds@${{ matrix.cds-version }}
npm install
- 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-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }}
- run: cd test/bookshop/ && cds deploy --to hana:cap-js-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }}
shell: bash
# Bind against BTP services
- run: cds bind db -2 cap-js-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }} -o package.json
shell: bash
- run: cds bind print-service -2 print-service -o package.json
shell: bash
# Run tests in hybrid mode
- run: cds bind --exec npm run test
shell: bash
# Cleanup
- name: Delete HDI Container Key
if: ${{ always() }}
run: cf delete-service-key cap-js-print-hana-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-$NODE_VERSION_HANA-${{ matrix.cds-version }} cap-js-print-hana-${{ 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-print-hana-${{ 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