Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: HewlettPackard/hpegl-vmaas-terraform-resources
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.0-beta2
Choose a base ref
...
head repository: HewlettPackard/hpegl-vmaas-terraform-resources
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing 342 changed files with 11,926 additions and 3,492 deletions.
33 changes: 33 additions & 0 deletions .github/parse_logs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
# (C) Copyright 2024 Hewlett Packard Enterprise Development LP

import os
import sys


def main(args):
n = len(args)
if n != 2:
print("Pass the log directory or txt file path")
return 1
log_path = args[1]
file_content = ''
if log_path.endswith(".txt"):
with open(log_path) as f:
file_content += (f.read())
else:
for x in os.listdir(log_path):
if x.endswith(".txt"):
with open(os.path.join(log_path, x)) as f:
file_content += (f.read())
test_count = file_content.count('RUN') - file_content.count('SKIP:')
pass_count = file_content.count('PASS:')
fail_count = file_content.count('FAIL:')
print(
f"\nTestcases Ran: {test_count}; \n"
f"Testcases Passed: {pass_count}; \n"
f"Testcases Failed: {fail_count}; \n")
return 0

if __name__ == "__main__":
exit(main(sys.argv))
61 changes: 35 additions & 26 deletions .github/workflows/acc.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
name: acc
name: Acceptance Tests Running on HPE PCE Solution Deployment Tenant

on:
push:
branches:
- master
jobs:

acc:
runs-on: [self-hosted, Linux, ubuntu]
steps:

- name: Checkout workspace
uses: actions/checkout@v2
# Runs every 2 days once at 3AM
# schedule:
# - cron: '0 21 */2 * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
test_case:
description: 'Enter testcases sperated by space. Leave empty for all'
required: false
default: ''
type: string
test_description:
description: 'Enter description for the test'
required: true
default: 'Check all Terraform Testcases'
type: string

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
release:
types: [published]

- name: Install necessary tools
run: make tools

- name: Run Acceptance test
env:
HPEGL_IAM_TOKEN: ${{secrets.HPEGL_IAM_TOKEN}}
TF_ACC_CMP_SUBJECT: ${{secrets.CMP_SUBJECT}}
TF_ACC_CONFIG: ${{secrets.TF_ACC_CONFIG}}
TF_ACC_MOCK_IAM: true
run: make acceptance
jobs:
acc-test:
uses: ./.github/workflows/reusable-dev-acc.yml
with:
test_case: ${{ inputs.test_case }}
test_description: ${{ inputs.test_description }}
test_case_folder: 'acc-testcases'
secrets:
DEV_HPEGL_IAM_SERVICE_URL: ${{ secrets.HPEGL_IAM_SERVICE_URL }}
DEV_HPEGL_TENANT_ID: ${{ secrets.HPEGL_TENANT_ID }}
DEV_HPEGL_USER_SECRET: ${{ secrets.HPEGL_USER_SECRET }}
DEV_HPEGL_USER_ID: ${{ secrets.HPEGL_USER_ID }}
DEV_HPEGL_VMAAS_API_URL: ${{ secrets.HPEGL_VMAAS_API_URL }}
DEV_HPEGL_VMAAS_LOCATION: ${{ secrets.HPEGL_VMAAS_LOCATION }}
DEV_HPEGL_VMAAS_SPACE_NAME: ${{ secrets.HPEGL_VMAAS_SPACE_NAME}}
TF_ACC: ${{ secrets.TF_ACC }}
18 changes: 10 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
name: ci
name: CI Lint Check

on: pull_request
on: [pull_request]
jobs:

ci:
runs-on: [self-hosted, Linux, ubuntu]
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.21' ]
steps:

- name: Checkout workspace
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.17
go-version: '1.21'

- name: Install necessary tools
run: make tools
@@ -25,4 +27,4 @@ jobs:
run: make build

- name: Validate lint
run: make lint
run: make lint
77 changes: 77 additions & 0 deletions .github/workflows/cicd-dev-acc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: IaC Tests for CI CD Gating Job
# This workflow runs all the acc-dev-testcases

on:
workflow_dispatch:

jobs:
test-provider:
uses: ./.github/workflows/reusable-dev-acc.yml
with:
test_case: TestProvider
test_description: Check for valid terraform provider
vmaas_broker_url: "https://vmaas-broker.intg.hpedevops.net"
secrets: inherit

test-datasouces:
needs: [test-provider]
if: "always() && ${{ needs.test-provider.result == 'success' }}"
uses: ./.github/workflows/reusable-dev-acc.yml
with:
test_case: TestAccDataSource
test_description: GET call usecase validations
vmaas_broker_url: "https://vmaas-broker.intg.hpedevops.net"
secrets: inherit

test-vmaas-instance:
uses: ./.github/workflows/reusable-dev-acc.yml
needs: [test-datasouces]
if: "always()"
with:
test_case: TestVmaasInstance TestAccResourceInstance
test_description: Instance usecase validations
vmaas_broker_url: "https://vmaas-broker.intg.hpedevops.net"
secrets: inherit

test-vmaas-lb:
uses: ./.github/workflows/reusable-dev-acc.yml
needs: [test-vmaas-instance]
if: "always()"
with:
test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate
test_description: Loadbalancer usecase validations
vmaas_broker_url: "https://vmaas-broker.intg.hpedevops.net"
secrets: inherit

test-vmaas-network:
uses: ./.github/workflows/reusable-dev-acc.yml
needs: [test-vmaas-lb]
if: "always()"
with:
test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan
test_description: NSX Network usecase validations
vmaas_broker_url: "https://vmaas-broker.intg.hpedevops.net"
secrets: inherit

process-logs:
runs-on: ubuntu-20.04
needs: [test-vmaas-network]
if: "always()"
steps:
- name: Checkout workspace
uses: actions/checkout@v4
- name: Download logs
id: logs
uses: actions/download-artifact@v4
with:
path: tmp/artifacts
merge-multiple: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Print Result and Publish
run: |
LOG_RESULT=$(python .github/parse_logs.py '${{ steps.logs.outputs.download-path }}')
echo $LOG_RESULT
curl -X POST -H 'Content-type: application/json' --data "{'text':'CICD Terraform IaC Test results $LOG_RESULT and report link - https://github.com/HewlettPackard/hpegl-vmaas-terraform-resources/actions/runs/${{ github.run_id }}'}" '${{ secrets.TEAMS_URL_CICD }}'
44 changes: 44 additions & 0 deletions .github/workflows/cicd-prod-acc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: IaC Tests for CI CD Solution Job

on:
workflow_dispatch:

jobs:
acc-test:
uses: ./.github/workflows/reusable-dev-acc.yml
with:
test_description: IaC Terraform Testcase
test_case_folder: 'acc-testcases'
secrets:
DEV_HPEGL_IAM_SERVICE_URL: ${{ secrets.HPEGL_IAM_SERVICE_URL }}
DEV_HPEGL_TENANT_ID: ${{ secrets.HPEGL_TENANT_ID }}
DEV_HPEGL_USER_SECRET: ${{ secrets.HPEGL_USER_SECRET }}
DEV_HPEGL_USER_ID: ${{ secrets.HPEGL_USER_ID }}
DEV_HPEGL_VMAAS_API_URL: ${{ secrets.HPEGL_VMAAS_API_URL }}
DEV_HPEGL_VMAAS_LOCATION: ${{ secrets.HPEGL_VMAAS_LOCATION }}
DEV_HPEGL_VMAAS_SPACE_NAME: ${{ secrets.HPEGL_VMAAS_SPACE_NAME}}
TF_ACC: ${{ secrets.TF_ACC }}

process-logs:
runs-on: ubuntu-20.04
needs:
- acc-test
if: "always()"
steps:
- name: Checkout workspace
uses: actions/checkout@v4
- name: Download logs
id: logs
uses: actions/download-artifact@v4
with:
path: tmp/artifacts
merge-multiple: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Print Result and Publish
run: |
LOG_RESULT=$(python .github/parse_logs.py '${{ steps.logs.outputs.download-path }}')
echo $LOG_RESULT
curl -X POST -H 'Content-type: application/json' --data "{'text':'CICD Terraform IaC Test results $LOG_RESULT and report link - https://github.com/HewlettPackard/hpegl-vmaas-terraform-resources/actions/runs/${{ github.run_id }}'}" '${{ secrets.SLACK_URL_CICD }}'
43 changes: 43 additions & 0 deletions .github/workflows/dev-acc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Dev Acceptance Testing
# This workflow is intended to run a particular set of testcases
# If want to execute all test, consider running cicd-dev-acc.yml

on:
# Runs every 2 days once at 3AM
# schedule:
# - cron: '0 21 */2 * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
test_case:
description: 'Enter testcases sperated by space'
required: true
default: 'TestProvider'
type: string
test_description:
description: 'Enter description for the test'
required: true
default: 'Check Terraform Dev Testcase'
type: string
vmaas_broker_url:
description: 'Enter VMaaS Broker URL'
required: false
default: 'https://vmaas-broker.intg.hpedevops.net'
type: string

jobs:
acc-test:
uses: ./.github/workflows/reusable-dev-acc.yml
with:
test_case: ${{ inputs.test_case }}
test_description: ${{ inputs.test_description }}
vmaas_broker_url: ${{ inputs.vmaas_broker_url }}
secrets:
DEV_HPEGL_IAM_SERVICE_URL: ${{ secrets.DEV_HPEGL_IAM_SERVICE_URL }}
DEV_HPEGL_TENANT_ID: ${{ secrets.DEV_HPEGL_TENANT_ID }}
DEV_HPEGL_USER_SECRET: ${{ secrets.DEV_HPEGL_USER_SECRET }}
DEV_HPEGL_USER_ID: ${{ secrets.DEV_HPEGL_USER_ID }}
DEV_HPEGL_VMAAS_API_URL: ${{ secrets.DEV_HPEGL_VMAAS_API_URL }}
DEV_HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }}
DEV_HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}}
TF_ACC: ${{ secrets.TF_ACC }}
53 changes: 53 additions & 0 deletions .github/workflows/malware-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP

name: Malware Scan
on:
pull_request:
push:
branches:
- main
- master

jobs:
scan_repository:
name: "Scan Virus on Repository"
runs-on: "ubuntu-latest"
permissions:
id-token: write
contents: read
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v4"
with:
fetch-depth: 0
- name: "Scan Source for Viruses"
id: scan
run: |
SHA_SHORT=$(git rev-parse --short HEAD)
SCAN_OUTPUT=/tmp/clamav-repository-results-${{ github.event.repository.name }}-${SHA_SHORT}-$(date +%s).txt
echo "scan_output=${SCAN_OUTPUT}" >> $GITHUB_OUTPUT
docker run --rm -v ${{ github.workspace }}:/scandir -v /tmp:/tmp -e SCAN_OUTPUT=${SCAN_OUTPUT} clamav/clamav:stable clamscan --infected --recursive --max-files=0 --max-filesize=0 --max-scansize=0 --max-recursion=1000 --max-dir-recursion=1000 /scandir | tee -a $SCAN_OUTPUT
INFECTED_FILES=$(grep ^Infected $SCAN_OUTPUT | awk '{print $NF}')
echo "infected_files=${INFECTED_FILES}" >> $GITHUB_OUTPUT
exit $INFECTED_FILES
- name: "Configure AWS Credentials"
if: always()
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::522637239241:role/s3-avscan-upload
role-session-name: malware-scan-upload
aws-region: us-west-2
- name: "Upload Source Scan Results"
if: always()
run: aws s3 cp ${{ steps.scan.outputs.scan_output }} s3://glcs-cloud-security-dev-avscan.hpe-hcss.hpe.com/
- name: "Tag Scan Upload"
if: always()
run: |
GH_OWNER=${{ github.repository_owner }}
GH_REPO=${{ github.event.repository.name }}
INFECTED_FILES=${{ steps.scan.outputs.infected_files }}
OBJECT_KEY=`basename ${{ steps.scan.outputs.scan_output }}`
aws s3api put-object-tagging \
--bucket glcs-cloud-security-dev-avscan.hpe-hcss.hpe.com \
--key $OBJECT_KEY \
--tagging "{\"TagSet\": [{ \"Key\": \"github_owner\", \"Value\": \"$GH_OWNER\" },{ \"Key\": \"github_repository\", \"Value\": \"$GH_REPO\"},{\"Key\": \"infected_files\", \"Value\": \"$INFECTED_FILES\"}]}"
Loading