JeanCarlosChavarriaHughes / API_Hacienda

API de comunicacion con hacienda
https://crlibre.org/qa/
GNU Affero General Public License v3.0
1 stars 1 forks source link

Implement Travis CI Framework #23

Open JeanCarlosChavarriaHughes opened 4 years ago

JeanCarlosChavarriaHughes commented 4 years ago

Dado que la API Hacienda se debe mantener robusta y con calidad garantizada. La manera de lograrlo en mediante el uso de continuos integration. Dado que el proyecto es open source, se recomienda implementar Travis CI con automated tests: https://docs.travis-ci.com/user/languages/php/

JeanCarlosChavarriaHughes commented 4 months ago

Currently, the best approach is to implement the CI/CT solution with Github Actions.

Travis CI has been one of most popular CI/CD platforms among DevOps engineers for a long time but with the arrival of GitHub Actions, things are starting to get complicated. With GitHub Actions, developers no longer need to use two different interfaces for source code repositories and your CI/CD pipeline.

Main Idea:

  1. Create GitHub Actions Workflow File: Create a file named .github/workflows/ci.yml in your repository to define the GitHub Actions workflow. Similar to :

on: push: branches:

jobs: build:

runs-on: ubuntu-latest

services:
  db:
    image: mysql:latest
    env:
      MYSQL_ROOT_PASSWORD: root_password
      MYSQL_DATABASE: test_database
      MYSQL_USER: test_user
      MYSQL_PASSWORD: test_password
    ports:
      - 3306:3306

steps:
- name: Checkout repository
  uses: actions/checkout@v2

- name: Set up Docker Compose
  uses: docker/compose-action@v2
  with:
    file: docker-compose.yml

- name: Wait for services to be ready
  run: docker-compose exec -T api wait-for-it db:3306 -- echo "Database is up!"

- name: Run Java API tests
  run: |
    # Add commands to run your Java RestAssured API tests here

2. Create Docker Compose File:
Ensure your docker-compose.yml file is correctly set up to spin up the PHP API and the database services. Similar to: https://github.com/JeanCarlosChavarriaHughes/API_Hacienda/blob/develop/docker-compose.yml 

3. Write Java RestAssured Tests (or any other test language and framework).
Create your Java RestAssured API tests in the repository. Ensure the tests interact with the API endpoints and any necessary environment variables. You can use a testing framework like TestNG or JUnit.

4. Update GitHub Actions Workflow File:
Modify the Java API test execution step in the workflow file to run your actual test commands. Similar to:
```- name: Run Java API tests
  run: |
    # Add commands to run your Java RestAssured API tests here
    ./gradlew test # or any other command to execute your tests
  1. Commit and Push: Commit the changes to your repository and push them to the develop branch. This will trigger the GitHub Actions workflow.

  2. Monitor Workflow Execution: Visit the "Actions" tab in your GitHub repository to monitor the progress and logs of the workflow. Any failures or issues will be reported there.