-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from CBIIT/juarezds
GitHub Actions - ADDING WORKFLOWS
- Loading branch information
Showing
58 changed files
with
1,217 additions
and
878 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.