Skip to content

AST Cli integration test #19

AST Cli integration test

AST Cli integration test #19

name: AST Cli integration test
on:
workflow_dispatch:
inputs:
baseUri:
description: 'AST Base URI'
required: true
baseAuthUri:
description: 'AST Base Auth URI'
required: true
secretToken:
description: 'AST API Key'
required: true
username:
description: 'AST Username'
required: true
password:
description: 'AST Password'
required: true
tenant:
description: 'Tenant'
required: true
proxyUser:
description: 'Proxy Username'
required: true
proxyPassword:
description: 'Proxy Password'
required: true
jobs:
manual-integration:
runs-on: ubuntu-latest
env:
GOPRIVATE: "github.com/checkmarxDev/*"
steps:
- name: Masking inputs
id: add_masks
run: |
INP_SECRET_TOKEN=$(jq -r '.inputs.secretToken' $GITHUB_EVENT_PATH)
echo ::add-mask::$INP_SECRET_TOKEN
echo CX_APIKEY="$INP_SECRET_TOKEN" >> $GITHUB_ENV
INP_PASSWORD=$(jq -r '.inputs.password' $GITHUB_EVENT_PATH)
echo ::add-mask::$INP_PASSWORD
echo CX_AST_PASSWORD="$INP_PASSWORD" >> $GITHUB_ENV
INP_PROXY_PASSWORD=$(jq -r '.inputs.proxyPassword' $GITHUB_EVENT_PATH)
echo ::add-mask::$INP_PROXY_PASSWORD
echo PROXY_PASSWORD="$INP_PROXY_PASSWORD" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 #v4.0.0
- name: Install Go
uses: actions/setup-go@v2
with:
go-version-file: go.mod
- name: Setup git
run: git config --global url."https://${{ secrets.PERSONAL_ACCESS_TOKEN }}:@github.com/".insteadOf "https://github.com"
- name: Download
run: go build -o ./bin/cx ./cmd
- name: Go Integration test
shell: bash
env:
CX_BASE_URI: ${{ github.event.inputs.baseUri }}
CX_BASE_AUTH_URI: ${{ github.event.inputs.baseAuthUri }}
CX_AST_USERNAME: ${{ github.event.inputs.username }}
CX_TENANT: ${{ github.event.inputs.tenant }}
CX_SCAN_SSH_KEY: ${{ secrets.CX_SCAN_SSH_KEY }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
PROXY_HOST: localhost
PROXY_PORT: 3128
PROXY_USERNAME: ${{ github.event.inputs.proxyUser }}
PR_GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
PR_GITHUB_NAMESPACE: "checkmarx"
PR_GITHUB_REPO_NAME: "ast-cli"
PR_GITHUB_NUMBER: 418
AZURE_ORG: ${{ secrets.AZURE_ORG }}
AZURE_PROJECT: ${{ secrets.AZURE_PROJECT }}
AZURE_REPOS: ${{ secrets.AZURE_REPOS }}
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
BITBUCKET_WORKSPACE: ${{ secrets.BITBUCKET_WORKSPACE }}
BITBUCKET_REPOS: ${{ secrets.BITBUCKET_REPOS }}
BITBUCKET_USERNAME: ${{ secrets.BITBUCKET_USERNAME }}
BITBUCKET_PASSWORD: ${{ secrets.BITBUCKET_PASSWORD }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
sudo chmod +x ./internal/commands/.scripts/integration_up.sh ./internal/commands/.scripts/integration_down.sh
./internal/commands/.scripts/integration_up.sh
./internal/commands/.scripts/integration_down.sh
- name: Check if total coverage is greater then 80
shell: bash
run: |
CODE_COV=$(go tool cover -func cover.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
EXPECTED_CODE_COV=80
var=$(awk 'BEGIN{ print "'$CODE_COV'"<"'$EXPECTED_CODE_COV'" }')
if [ "$var" -eq 1 ];then
echo "Your code coverage is too low. Coverage precentage is: $CODE_COV"
exit 1
else
echo "Your code coverage test passed! Coverage precentage is: $CODE_COV"
exit 0
fi