-
Notifications
You must be signed in to change notification settings - Fork 24
110 lines (106 loc) · 4.19 KB
/
manual-integration-test.yml
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
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 }}
AZURE_NEW_ORG: "azureAccountTests"
AZURE_PROJECT_NAME: "testsProject"
AZURE_PR_NUMBER: 1
AZURE_NEW_TOKEN: ${{ secrets.AZURE_NEW_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 }}
PR_BITBUCKET_TOKEN: ${{ secrets.PR_BITBUCKET_TOKEN }}
PR_BITBUCKET_NAMESPACE: "AstSystemTest"
PR_BITBUCKET_REPO_NAME: "cliIntegrationTest"
PR_BITBUCKET_ID: 1
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=79.9
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