Commit ec5ef9cb authored by GridexX's avatar GridexX
Browse files

Merge branch '643-new-job-codespell' into 'latest'

Resolve "[New job] - Codespell"

Closes #643

See merge request r2devops/hub!407
parents 847822ba 31783014
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
# Changelog
All notable changes to this job will be documented in this file.

## [0.1.0] - 2022-09-22
* Initial version
 No newline at end of file
+26 −0
Original line number Diff line number Diff line
## Objective

Fix common misspellings inside your code with [codespell](https://github.com/codespell-project/codespell). This job can be used out of the box and doesn't need any configuration.

## How to use it

1. Copy the job URL located in the `Install` part of the right panel and add it inside the `include` list of your `.gitlab-ci.yml` file (see the [quick setup](/use-the-hub/#quick-setup)). You can specify [a fixed version](#changelog) instead of `latest`.
1. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/use-the-hub/#jobs-customization)
1. Well done, your job is ready to work ! 😀

## Variables

| Name | Description | Default |
| ---- | ----------- | ------- |
| `CODESPELL_DICTIONARY` <img width=100/> | The dictionary file to ignore some words from the analyze. Check the behavior below 👇 <img width=175/> | `dictionary.txt` <img width=100/> |
| `CODESPELL_IGNORE_FILES` | Ignore files from the analyze. Separate each file with a space | ` ` |
| `CODESPELL_VERSION` | The version of codespell to install. Check out the [releases](https://github.com/codespell-project/codespell/releases) | `3.10-alpine3.16` |
| `IMAGE_TAG` | The default tag for the docker image | `3.10-alpine3.16` |

   !!! info "How to write your dictionary ? 📗"
   Write one word per line in **lowercase** inside your `dictionary.txt` file at the root of the repository.  
   If you want to place the file in a specific folder, you can specify the path with the `CODESPELL_DICTIONARY` variable. 

## Author
This resource is an **[official job](https://docs.r2devops.io/faq-labels/)** added in [**R2Devops repository**](https://gitlab.com/r2devops/hub) by [@GridexX](https://gitlab.com/GridexX)
+31 −0
Original line number Diff line number Diff line
# Job from R2Devops hub --> r2devops.io

stages:
  - tests

codespell:
  stage: tests
  image:
    name: python:${IMAGE_TAG}
    entrypoint: [""]
  variables:
    CODESPELL_DICTIONARY: "dictionary.txt"
    #separate each file to ignore with a space
    CODESPELL_IGNORE_FILES: ""
    CODESPELL_VERSION: "2.2.1"
    IMAGE_TAG: "3.10-alpine3.16"
  script:
    - pip install -q codespell===${CODESPELL_VERSION}
    - |
      IGNORE_FILES_OPTION=""
      for file in ${CODESPELL_IGNORE_FILES}; do
        IGNORE_FILES_OPTION="${IGNORE_FILES_OPTION} -x $file"
      done
    - |
      if [ -f ${CODESPELL_DICTIONARY} ]; then
        DICTIONARY_OPTION="-I ${CODESPELL_DICTIONARY}"
      else
        DICTIONARY_OPTION=""
        echo "No dictionary file found"
      fi
    - codespell -c ${DICTIONARY_OPTION} ${IGNORE_FILES_OPTION}