Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOD_Workflow #36

Merged
merged 11 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ jobs:
if: ${{ inputs.commit_sha != '' }}
with:
ref: ${{ inputs.commit_sha }}
fetch-depth: 0
submodules: 'recursive'

- name: checkout repo
uses: actions/checkout@v4
if: ${{ inputs.commit_sha == '' }}
with:
fetch-depth: 0
submodules: 'recursive'

- name: update packages
run: sudo apt-get update -y
Expand All @@ -41,9 +46,48 @@ jobs:

- name: generate local SSH key
run: ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N ""

- name: Install Python deps
run: pip3 install requests wheel boto3

- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest

- name: run e2e test
run: make e2e
run: |
if ! make e2e ; then
echo "EXIT_STATUS=1" >> $GITHUB_ENV
fi
env:
CLEANUP_TEST_LINODE_INSTANCE: true
LINODE_TOKEN: ${{ secrets.DX_LINODE_TOKEN }}

- name: Copy report.xml from hack directory to root directory
vshanthe marked this conversation as resolved.
Show resolved Hide resolved
run: |
cp hack/*_go_metadata_test_report.xml .

- name: Add additional information to XML report
run: |
filename=$(ls | grep -E '^[0-9]{12}_go_metadata_test_report\.xml$')
python tod_scripts/add_to_xml_test_report.py \
--branch_name "${GITHUB_REF#refs/*/}" \
--gha_run_id "$GITHUB_RUN_ID" \
--gha_run_number "$GITHUB_RUN_NUMBER" \
--xmlfile "${filename}"

- name: Upload test results
run: |
filename=$(ls | grep -E '^[0-9]{12}_go_metadata_test_report\.xml$')
python tod_scripts/test_report_upload_script.py "${filename}"
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}

- name: Test Execution Status Handler
run: |
if [[ "$EXIT_STATUS" != 0 ]]; then
echo "Test execution contains failure(s)"
exit $EXIT_STATUS
else
echo "Tests passed!"
fi
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tod_scripts"]
path = tod_scripts
url = https://github.com/linode/TOD-test-report-uploader.git
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ test-deps:
e2e:
ANSIBLE_HOST_KEY_CHECKING=False ANSIBLE_STDOUT_CALLBACK=debug ansible-playbook -v --extra-vars="debug=${LINODE_DEBUG} ssh_pubkey_path=${TEST_PUBKEY} cleanup_linode=${CLEANUP_TEST_LINODE_INSTANCE}" ./hack/run-e2e.yml

# Define the timestamp and dynamic report filename
REPORT_TIMESTAMP := $(shell date +'%Y%m%d%H%M')
export REPORT_FILENAME := $(REPORT_TIMESTAMP)_go_metadata_test_report.xml

# Runs the E2E test suite locally.
# NOTE: E2E tests must be run from within a Linode.
e2e-local:
Expand Down
15 changes: 15 additions & 0 deletions hack/run-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@
source .test.env && \
make e2e-local
register: run_tests

- name: Find report.xml file on remote server
find:
paths: "~/go-metadata-{{ run_id }}"
patterns: "*_go_metadata_test_report.xml"
file_type: file
register: report_files

- name: Copy report.xml to local folder directory
fetch:
src: "{{ report_files.files | first | default({}).path }}"
dest: "./"
flat: yes
remote_src: yes
ignore_errors: yes

rescue:
- debug:
Expand Down
2 changes: 1 addition & 1 deletion test/integration/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
e2e-local:
go test -v ./...
go test -v ./... | go-junit-report -set-exit-code > $(REPORT_FILENAME)
1 change: 1 addition & 0 deletions tod_scripts
Submodule tod_scripts added at 5f1942