Exadra37 / elixir-scribe

The Elixir Scribe tool aims to help developers to embody the values of discipline and craftsmanship of the Scribes, enabling them to more easily write clean code in a clean software architecture for enhanced developer experience and productivity.
https://exadra37.com
MIT License
39 stars 1 forks source link

Generates a CI file for Github or Gitlab #3

Open matheuscamarques opened 5 days ago

matheuscamarques commented 5 days ago

Objective:

Create CI (Continuous Integration) files for GitHub and GitLab that include the basic steps for running code quality and security checks in an Elixir project.

Basic Steps to Run:

  1. mix format --dry-run --check-formatted: Check if the code is formatted according to the defined rules.
  2. mix deps.unlock --check-unused: Check for unused dependencies.
  3. mix deps.audit: Audit dependencies for known vulnerabilities.
  4. mix hex.audit: Audit Hex packages for vulnerabilities.
  5. mix sobelow: Run security checks on the code.
  6. mix credo: Run static analysis and check code for style compliance.
  7. mix doctor: Evaluate code documentation.
  8. mix test --cover: Run unit tests and generate a code coverage report.

Functional Requirements:

See Other Approaches:

Useful Resources and References

GitHub Actions:

  1. Official GitHub Actions Documentation: GitHub Actions Documentation
  2. Tutorial on GitHub Actions for Elixir: Elixir CI with GitHub Actions

GitLab CI/CD:

  1. Official GitLab CI/CD Documentation: GitLab CI/CD Documentation
  2. Setting Up GitLab CI/CD for Elixir Projects: Setting Up GitLab CI/CD for Elixir Projects

BitBucket Pipelines:

  1. Official BitBucket Pipelines Documentation: BitBucket Pipelines Documentation
  2. Example CI for Elixir on BitBucket: Example CI for Elixir on BitBucket

Other CI File Patterns:

  1. CircleCI for Elixir Projects: CircleCI Configuration for Elixir Projects
  2. Travis CI for Elixir Projects: Travis CI Configuration for Elixir Projects

CI File Examples

GitHub Actions (.github/workflows/ci.yml):

name: CI

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Elixir
      uses: actions/setup-elixir@v1
      with:
        otp-version: '23.0'
        elixir-version: '1.11.2'
    - name: Install dependencies
      run: mix deps.get
    - name: Run format check
      run: mix format --dry-run --check-formatted
    - name: Check unused dependencies
      run: mix deps.unlock --check-unused
    - name: Audit dependencies
      run: mix deps.audit
    - name: Audit Hex packages
      run: mix hex.audit
    - name: Run Sobelow security checks
      run: mix sobelow
    - name: Run Credo code analysis
      run: mix credo
    - name: Evaluate documentation
      run: mix doctor
    - name: Run tests with coverage
      run: mix test --cover

GitLab CI (.gitlab-ci.yml):

stages:
  - check
  - test

check:
  stage: check
  image: elixir:1.11.2
  script:
    - mix local.hex --force
    - mix deps.get
    - mix format --dry-run --check-formatted
    - mix deps.unlock --check-unused
    - mix deps.audit
    - mix hex.audit
    - mix sobelow
    - mix credo
    - mix doctor

test:
  stage: test
  image: elixir:1.11.2
  script:
    - mix local.hex --force
    - mix deps.get
    - mix test --cover

These examples provide a solid foundation for setting up continuous integration using GitHub Actions and GitLab CI/CD for Elixir projects. To adapt these files for BitBucket or other CI tools, consult the specific documentation and adjust accordingly.

Exadra37 commented 3 days ago

Thanks for taking the time to create a very detailed issue :)

I am planning to add the CI files when I tackle the mix scribe.gen.ci, as per the Roadmap, but I am happy to accept a PR from you with just the CI files.

On a future release I will add the generators based on these CI files.