From 38123b9d19728060b61e6713509115b637c62f54 Mon Sep 17 00:00:00 2001 From: Shem Date: Wed, 17 Jul 2024 12:47:33 +0000 Subject: [PATCH] add tests --- steps/03_run_both_servers.yml | 3 +- steps/04_migrate_endpoints.yml | 43 ++++++++++++++++++---- steps/05_update_readme.yml | 65 ++++++++++++++++++++++++++-------- 3 files changed, 90 insertions(+), 21 deletions(-) diff --git a/steps/03_run_both_servers.yml b/steps/03_run_both_servers.yml index 3321f76..1480dd8 100644 --- a/steps/03_run_both_servers.yml +++ b/steps/03_run_both_servers.yml @@ -33,6 +33,7 @@ githubActions: - cmd: docker compose up -d - cmd: sleep 5 - cmd: curl localhost:8001 + - cmd: curl localhost:8000 trigger: type: github_pr_lifecycle_status @@ -62,7 +63,7 @@ trigger: - actionId: github_pr_reject params: person: lucca - message: "Weird, I tried to run the node server using `docker compose up` but couldn't find anything on port 8001, are you sure it works for you?" + message: "Weird, I tried to run the servers using `docker compose up` but couldn't find anything on port 8000 or 8001, are you sure it works for you?" github_pr_merged: do: - actionId: finish_step \ No newline at end of file diff --git a/steps/04_migrate_endpoints.yml b/steps/04_migrate_endpoints.yml index 9b58ed1..2f6fbda 100644 --- a/steps/04_migrate_endpoints.yml +++ b/steps/04_migrate_endpoints.yml @@ -16,11 +16,42 @@ startFlow: - text: We can do it easily by giving copilot the code we want to migrate and ask them for help. - text: Add the Python code you want to migrate [to the chat](https://code.visualstudio.com/docs/copilot/getting-started-chat#_add-chat-context) and ask Copilot to translate it to Node.js. - text: Once the migration is complete, commit the changes and open a PR. Ness will be thrilled with our progress. - - actionId: ready_message - params: - person: lucca + +githubActions: + commands: + - cmd: docker compose up -d + - cmd: sleep 5 + - cmd: | + curl -X POST -H "Content-Type: application/json" -d '{"text": "New task"}' http://localhost:8001/tasks + - cmd: | + curl localhost:8001/tasks | grep "New task" + trigger: - type: user_ready_response + type: github_pr_lifecycle_status flowNode: - do: - - actionId: finish_step + switch: + key: "${eventType}" + cases: + github_pr_opened: + do: + - actionId: github_pr_comment + params: + person: lucca + message: "Got it! Let me review the changes and get back to you." + github_pr_workflow_complete_success: + do: + - actionId: bot_message + params: + person: lucca + messages: + - text: "Good job, you can now merge the PR." + - actionId: github_pr_approve + params: + person: lucca + message: "Good job, you can now merge the PR." + github_pr_workflow_complete_failure: + do: + - actionId: github_pr_reject + params: + person: lucca + message: "I'm sorry, but I can't approve this PR, I found some issues when testing the endpoints." diff --git a/steps/05_update_readme.yml b/steps/05_update_readme.yml index 4d30782..40650d1 100644 --- a/steps/05_update_readme.yml +++ b/steps/05_update_readme.yml @@ -18,19 +18,56 @@ startFlow: chat](https://code.visualstudio.com/docs/copilot/getting-started-chat#_stay-in-the-flow-with-inline-chat) to ask Copilot for updates. Once you're done, commit the changes and open a final PR. Ness will likely throw a party with all this progress. - - actionId: ready_message - params: - person: lucca + trigger: - type: user_ready_response + type: github_pr_lifecycle_status flowNode: - do: - - actionId: bot_message - params: - person: lucca - messages: - - text: Congratulations, you've successfully migrated the Python server to Node - using GitHub Copilot! We've upgraded our tech stack and now have - a Node server handling our tasks. Ness is going to be thrilled. - Great job! - - actionId: finish_step + switch: + key: "${eventType}" + cases: + github_pr_workflow_complete_success: + if: + conditions: + - conditionId: github_does_file_contain + params: + fileName: readme.md + regex: 8001 + - conditionId: github_does_file_contain + params: + fileName: readme.md + regex: node + flags: i + then: + do: + - actionId: github_pr_approve + params: + person: lucca + message: "Nice work! Now you can merge it." + - actionId: bot_message + params: + person: lucca + messages: + - text: "Nice work! Now you can merge it." + else: + do: + - actionId: github_pr_reject + params: + person: lucca + message: "Are you sure you changed the readme file and explained that the node server is running on port 8001?" + - actionId: bot_message + params: + person: lucca + messages: + - text: "Are you sure you changed the readme file and explained that the node server is running on port 8001?" + + github_pr_merged: + do: + - actionId: bot_message + params: + person: lucca + messages: + - text: Congratulations, you've successfully migrated the Python server to Node + using GitHub Copilot! We've upgraded our tech stack and now have + a Node server handling our tasks. Ness is going to be thrilled. + Great job! + - actionId: finish_step \ No newline at end of file