Golang GORM ORM
▌Introduction
Robot Framework GitHub Actions Postman Monitor
▌Introduction
Due to COVID-19,
many people work from home and need to clock in or out online on working days.
Since I sometimes
forget to clock in or out online and I am so lazy to open the HR website and enter
user ID/PWD each time on it, I decided to make the automation clock in(out)
flow by E2E testing stack.
I use the stack
as following:
ü Robot Framework
ü Azure Container Registry
ü GitHub Actions
ü Postman Monitor
▌Steps
▋Record and prepare the E2E automation test
I use Katalon
Recorder and Robot Framework to
have both automation test as clock_in.robot and clock_out.robot.
I would like to
run the tests in Docker environment, so I made a dockefile and could be built
and published the Docker Image to a private Docker registry (e.q. Azure Container
Registry).
See my previous
article, [Robot
Framework] Run E2E test by Chrome and SeleniumLibrary in Docker, for the implementation
details.
Now, I have to find
a way to pull the Docker Image and then run the tests automatically.
▋GitHub Actions
GitHub Actions supports amazing
and easy way to automate the workflow.
This article, [GitHub]
Github Actions - Workflow dependencies, shows how to pull and run a Docker
Image by GitHub Actions workflow.
Here is the YAML
file of workflow that has workflow
dispatch event. I will talk about why using workflow
dispatch instead of schedule
event later.
▋docker_clock_in.yml
And my GitHub
Actions secrets:
After pushing the
workflow YAML file to main/master branch, I can trigger the workflow (open the
headless Chrome, go to HR website and then clock in) in three ways.
(Reference: Manually
running a workflow)
1. GitHub CLI: gh workflow run <workflow>
2. Run the workflow in GitHub Actions UI
https://api.github.com/repos/<user_id>/<reponsitory_name>/actions/workflows/<workflow>.yml/dispatches
▋Why not use schedule
event but workflow_dispatch?
I commented out
the schedule
event in docker_clock_in.yml,
and use workflow_dispatch
event instead. The reason is that schedule
event has a uncertain delay time and won’t be trigger on the schedule time
precisely. If your job can tolerates a delay time, schedule
event might be a good way to trigger it. However, since I need to clock in
before my office hours so I use Postman
Monitor to automatically send the request for running the workflow.
▋Postman Monitor
Postman
Monitor is the collection-based monitor that we can execute a collection of
requests and collect the response time and result by scheduled time. Furthermore,
it runs on Postman's cloud infrastructure, which is hosted by AWS. In other words,
we do not need a live machine to execute the target request(s) by Monitor.
The following is
my monitoring setup for requesting the clock-in workflow_dispatch API.
After dispatched
the workflow, the workflow will pull and run the Docker Image that has
automation tests for my clock-in or clock-out.
▌Summarize
There are many
ways to accomplish this automation job.
I chose the stack/tools
is because I don’t want to have extra cost for this routine job and I do want to
save my time from it.
▌Reference
▋GitHub
Docs: Create a workflow dispatch event
▋GitHub
Docs: Manually running a workflow
▋Postman:
Monitoring your APIs