Skip to content

Commit

Permalink
Merge pull request #319 from CBIIT/juarezds
Browse files Browse the repository at this point in the history
GitHub Actions - ADDING WORKFLOWS
  • Loading branch information
iamdez99 authored Nov 14, 2024
2 parents 5e27e6a + 9e677d0 commit 6827faf
Show file tree
Hide file tree
Showing 58 changed files with 1,217 additions and 878 deletions.
Empty file.
79 changes: 79 additions & 0 deletions .github/scripts/upload_to_sharepoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import os
import glob
import requests
import msal

# Receive environment variables from GitHub Actions Workflow
TENANT_ID = os.getenv('TENANT_ID')
CLIENT_ID = os.getenv('CLIENT_ID')
CLIENT_SECRET = os.getenv('CLIENT_SECRET')
SHAREPOINT_SITE_ID = os.getenv('SHAREPOINT_SITE_ID')
SHAREPOINT_DRIVE_ID = os.getenv('SHAREPOINT_DRIVE_ID')
FILES_PATH = os.getenv('FILES_PATH')

# Define the scopes and endpoints
SCOPE = ["https://graph.microsoft.com/.default"]
GRAPH_API_ENDPOINT = 'https://graph.microsoft.com/v1.0'


def authenticate():
# Forming the authority
authority = f"https://login.microsoftonline.com/{TENANT_ID}"

# Creating the ConfidentialClientApplication
app = msal.ConfidentialClientApplication(
CLIENT_ID,
authority=authority,
client_credential=CLIENT_SECRET,
)

# Getting the access token
result = app.acquire_token_silent(SCOPE, account=None)

if not result:
result = app.acquire_token_for_client(SCOPE)

if "access_token" in result:
return result["access_token"]
else:
raise Exception(f"Authentication failed: {result.get('error')}, {result.get('error_description')}")


def upload_files_to_sharepoint(access_token):
# Get list of all files in the directory
files = glob.glob(FILES_PATH)

for file_path in files:
try:
# Building the correct endpoint
FILE_NAME = os.path.basename(file_path)
upload_url = (
f"{GRAPH_API_ENDPOINT}/sites/{SHAREPOINT_SITE_ID}/drives/{SHAREPOINT_DRIVE_ID}"
f"/items/root:/{FILE_NAME}:/content"
)

# Read file content
with open(file_path, "rb") as file_data:
file_content = file_data.read()

# Define headers
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/octet-stream",
}

# Make the request
response = requests.put(upload_url, headers=headers, data=file_content)

# Check the response
if response.status_code == 201:
print(f"File uploaded successfully to {SHAREPOINT_DRIVE_ID}/{FILE_NAME}")
else:
print(f"Failed to upload file: {response.status_code}, {response.text}")

except Exception as e:
print(f"Error: {e}")


if __name__ == "__main__":
upload_files_to_sharepoint(authenticate())
13 changes: 13 additions & 0 deletions .github/workflows/ANALYSIS TOOLS - CCP Regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ jobs:
with:
name: CCP-REGRESSION-${{ env.timestamp }}
path: target/CCP-reports/*

- name: Upload to SharePoint
shell: powershell
run: |
$Env:PATH = "C:\Users\juarezds\AppData\Local\Programs\Python\Python312;$Env:PATH"
python $Env:GITHUB_WORKSPACE\.github\scripts\upload_to_sharepoint.py
env:
FILES_PATH: target/CCP-reports/*
SHAREPOINT_SITE_ID: ${{ secrets.SHAREPOINT_SITE_ID }}
SHAREPOINT_DRIVE_ID: ${{ secrets.SHAREPOINT_DRIVE_ID }}
tenant_id: ${{ secrets.SHAREPOINT_TENANT_ID }}
client_id: ${{ secrets.SHAREPOINT_CLIENT_ID }}
client_secret: ${{ secrets.SHAREPOINT_CLIENT_SECRET }}
17 changes: 15 additions & 2 deletions .github/workflows/ANALYSIS TOOLS - ICDGenie Regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,24 @@ jobs:
Add-Content -Path $env:GITHUB_ENV -Value "timestamp=$timestamp"
- name: Determine report path
id: reportpath
run: echo "path=html-reports" >> $GITHUB_ENV
run: echo "path=ICDGenie-regression-reports" >> $GITHUB_ENV

- name: Upload Cucumber Report
uses: actions/upload-artifact@v4
if: always()
with:
name: ICDGENIE-REGRESSION-${{ env.timestamp }}
path: target/html-reports/*
path: target/ICDGenie-regression-reports/*

- name: Upload to SharePoint
shell: powershell
run: |
$Env:PATH = "C:\Users\juarezds\AppData\Local\Programs\Python\Python312;$Env:PATH"
python $Env:GITHUB_WORKSPACE\.github\scripts\upload_to_sharepoint.py
env:
FILES_PATH: target/ICDGenie-regression-reports/*
SHAREPOINT_SITE_ID: ${{ secrets.SHAREPOINT_SITE_ID }}
SHAREPOINT_DRIVE_ID: ${{ secrets.SHAREPOINT_DRIVE_ID }}
tenant_id: ${{ secrets.SHAREPOINT_TENANT_ID }}
client_id: ${{ secrets.SHAREPOINT_CLIENT_ID }}
client_secret: ${{ secrets.SHAREPOINT_CLIENT_SECRET }}
56 changes: 56 additions & 0 deletions .github/workflows/ANALYSIS TOOLS - NIFE Regression.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: ANALYSIS TOOLS - NIFE Regression

on:
schedule:
# This corresponds to 10:30 AM EST (3:30 PM UTC) from Monday to Friday
- cron: '30 15 * * MON-FRI'
workflow_dispatch:
inputs:
testBrowser:
description: 'Browser'
required: true
default: 'chrome'

jobs:
build:
runs-on: NCI-WINDOWS
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Run specific runner class
run: mvn -B -q -Dtest="AnalysisTools.NIFESubmit.NIFESubmit_Runners.RunNIFESubmitRegressionTest" test
continue-on-error: true

- name: Generate timestamp
id: timestamp
run: |
$timeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById("Eastern Standard Time")
$dateTime = [System.TimeZoneInfo]::ConvertTime([System.DateTime]::UtcNow, $timeZone)
$timestamp = $dateTime.ToString("yyyy-MM-dd_hh-mm-ss_tt")
Add-Content -Path $env:GITHUB_ENV -Value "timestamp=$timestamp"
- name: Determine report path
id: reportpath
run: echo "path=NIFE-Regression-reports" >> $GITHUB_ENV

- name: Upload Cucumber Report
uses: actions/upload-artifact@v4
if: always()
with:
name: NIFE-REGRESSION-${{ env.timestamp }}
path: target/NIFE-Regression-reports/*

- name: Upload to SharePoint
shell: powershell
run: |
$Env:PATH = "C:\Users\juarezds\AppData\Local\Programs\Python\Python312;$Env:PATH"
python $Env:GITHUB_WORKSPACE\.github\scripts\upload_to_sharepoint.py
env:
FILES_PATH: target/NIFE-Regression-reports/*
SHAREPOINT_SITE_ID: ${{ secrets.SHAREPOINT_SITE_ID }}
SHAREPOINT_DRIVE_ID: ${{ secrets.SHAREPOINT_DRIVE_ID }}
tenant_id: ${{ secrets.SHAREPOINT_TENANT_ID }}
client_id: ${{ secrets.SHAREPOINT_CLIENT_ID }}
client_secret: ${{ secrets.SHAREPOINT_CLIENT_SECRET }}
56 changes: 56 additions & 0 deletions .github/workflows/ANALYSIS TOOLS - SOCCER Regression.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: ANALYSIS TOOLS - SOCCER Regression

on:
schedule:
# This corresponds to 7:30 AM EST (12:30 PM UTC) from Monday to Friday
- cron: '30 12 * * 1-5'
workflow_dispatch:
inputs:
testBrowser:
description: 'Browser'
required: true
default: 'chrome'

jobs:
build:
runs-on: NCI-WINDOWS
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Run specific runner class
run: mvn -B -q -Dtest="AnalysisTools.Soccer.Soccer_Runners.RunSoccerRegressionTest" test
continue-on-error: true

- name: Generate timestamp
id: timestamp
run: |
$timeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById("Eastern Standard Time")
$dateTime = [System.TimeZoneInfo]::ConvertTime([System.DateTime]::UtcNow, $timeZone)
$timestamp = $dateTime.ToString("yyyy-MM-dd_hh-mm-ss_tt")
Add-Content -Path $env:GITHUB_ENV -Value "timestamp=$timestamp"
- name: Determine report path
id: reportpath
run: echo "path=soccer-regression-reports" >> $GITHUB_ENV

- name: Upload Cucumber Report
uses: actions/upload-artifact@v4
if: always()
with:
name: SOCCER-REGRESSION-${{ env.timestamp }}
path: target/soccer-regression-reports/*

- name: Upload to SharePoint
shell: powershell
run: |
$Env:PATH = "C:\Users\juarezds\AppData\Local\Programs\Python\Python312;$Env:PATH"
python $Env:GITHUB_WORKSPACE\.github\scripts\upload_to_sharepoint.py
env:
FILES_PATH: target/soccer-regression-reports/*
SHAREPOINT_SITE_ID: ${{ secrets.SHAREPOINT_SITE_ID }}
SHAREPOINT_DRIVE_ID: ${{ secrets.SHAREPOINT_DRIVE_ID }}
tenant_id: ${{ secrets.SHAREPOINT_TENANT_ID }}
client_id: ${{ secrets.SHAREPOINT_CLIENT_ID }}
client_secret: ${{ secrets.SHAREPOINT_CLIENT_SECRET }}
85 changes: 0 additions & 85 deletions .github/workflows/CCT-CHAT-BOT-Smoke.yml

This file was deleted.

Loading

0 comments on commit 6827faf

Please sign in to comment.