Skip to content

Commit

Permalink
Write output to file with python
Browse files Browse the repository at this point in the history
  • Loading branch information
clarmso committed Feb 22, 2024
1 parent 977ccfa commit 49a09ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/staging-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
- name: Setup python
uses: actions/setup-python@v1

- name: Establish Cloud SQL Proxy
uses: mattes/gce-cloudsql-proxy-action@v1
with:
creds: ${{ secrets.GCLOUD_AUTH }}
instance: ${{ secrets.CLOUD_SQL_CONNECTION_NAME }}
port: ${{ secrets.CLOUD_SQL_DATABASE_PORT }}
# - name: Establish Cloud SQL Proxy
# uses: mattes/gce-cloudsql-proxy-action@v1
# with:
# creds: ${{ secrets.GCLOUD_AUTH }}
# instance: ${{ secrets.CLOUD_SQL_CONNECTION_NAME }}
# port: ${{ secrets.CLOUD_SQL_DATABASE_PORT }}

- name: Install requirements
run: pip install -r requirements.txt
Expand All @@ -38,13 +38,11 @@ jobs:
echo "TESTRAIL_PASSWORD=${{ secrets.TESTRAIL_PASSWORD }}" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
- name: Do Stuff!
- name: Get TestRail test suites and tests
run: |
echo "Hello world!"
ls
pwd
python testrail.py
# Use Github Actions marketplace
- name: Sign in to Google Cloud
Expand All @@ -59,7 +57,8 @@ jobs:

# Connect to GCP bucket
# gcloud auth activate-service-account test-dashboard-cloud-run@moz-mobile-tools.iam.gserviceaccount.com --key-file=/tmp/gce-cloudsql-proxy/key.json --project=moz-mobile-tools
# echo "Hello World!" >> `date +"hello-%Y-%m-%dT%H:%M:%S.txt"`
- name: Upload file to GCP bucket
run: |
echo "Hello World!" >> `date +"hello-%Y-%m-%dT%H:%M:%S.txt"`
ls hello-*.txt
gcloud storage cp hello-*.txt gs://backups-testrail-test-suites
14 changes: 13 additions & 1 deletion testrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from utils.datetime_utils import DatetimeUtils as dt

from datetime import datetime

class TestRail:

Expand Down Expand Up @@ -307,9 +308,20 @@ def report_test_runs_insert(self, project_id, payload):
if __name__ == "__main__":
testrail = TestRail()

# TODO: Loop through reference tables for projects in
# Cloud SQL database
# PROJECT_IDS = [59, 14, 27, 48]
PROJECT_ID = 59 # Fenix

# TODO: Loop through all test suites for each project.
SUITE_ID = 3192
response = testrail.test_cases(PROJECT_ID, SUITE_ID)
# response = testrail.test_cases(PROJECT_ID)
print(response)

# Put response to a file for uploading later
# print(response)
current = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
output_filename = "hello-{timestamp}.txt".format(timestamp = current)
output_file = open(output_filename, "w")
output_file.write(response)
output_file.close()

0 comments on commit 49a09ed

Please sign in to comment.