Skip to content
Merged
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
107 changes: 2 additions & 105 deletions .github/workflows/cfdeploy.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
name: Deploy and Integration Test
name: Deploy

on:
pull_request:
types: [closed]
branches:
- develop
workflow_dispatch:

permissions:
pull-requests: read

jobs:
deploy:
if: github.event.pull_request.merged == true
Deploy:
runs-on: cap-java

steps:
Expand Down Expand Up @@ -62,101 +57,3 @@ jobs:
# Deploy the application
echo "Running cf deploy"
cf deploy mta_archives/demoappjava_1.0.0.mtar -f

integration-test:
needs: deploy
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Install Cloud Foundry CLI and jq
run: |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli jq
- name: Login to Cloud Foundry
run: |
cf login -a ${{ secrets.CF_API }} \
-u ${{ secrets.CF_USER }} \
-p ${{ secrets.CF_PASSWORD }} \
-o ${{ secrets.CF_ORG }} \
-s ${{ secrets.CF_SPACE }}
- name: Fetch and Escape Client Secret
id: fetch_secret
run: |
# Fetch the service instance GUID
service_instance_guid=$(cf service demoappjava-public-uaa --guid)
if [ -z "$service_instance_guid" ]; then
echo "Error: Unable to retrieve service instance GUID"; exit 1;
fi
# Fetch the binding GUID
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")

binding_guid=$(echo $bindings_response | jq -r '.resources[0].guid')
if [ -z "$binding_guid" ]; then
echo "Error: Unable to retrieve binding GUID"; exit 1;
fi

# Fetch the clientSecret
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
clientSecret=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
if [ -z "$clientSecret" ] || [ "$clientSecret" == "null" ]; then
echo "Error: clientSecret is not set or is null"; exit 1;
fi

# Escape any $ characters in the clientSecret
escapedClientSecret=$(echo "$clientSecret" | sed 's/\$/\\$/g')
echo "::set-output name=CLIENT_SECRET::$escapedClientSecret"
- name: Run integration tests
env:
CLIENT_SECRET: ${{ steps.fetch_secret.outputs.CLIENT_SECRET }}
run: |
set -e # Enable error checking
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
# Gather secrets and other values
appUrl="${{ secrets.CF_ORG }}-${{ secrets.CF_SPACE }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
authUrl="${{ secrets.CAPAUTH_URL }}"
clientID="${{ secrets.CAPSDM_CLIENT_ID }}"
clientSecret="${{ env.CLIENT_SECRET }}"
username="${{ secrets.CF_USER }}"
password="${{ secrets.CF_PASSWORD }}"
# Ensure all required variables are set
if [ -z "$appUrl" ]; then echo "Error: appUrl is not set"; exit 1; fi
if [ -z "$authUrl" ]; then echo "Error: authUrl is not set"; exit 1; fi
if [ -z "$clientID" ]; then echo "Error: clientID is not set"; exit 1; fi
if [ -z "$clientSecret" ]; then echo "Error: clientSecret is not set"; exit 1; fi
if [ -z "$username" ]; then echo "Error: username is not set"; exit 1; fi
if [ -z "$password" ]; then echo "Error: password is not set"; exit 1; fi
# Function to partially mask sensitive information for logging
mask() {
local value="$1"
if [ ${#value} -gt 6 ]; then
echo "${value:0:3}*****${value: -3}"
else
echo "${value:0:2}*****"
fi
}
# Update properties file with real values
cat > "$PROPERTIES_FILE" <<EOL
appUrl=$appUrl
authUrl=$authUrl
clientID=$clientID
clientSecret=$clientSecret
username=$username
password=$password
EOL
# Run Maven integration tests
mvn clean verify -P integration-tests -DskipUnitTests || { echo "Maven tests failed"; exit 1; }




162 changes: 162 additions & 0 deletions .github/workflows/deploy_and_Integration_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: Deploy and Integration Test

on:
pull_request:
types: [closed]
branches:
- develop
workflow_dispatch:

permissions:
pull-requests: read

jobs:
deploy:
if: github.event.pull_request.merged == true
runs-on: cap-java

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: develop

- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Verify and Checkout Deploy Branch
run: |
git fetch origin
if git rev-parse --verify origin/develop_deploy; then
git checkout develop_deploy
else
echo "Branch 'develop_deploy' not found. Please verify the branch name."
exit 1
fi
- name: Deleting the sdm directory for fresh build
run: |
pwd
cd
rm -rf .m2/repository/com/sap/cds
- name: Prepare and Deploy to Cloud Foundry
run: |
echo "Current Branch......"
git branch
pwd
cd /sapmnt/home/I355238/actions-runner/_work/sdm/sdm/cap-notebook/demoapp

#Replace placeholder with actual REPOSITORY_ID value
sed -i 's|__REPOSITORY_ID__|'${{ secrets.REPOSITORY_ID }}'|g' ./mta.yaml

mbt build

# Install cf CLI plugin
cf install-plugin multiapps -f

# Login to Cloud Foundry again to ensure session is active
cf login -a ${{ secrets.CF_API }} -u ${{ secrets.CF_USER }} -p ${{ secrets.CF_PASSWORD }} -o ${{ secrets.CF_ORG }} -s ${{ secrets.CF_SPACE }}

# Deploy the application
echo "Running cf deploy"
cf deploy mta_archives/demoappjava_1.0.0.mtar -f

integration-test:
needs: deploy
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Install Cloud Foundry CLI and jq
run: |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli jq
- name: Login to Cloud Foundry
run: |
cf login -a ${{ secrets.CF_API }} \
-u ${{ secrets.CF_USER }} \
-p ${{ secrets.CF_PASSWORD }} \
-o ${{ secrets.CF_ORG }} \
-s ${{ secrets.CF_SPACE }}
- name: Fetch and Escape Client Secret
id: fetch_secret
run: |
# Fetch the service instance GUID
service_instance_guid=$(cf service demoappjava-public-uaa --guid)
if [ -z "$service_instance_guid" ]; then
echo "Error: Unable to retrieve service instance GUID"; exit 1;
fi
# Fetch the binding GUID
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")

binding_guid=$(echo $bindings_response | jq -r '.resources[0].guid')
if [ -z "$binding_guid" ]; then
echo "Error: Unable to retrieve binding GUID"; exit 1;
fi

# Fetch the clientSecret
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
clientSecret=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
if [ -z "$clientSecret" ] || [ "$clientSecret" == "null" ]; then
echo "Error: clientSecret is not set or is null"; exit 1;
fi

# Escape any $ characters in the clientSecret
escapedClientSecret=$(echo "$clientSecret" | sed 's/\$/\\$/g')
echo "::set-output name=CLIENT_SECRET::$escapedClientSecret"
- name: Run integration tests
env:
CLIENT_SECRET: ${{ steps.fetch_secret.outputs.CLIENT_SECRET }}
run: |
set -e # Enable error checking
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
# Gather secrets and other values
appUrl="${{ secrets.CF_ORG }}-${{ secrets.CF_SPACE }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
authUrl="${{ secrets.CAPAUTH_URL }}"
clientID="${{ secrets.CAPSDM_CLIENT_ID }}"
clientSecret="${{ env.CLIENT_SECRET }}"
username="${{ secrets.CF_USER }}"
password="${{ secrets.CF_PASSWORD }}"
# Ensure all required variables are set
if [ -z "$appUrl" ]; then echo "Error: appUrl is not set"; exit 1; fi
if [ -z "$authUrl" ]; then echo "Error: authUrl is not set"; exit 1; fi
if [ -z "$clientID" ]; then echo "Error: clientID is not set"; exit 1; fi
if [ -z "$clientSecret" ]; then echo "Error: clientSecret is not set"; exit 1; fi
if [ -z "$username" ]; then echo "Error: username is not set"; exit 1; fi
if [ -z "$password" ]; then echo "Error: password is not set"; exit 1; fi
# Function to partially mask sensitive information for logging
mask() {
local value="$1"
if [ ${#value} -gt 6 ]; then
echo "${value:0:3}*****${value: -3}"
else
echo "${value:0:2}*****"
fi
}
# Update properties file with real values
cat > "$PROPERTIES_FILE" <<EOL
appUrl=$appUrl
authUrl=$authUrl
clientID=$clientID
clientSecret=$clientSecret
username=$username
password=$password
EOL
# Run Maven integration tests
mvn clean verify -P integration-tests -DskipUnitTests || { echo "Maven tests failed"; exit 1; }




101 changes: 101 additions & 0 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Integration Test

on:
workflow_dispatch:

permissions:
pull-requests: read

jobs:
integration-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Install Cloud Foundry CLI and jq
run: |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli jq
- name: Login to Cloud Foundry
run: |
cf login -a ${{ secrets.CF_API }} \
-u ${{ secrets.CF_USER }} \
-p ${{ secrets.CF_PASSWORD }} \
-o ${{ secrets.CF_ORG }} \
-s ${{ secrets.CF_SPACE }}
- name: Fetch and Escape Client Secret
id: fetch_secret
run: |
# Fetch the service instance GUID
service_instance_guid=$(cf service demoappjava-public-uaa --guid)
if [ -z "$service_instance_guid" ]; then
echo "Error: Unable to retrieve service instance GUID"; exit 1;
fi
# Fetch the binding GUID
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")

binding_guid=$(echo $bindings_response | jq -r '.resources[0].guid')
if [ -z "$binding_guid" ]; then
echo "Error: Unable to retrieve binding GUID"; exit 1;
fi

# Fetch the clientSecret
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
clientSecret=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
if [ -z "$clientSecret" ] || [ "$clientSecret" == "null" ]; then
echo "Error: clientSecret is not set or is null"; exit 1;
fi

# Escape any $ characters in the clientSecret
escapedClientSecret=$(echo "$clientSecret" | sed 's/\$/\\$/g')
echo "::set-output name=CLIENT_SECRET::$escapedClientSecret"
- name: Run integration tests
env:
CLIENT_SECRET: ${{ steps.fetch_secret.outputs.CLIENT_SECRET }}
run: |
set -e # Enable error checking
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
# Gather secrets and other values
appUrl="${{ secrets.CF_ORG }}-${{ secrets.CF_SPACE }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
authUrl="${{ secrets.CAPAUTH_URL }}"
clientID="${{ secrets.CAPSDM_CLIENT_ID }}"
clientSecret="${{ env.CLIENT_SECRET }}"
username="${{ secrets.CF_USER }}"
password="${{ secrets.CF_PASSWORD }}"
# Ensure all required variables are set
if [ -z "$appUrl" ]; then echo "Error: appUrl is not set"; exit 1; fi
if [ -z "$authUrl" ]; then echo "Error: authUrl is not set"; exit 1; fi
if [ -z "$clientID" ]; then echo "Error: clientID is not set"; exit 1; fi
if [ -z "$clientSecret" ]; then echo "Error: clientSecret is not set"; exit 1; fi
if [ -z "$username" ]; then echo "Error: username is not set"; exit 1; fi
if [ -z "$password" ]; then echo "Error: password is not set"; exit 1; fi
# Function to partially mask sensitive information for logging
mask() {
local value="$1"
if [ ${#value} -gt 6 ]; then
echo "${value:0:3}*****${value: -3}"
else
echo "${value:0:2}*****"
fi
}
# Update properties file with real values
cat > "$PROPERTIES_FILE" <<EOL
appUrl=$appUrl
authUrl=$authUrl
clientID=$clientID
clientSecret=$clientSecret
username=$username
password=$password
EOL
# Run Maven integration tests
mvn clean verify -P integration-tests -DskipUnitTests || { echo "Maven tests failed"; exit 1; }
2 changes: 1 addition & 1 deletion .github/workflows/unit.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
mvn clean install -P unit-tests -DskipIntegrationTests

- name: Upload code coverage report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: target/site/jacoco/jacoco.xml
Loading