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

Generates a CI file for Github or Gitlab #3

Open
matheuscamarques opened this issue Jul 3, 2024 · 1 comment
Open

Generates a CI file for Github or Gitlab #3

matheuscamarques opened this issue Jul 3, 2024 · 1 comment

Comments

@matheuscamarques
Copy link

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:

  • Generate CI file for GitHub.
  • Generate CI file for GitLab.

See Other Approaches:

  • Generate CI file for BitBucket.
  • Other CI file patterns.

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
Copy link
Collaborator

Exadra37 commented Jul 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants