Commit aaeed4f9 authored by Cédric OLIVIER's avatar Cédric OLIVIER
Browse files

feat: Initialize SQLFluff template

parent 2a4a00a8
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -9,10 +9,10 @@ include:
    ref: 'master'
    file: '/templates/validation.yml'
  - project: 'to-be-continuous/bash'
    ref: '2.0.0'
    ref: '3.0.1'
    file: 'templates/gitlab-ci-bash.yml'
  - project: 'to-be-continuous/semantic-release'
    ref: '2.0.2'
    ref: '3.0.0'
    file: '/templates/gitlab-ci-semrel.yml'

stages:
@@ -20,7 +20,7 @@ stages:
  - publish

variables:
  GITLAB_CI_FILES: "templates/gitlab-ci-xxx.yml"
  GITLAB_CI_FILES: "templates/gitlab-ci-sqlfluff.yml"
  BASH_SHELLCHECK_FILES: "*.sh"

semantic-release:
+16 −72
Original line number Diff line number Diff line
# GitLab CI template for XXX
# GitLab CI template for SQLFluff

This project implements a generic GitLab CI template for [XXX](https://link.to.tool.com/).
This project implements a generic GitLab CI template for [SQLFluff](https://docs.sqlfluff.com).

It provides several features, usable in different modes (by configuration).

@@ -10,92 +10,36 @@ In order to include this template in your project, add the following to your `gi

```yaml
include:
  - project: 'to-be-continuous/xxx'
  - project: 'to-be-continuous/sqlfluff'
    ref: '1.0.0'
    file: '/templates/gitlab-ci-xxx.yml'
    file: '/templates/gitlab-ci-sqlfluff.yml'
```

## Global configuration

The XXX template uses some global configuration used throughout all jobs.
The SQLFluff template uses some global configuration used throughout all jobs.


| Name                  | description                            | default value     |
| --------------------- | -------------------------------------- | ----------------- |
| `XXX_IMAGE`           | The Docker image used to run XXX       | `xxx:latest` |
| `SQLFLUFF_IMAGE`      | The Docker image used to run SQLFluff  | `sqlfluff/sqlfluff:latest`   |
| `SQLFLUFF_WORKING_DIR`| SQLFluff working directory, scope of configuration and sql files used | `.` |

sqlfluff needs to set a [dialect](https://docs.sqlfluff.com/en/stable/dialects.html) you can do it by setting `SQLFLUFF_LINT_ARGS` to `--dialect my_dialect` or provide a [configuration file](https://docs.sqlfluff.com/en/stable/configuration.html) in your repository.

If there is no configuration file in `SQLFLUFF_WORKING_DIR`, [default configuration](https://docs.sqlfluff.com/en/stable/configuration.html#defaultconfig) is used.

## Jobs

### `xxx-build` job
### `sqlfluff-lint` job

This job performs **build and tests** at once.
This job performs a [lint](https://docs.sqlfluff.com/en/stable/cli.html#sqlfluff-lint) analysis of your `SQL` code

It uses the following variable:

| Name                  | description                              | default value     |
| --------------------- | ---------------------------------------- | ----------------- |
| `XXX_BUILD_ARGS`      | Arguments used by the build job          | `build --with-default-args` |

### SonarQube analysis

If you're using the SonarQube template to analyse your XXX code, here are 2 sample `sonar-project.properties` files.

```properties
# see: https://docs.sonarqube.org/latest/analysis/languages/xxx/
# set your source directory(ies) here (relative to the sonar-project.properties file)
sonar.sources=.
# exclude unwanted directories and files from being analysed
sonar.exclusions=output/**,**/*_test.xxx

# set your tests directory(ies) here (relative to the sonar-project.properties file)
sonar.tests=.
sonar.test.inclusions=**/*_test.xxx

# tests report (TODO)
sonar.xxx.testExecutionReportPaths=reports/sonar_test_report.xml
# coverage report (TODO)
sonar.xxx.coverage.reportPaths=reports/coverage.cov
```

More info:

* [XXX language support](https://docs.sonarqube.org/latest/analysis/languages/xxx/)
* [test coverage & execution parameters](https://docs.sonarqube.org/latest/analysis/coverage/)
* [third-party issues](https://docs.sonarqube.org/latest/analysis/external-issues/)

### `xxx-lint` job

This job performs a [lint](link-to-the-tool) analysis of your code, mapped to the `build` stage.

It uses the following variables:

| Name                  | description                                | default value     |
| --------------------- | ------------------------------------------ | ----------------- |
| `XXX_LINT_IMAGE`      | The Docker image used to run the lint tool | `xxx-lint:latest` |
| `XXX_LINT_ARGS`       | Lint [options and arguments](link-to-the-cli-options) | `--serevity=medium` |

### `xxx-depcheck` job

This job enables a manual [dependency check](link-to-the-tool) analysis of your code, mapped to the `test` stage.

It uses the following variables:

| Name                  | description                                | default value     |
| --------------------- | ------------------------------------------ | ----------------- |
| `XXX_DEPCHECK_IMAGE`  | The Docker image used to run the dependency check tool | `xxx-depcheck:latest` |
| `XXX_DEPCHECK_ARGS`   | Dependency check [options and arguments](link-to-the-cli-options) | _none_ |

### `xxx-publish` job

This job is **disabled by default** and performs a publish of your built binaries.

It uses the following variables:

| Name                  | description                            | default value     |
| --------------------- | -------------------------------------- | ----------------- |
| `XXX_PUBLISH_ENABLED` | Variable to enable the publish job     | _none_ (disabled) |
| `XXX_PUBLISH_ARGS`    | Arguments used by the publish job      | `publish --with-default-args` |
| :lock: `XXX_PUBLISH_LOGIN` | Login to use to publish           | **has to be defined** |
| :lock: `XXX_PUBLISH_PASSWORD` | Password to use to publish     | **has to be defined** |
| `SQLFLUFF_LINT_ARGS`  | Lint [options and arguments](https://docs.sqlfluff.com/en/stable/cli.html#sqlfluff-lint) | _none_ |

### Secrets management

bumpversion.sh

100644 → 100755
+0 −0

File mode changed from 100644 to 100755.

+13 −69
Original line number Diff line number Diff line
{
  "name": "XXX",
  "description": "GitLab CI template for XXX",
  "template_path": "templates/gitlab-ci-xxx.yml",
  "kind": "build",
  "name": "SQLFluff lint",
  "description": "GitLab CI template for [SQLFluff lint](https://docs.sqlfluff.com) analysis",
  "template_path": "templates/gitlab-ci-sqlfluff.yml",
  "kind": "analyse",
  "variables": [
    {
      "name": "XXX_IMAGE",
      "description": "The Docker image used to run XXX",
      "default": "xxx:1.2.3"
      "name": "SQLFLUFF_IMAGE",
      "description": "The Docker image used to run SQLFluff",
      "default": "sqlfluff/sqlfluff:latest"
    },
    {
      "name": "XXX_BUILD_ARGS",
      "description": "Arguments used by the build job",
      "default": "build --with-default-args",
      "name": "SQLFLUFF_WORKING_DIR",
      "description": "Sqlfluff working directory, scope of configuration and sql files used",
      "default": ".",
      "advanced": true
    }
  ],
  "features": [
    {
      "id": "lint",
      "name": "XXX lint",
      "description": "[XXX lint](link-to-the-tool) analysis",
      "variables": [
        {
          "name": "XXX_LINT_IMAGE",
          "description": "The Docker image used to run the lint tool",
          "default": "xxx-lint:latest"
        },
        {
          "name": "XXX_LINT_ARGS",
          "description": "Lint [options and arguments](link-to-the-cli-options)",
          "default": "--serevity=medium",
          "advanced": true
        }
      ]
    },
    {
      "id": "depcheck",
      "name": "XXX dependency check",
      "description": "[XXX dependency check](link-to-the-tool) analysis",
      "variables": [
        {
          "name": "XXX_DEPCHECK_IMAGE",
          "description": "The Docker image used to run the dependency check tool",
          "default": "xxx-depcheck:latest"
    },
    {
          "name": "XXX_DEPCHECK_ARGS",
          "description": "Dependency check [options and arguments](link-to-the-cli-options)",
      "name": "SQLFLUFF_LINT_ARGS",
      "description": "Lint [options and arguments](https://docs.sqlfluff.com/en/stable/cli.html#sqlfluff-lint)",
      "advanced": true
    }
  ]
    },
    {
      "id": "publish",
      "name": "Publish",
      "description": "Publish your package to a repository",
      "enable_with": "XXX_PUBLISH_ENABLED",
      "variables": [
        {
          "name": "XXX_PUBLISH_ARGS",
          "description": "Arguments used by the publish job",
          "default": "publish --with-default-args",
          "advanced": true
        },
        {
          "name": "XXX_PUBLISH_LOGIN",
          "description": "Login to use to publish",
          "secret": true
        },
        {
          "name": "XXX_PUBLISH_PASSWORD",
          "description": "Password to use to publish",
          "secret": true
        }
      ]
    }
  ]
}
+16.8 KiB (27.7 KiB)
Loading image diff...
Loading