{"id":28881989,"url":"https://github.com/ronihdzz/git-archive-action-testing-example","last_synced_at":"2026-04-11T02:02:02.268Z","repository":{"id":287766986,"uuid":"965726287","full_name":"ronihdzz/git-archive-action-testing-example","owner":"ronihdzz","description":"This repository demonstrates how the ronihdzz/git-archive-action integrates into a complex and realistic CI/CD workflow. This project showcases a complete use case where integration tests run against multiple services (PostgreSQL, MongoDB, Redis), generate coverage reports within a Docker container, and finally use the Action to persist these repor","archived":false,"fork":false,"pushed_at":"2025-06-10T06:04:48.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-10T06:30:43.965Z","etag":null,"topics":["ci-cd","demo","devops","docker","example","github-actions","mongodb","postgresql","redis","testing"],"latest_commit_sha":null,"homepage":"https://ronihdz.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ronihdzz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-13T19:21:46.000Z","updated_at":"2025-06-10T06:03:31.000Z","dependencies_parsed_at":"2025-06-10T06:40:49.558Z","dependency_job_id":null,"html_url":"https://github.com/ronihdzz/git-archive-action-testing-example","commit_stats":null,"previous_names":["ronihdzz/testing-actions-coverage","ronihdzz/git-archive-action-testing-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ronihdzz/git-archive-action-testing-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronihdzz%2Fgit-archive-action-testing-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronihdzz%2Fgit-archive-action-testing-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronihdzz%2Fgit-archive-action-testing-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronihdzz%2Fgit-archive-action-testing-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ronihdzz","download_url":"https://codeload.github.com/ronihdzz/git-archive-action-testing-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronihdzz%2Fgit-archive-action-testing-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261014123,"owners_count":23097179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci-cd","demo","devops","docker","example","github-actions","mongodb","postgresql","redis","testing"],"created_at":"2025-06-20T20:41:51.077Z","updated_at":"2026-04-11T02:02:01.866Z","avatar_url":"https://github.com/ronihdzz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git Archive Action - Testing Example\n\n[English](#english) | [Español](#español)\n\n---\n\n## English\n\n### Showcase: Example Project in Action\n\nThis repository demonstrates how the [ronihdzz/git-archive-action](https://github.com/ronihdzz/git-archive-action) integrates into a complex and realistic CI/CD workflow. This project showcases a complete use case where integration tests run against multiple services (PostgreSQL, MongoDB, Redis), generate coverage reports within a Docker container, and finally use the Action to persist these reports.\n\n| CI Environment | Coverage |\n|-----------|----------|\n| main| ![Coverage Badge](https://github.com/ronihdzz/testing-actions-coverage/blob/artifacts/main/latest/coverage.svg) |\n| development| ![Coverage Badge](https://github.com/ronihdzz/testing-actions-coverage/blob/artifacts/development/latest/coverage.svg) |\n\n### Example Project Workflow\n\nBelow is the workflow code used in this project:\n\n```yaml\nname: Run Tests\n\non:\n  push:\n    branches: [main,development]\n\npermissions:\n  contents: write\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    env:\n      COVERAGE_REPORTS: coverage-reports\n    services:\n      postgres:\n        image: postgres:13\n        env:\n          POSTGRES_USER: test\n          POSTGRES_PASSWORD: test\n          POSTGRES_DB: test_db\n        ports: ['5432:5432']\n        options: \u003e-\n          --health-cmd=\"pg_isready\" --health-interval=10s --health-timeout=5s --health-retries=5\n      mongodb:\n        image: mongo:4.4\n        ports: ['27017:27017']\n        options: \u003e-\n          --health-cmd=\"mongo --eval 'db.runCommand({ ping: 1 })'\" --health-interval=10s --health-timeout=5s --health-retries=5\n      redis:\n        image: redis:6\n        ports: ['6379:6379']\n        options: \u003e-\n          --health-cmd=\"redis-cli ping\" --health-interval=10s --health-timeout=5s --health-retries=5\n    steps:\n      - name: 🧾 Checkout code\n        uses: actions/checkout@v3\n\n      - name: 🏗️ Build test image\n        run: docker build --progress=plain -t my-test-image -f docker_images/testing/Dockerfile.testing .\n\n      - name: 🚀 Run tests in container\n        run: |\n          docker run \\\n            --name my-tests \\\n            --network=host \\\n            -e CI=true \\\n            -e GITHUB_DATABASE_POSTGRESQL=postgres://test:test@localhost:5432/test_db \\\n            -e GITHUB_DATABASE_MONGODB=mongodb://localhost:27017 \\\n            -e GITHUB_DATABASE_REDIS=redis://localhost:6379 \\\n            -v ${{ github.workspace }}/artifacts:/app/artifacts \\\n            my-test-image\n\n      - name: 📥 Copy reports from container\n        run: |\n          mkdir -p ${{ env.COVERAGE_REPORTS }}\n          docker cp my-tests:/app/coverage-reports/. ${{ env.COVERAGE_REPORTS }}\n          echo \"📄 Files copied from container:\"\n          ls -lh ${{ env.COVERAGE_REPORTS }}\n          \n      - name: 📤 Upload coverage as artifact\n        uses: actions/upload-artifact@v4\n        with:\n          name: ${{ env.COVERAGE_REPORTS }}\n          path: ${{ env.COVERAGE_REPORTS }}\n\n      - name: Save coverage\n        uses: ronihdzz/git-archive-action@v3\n        with:\n          gh-token: ${{ secrets.GITHUB_TOKEN }}\n          artifacts-branch: 'artifacts'\n          coverage-source: ${{ env.COVERAGE_REPORTS }}\n          is-artifact: false\n```\n\n### Detailed Explanation of the Real Flow\n\n1. **services**: The workflow defines three services (PostgreSQL, MongoDB, and Redis) that start alongside the job. Thanks to health-checks, test steps won't begin until these databases are ready to accept connections, simulating a production environment.\n\n2. **Build test image**: A Docker image specific for testing is built. This encapsulates all project dependencies and ensures a consistent testing environment.\n\n3. **Run tests in container**: The test container is executed with:\n   - `--network=host`: Allows the container to communicate with database services running on the runner through localhost\n   - `-e ...`: Database connection strings are injected as environment variables\n\n4. **Copy reports from container**: This is a critical step. Once tests finish inside the container, generated reports exist only within that container's file system. The `docker cp` command extracts these reports from the container (`my-tests:/app/coverage-reports/.`) to the GitHub runner's file system (`${{ env.COVERAGE_REPORTS }}`), making them accessible for subsequent steps.\n\n5. **Upload coverage as artifact**: This step uses the official `upload-artifact` Action to upload reports to the workflow's \"Artifacts\" section in GitHub UI. This is useful for quick review and manual downloads.\n\n6. **Save coverage**: Finally, our Action is called:\n   - `uses: ronihdzz/git-archive-action@v3`: Executes the Action to persist reports\n   - `coverage-source: ${{ env.COVERAGE_REPORTS }}`: Indicates the folder path containing reports (same folder created in \"Copy reports...\" step)\n   - `is-artifact: false`: Important to note it's set to `false`. Although the previous step uploaded an artifact, our Action is working with the local folder extracted from the container with `docker cp`. This demonstrates the Action's flexibility to work directly with files on the runner.\n\n---\n\n## Español\n\n### Showcase: Proyecto de Ejemplo en Acción\n\nEste repositorio demuestra cómo la [ronihdzz/git-archive-action](https://github.com/ronihdzz/git-archive-action) se integra en un flujo de trabajo de CI/CD complejo y realista. Este proyecto muestra un caso de uso completo donde las pruebas de integración se ejecutan contra múltiples servicios (PostgreSQL, MongoDB, Redis), se generan reportes de cobertura dentro de un contenedor Docker, y finalmente se utiliza la Action para persistir dichos reportes.\n\n| Entorno CI | Cobertura |\n|-----------|----------|\n| main| ![Coverage Badge](https://github.com/ronihdzz/testing-actions-coverage/blob/artifacts/main/latest/coverage.svg) |\n| development| ![Coverage Badge](https://github.com/ronihdzz/testing-actions-coverage/blob/artifacts/development/latest/coverage.svg) |\n\n### Workflow del Proyecto de Ejemplo\n\nA continuación se muestra el código del workflow utilizado en el proyecto:\n\n```yaml\nname: Run Tests\n\non:\n  push:\n    branches: [main,development]\n\npermissions:\n  contents: write\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    env:\n      COVERAGE_REPORTS: coverage-reports\n    services:\n      postgres:\n        image: postgres:13\n        env:\n          POSTGRES_USER: test\n          POSTGRES_PASSWORD: test\n          POSTGRES_DB: test_db\n        ports: ['5432:5432']\n        options: \u003e-\n          --health-cmd=\"pg_isready\" --health-interval=10s --health-timeout=5s --health-retries=5\n      mongodb:\n        image: mongo:4.4\n        ports: ['27017:27017']\n        options: \u003e-\n          --health-cmd=\"mongo --eval 'db.runCommand({ ping: 1 })'\" --health-interval=10s --health-timeout=5s --health-retries=5\n      redis:\n        image: redis:6\n        ports: ['6379:6379']\n        options: \u003e-\n          --health-cmd=\"redis-cli ping\" --health-interval=10s --health-timeout=5s --health-retries=5\n    steps:\n      - name: 🧾 Checkout code\n        uses: actions/checkout@v3\n\n      - name: 🏗️ Build test image\n        run: docker build --progress=plain -t my-test-image -f docker_images/testing/Dockerfile.testing .\n\n      - name: 🚀 Run tests in container\n        run: |\n          docker run \\\n            --name my-tests \\\n            --network=host \\\n            -e CI=true \\\n            -e GITHUB_DATABASE_POSTGRESQL=postgres://test:test@localhost:5432/test_db \\\n            -e GITHUB_DATABASE_MONGODB=mongodb://localhost:27017 \\\n            -e GITHUB_DATABASE_REDIS=redis://localhost:6379 \\\n            -v ${{ github.workspace }}/artifacts:/app/artifacts \\\n            my-test-image\n\n      - name: 📥 Copiar reportes desde el contenedor\n        run: |\n          mkdir -p ${{ env.COVERAGE_REPORTS }}\n          docker cp my-tests:/app/coverage-reports/. ${{ env.COVERAGE_REPORTS }}\n          echo \"📄 Archivos copiados desde el contenedor:\"\n          ls -lh ${{ env.COVERAGE_REPORTS }}\n          \n      - name: 📤 Subir cobertura como artefacto\n        uses: actions/upload-artifact@v4\n        with:\n          name: ${{ env.COVERAGE_REPORTS }}\n          path: ${{ env.COVERAGE_REPORTS }}\n\n      - name: Guardar coverage\n        uses: ronihdzz/git-archive-action@v3\n        with:\n          gh-token: ${{ secrets.GITHUB_TOKEN }}\n          artifacts-branch: 'artifacts'\n          coverage-source: ${{ env.COVERAGE_REPORTS }}\n          is-artifact: false\n```\n\n### Explicación Detallada del Flujo Real\n\n1. **services**: El workflow define tres servicios (PostgreSQL, MongoDB y Redis) que se inician junto con el job. Gracias a los health-checks, los pasos de prueba no comenzarán hasta que estas bases de datos estén listas para aceptar conexiones, simulando un entorno de producción.\n\n2. **Build test image**: Se construye una imagen de Docker específica para las pruebas. Esto encapsula todas las dependencias del proyecto y garantiza un entorno de prueba consistente.\n\n3. **Run tests in container**: Se ejecuta el contenedor de pruebas con:\n   - `--network=host`: Permite que el contenedor se comunique con los servicios de bases de datos que se ejecutan en el runner a través de localhost\n   - `-e ...`: Se inyectan las cadenas de conexión a las bases de datos como variables de entorno\n\n4. **Copiar reportes desde el contenedor**: Este es un paso crítico. Una vez que las pruebas terminan dentro del contenedor, los reportes generados existen únicamente dentro del sistema de archivos de ese contenedor. El comando `docker cp` se utiliza para extraer esos reportes desde el contenedor (`my-tests:/app/coverage-reports/.`) hacia el sistema de archivos del runner de GitHub (`${{ env.COVERAGE_REPORTS }}`), haciéndolos accesibles para los siguientes pasos.\n\n5. **Subir cobertura como artefacto**: Este paso utiliza la Action oficial `upload-artifact` para subir los reportes a la sección de \"Artifacts\" del workflow en la UI de GitHub. Esto es útil para una revisión rápida y para descargas manuales.\n\n6. **Guardar coverage**: Finalmente, se llama a nuestra Action:\n   - `uses: ronihdzz/git-archive-action@v3`: Se ejecuta la Action para persistir los reportes\n   - `coverage-source: ${{ env.COVERAGE_REPORTS }}`: Se le indica la ruta de la carpeta que contiene los reportes (es la misma carpeta que se creó en el paso \"Copiar reportes...\")\n   - `is-artifact: false`: Es muy importante notar que se usa `false`. Aunque el paso anterior subió un artefacto, nuestra Action en este caso está trabajando con la carpeta local que fue extraída del contenedor con `docker cp`. Esto demuestra la flexibilidad de la Action para trabajar directamente con archivos en el runner.\n\n### Repositorio de la Action Principal\n\nPara más información sobre la Action utilizada en este ejemplo, visita: [ronihdzz/git-archive-action](https://github.com/ronihdzz/git-archive-action)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronihdzz%2Fgit-archive-action-testing-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fronihdzz%2Fgit-archive-action-testing-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronihdzz%2Fgit-archive-action-testing-example/lists"}