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

Add a testing CI on the aws image #19

Closed
wants to merge 12 commits into from
Closed

Add a testing CI on the aws image #19

wants to merge 12 commits into from

Conversation

bidoubiwa
Copy link
Contributor

This PR adds a CI that is run on every pull_request and push. In the CI:

  • A temporary IAM with the current packer configuration is created
  • An EC2 instance is created based on this IAM.
  • It waits for the instance to be up and running. A timeout error is raised after 10 minutes
  • It tests is done to ensure Meilisearch is running correctly by making a request on /health and ensure the answer is {"status":"available"}.
  • Terraform destroy the instance and the temporary image.

We used continue-on-error: true in the steps that might fail to ensure terraform correctly removes the image

@bidoubiwa bidoubiwa force-pushed the add_test_ci branch 3 times, most recently from 5c056f9 to 324023c Compare April 27, 2023 15:24
@bidoubiwa bidoubiwa force-pushed the add_test_ci branch 8 times, most recently from e9f4052 to e74357e Compare April 27, 2023 16:20
@bidoubiwa bidoubiwa requested a review from alallema May 2, 2023 12:17
@bidoubiwa bidoubiwa added the skip-changelog The PR will not appear in the release changelogs label May 2, 2023
@bidoubiwa bidoubiwa marked this pull request as ready for review May 2, 2023 12:17
Copy link
Contributor

@alallema alallema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @bidoubiwa for this PR 🔥
So so great 🚀

Comment on lines 23 to 26
run: |
wget https://releases.hashicorp.com/packer/1.7.7/packer_1.7.7_linux_amd64.zip # change version
unzip packer_1.7.7_linux_amd64.zip
sudo mv packer /usr/local/bin/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run: |
wget https://releases.hashicorp.com/packer/1.7.7/packer_1.7.7_linux_amd64.zip # change version
unzip packer_1.7.7_linux_amd64.zip
sudo mv packer /usr/local/bin/
uses: hashicorp/setup-packer@main
with:
version: ${{ env.PACKER_VERSION }}

Is there a reason for not using the Packer Github action directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I tried initially but it didn't work. I can try again though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth spending too much time on it - if it works with the official GitHub-action, all the better, otherwise, let's keep what works for now.

.github/workflows/test.yml Outdated Show resolved Hide resolved
Comment on lines +6 to +7
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' --max-time 5 http://$PUBLIC_IP)" != "200" ]; do
sleep 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add a echo -n "." before the sleep 5, that way, we have a visual during the process. But I'm not sure it's will be visible on github-action

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about echo "Pinging the server..." ?

PUBLIC_IP=$1
start_time=$(date +%s)

while [ "$(curl -s -o /dev/null -w ''%{http_code}'' --max-time 5 http://$PUBLIC_IP)" != "200" ]; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use the command -o /dev/null to capture output if you're going to send it to /dev/null? If you want to avoid having it printed in the terminal, the -s silent option is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a copypasta from chatgpt 😅 Good catch

Comment on lines 6 to 13
# Check if the variable content is equal to '{"status":"available"}'
if [ "$status" != '{"status":"available"}' ]; then
# If not, echo the variable value and an error message, and exit with code 1
echo "Error: Meilisearch is not running correctly."
echo "Server response: $status"
exit 1
else
# If it is equal, echo a success message and exit with code 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's better to comment on your code, but I don't think comments here do much.

terraform-config.tf Show resolved Hide resolved
Comment on lines +43 to +48
run: |
sudo apt-get update
sudo apt-get install -y curl unzip
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install -y terraform
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run: |
sudo apt-get update
sudo apt-get install -y curl unzip
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install -y terraform
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.7

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here for Terraform? Maybe we can use both simultaneously ...

id = "sg-037fd498b332442c1"
}

resource "aws_instance" "test" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are predefined types, otherwise, you could change test by github_action_test or CI_test or something maybe more precise WDYT?

@alallema
Copy link
Contributor

alallema commented Sep 5, 2023

Due to the reduced availability of the team that takes care of this repo. The team will never have time to complete this PR, so I'm closing it.

@alallema alallema closed this Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog The PR will not appear in the release changelogs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement github-action workflow 2 - Build and Test the image
2 participants