Skip to content

Commit

Permalink
Merge pull request #94 from hello-ag/feature/PR_test_github_action
Browse files Browse the repository at this point in the history
Add files to checkout new PR and run unit tests
  • Loading branch information
hello-binit committed Sep 14, 2021
2 parents 3951480 + 81ab07d commit 9b2395e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/pr_clone_run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cd repos
git clone $3 stretch_body_PR_testing
cd stretch_body_PR_testing
git fetch origin pull/$1/head:$2
git checkout $2
cd body
declare -a TestFiles=("test_arm" "test_dxl_comms" "test_end_of_arm" "test_hello_utils" "test_robot_params" "test_timing_stats" "test_base" "test_dynamixel_hello_XL430" "test_end_of_arm_tools" "test_lift" "test_robot" "test_timing_stats" "test_arm" "test_device" "test_dynamixel_XL430" "test_hello_utils" "test_pimu" "test_steppers" )
declare -a TestFiles2=("test_hello_utils")
declare -a TestFiles3=("test_robot_params")
# Iterate the string array using for loop
for fileName in ${TestFiles2[@]}; do
python -m unittest test.$fileName
done
cd ../..
rm -rf stretch_body_PR_testing
exit
~^Z
35 changes: 35 additions & 0 deletions .github/workflows/stretch_ssh_pr_checkout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Checkout new PR
on:
pull_request_target:
jobs:
Checkout_PR_and_run_tests:
runs-on: ubuntu-18.04
steps:
- name: Repository checkout
uses: actions/checkout@v2

- name: save the ssh key for access to robot to the file
run: 'echo "$SSH_KEY" > the_key'
shell: bash
env:
SSH_KEY: ${{ secrets.STRETCH_SSH_KEY_GITHUB_ACTION }}
- run: chmod 400 the_key

- name: Print out PR reference values
run: |
echo github.base_ref: ${{ github.base_ref }}
echo github.head_ref: ${{ github.head_ref }}
echo github.ref: ${{ github.ref }}
- name: Replace PR number, Branch name and Cloning URL
run: sed -e "s/\$1/${PR_NUMBER}/g" -e "s|\$2|${BRANCH_NAME}|g" -e "s|\$3|${CLONE_URL}|g" .github/workflows/pr_checkout_commands.sh > ssh_commands_pr_info.sh; cat ssh_commands_pr_info.sh
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH_NAME: ${{ github.head_ref }}
CLONE_URL: ${{ github.event.repository.clone_url }}

- name: Log into stretch using ssh and run tests
run: ssh -i the_key hello-robot@"${STRETCH_IP}" -p "$STRETCH_PORT" -tt -o StrictHostKeyChecking=no < ./ssh_commands_pr_info.sh
env:
STRETCH_IP: 72.134.86.243
STRETCH_PORT: 43771

0 comments on commit 9b2395e

Please sign in to comment.