Commit 72f6ab3a authored by Ruben ten Hove's avatar Ruben ten Hove
Browse files

feat: version pin check job

parent 81820922
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -30,3 +30,21 @@ variables:
    VARIABLE_KEY=VARIABLE_VALUE
    VARIABLE_KEY2=VARIABLE_VALUE2
```

## Version pin check

To ensure versions are pinned using variables, you can extend the
`.version-pinning` job to check if a variable is set. For example:

```yaml
include:
  - remote: https://jobs.just-ci.dev/v6.28.4/project-automation/version-pin-check.yml

PIN-VERSION:PYVERSION:
  extends: .version-pin-check
  rules:
    - if: '$I_DONT_PIN_MY_VERSIONS == null && $PYVERSION !~ /^3\.[0-9]{1,2}.*$/'
```

> Ensure the job name has the variable name after the first `:` for the message
> to be correct.
+14 −0
Original line number Diff line number Diff line
---
.version-pin-check:
  image: docker.io/bash:latest
  stage: .pre
  variables:
    GIT_STRATEGY: none
  script:
    - |
      VAR_NAME=$(echo "${CI_JOB_NAME}" | cut -d':' -f2-)
      if [ "${VAR_NAME}" != "" ]; then
        echo "${VAR_NAME} is not pinned (correctly) and is currently set to ${!VAR_NAME}."
      fi
    - exit 1
  allow_failure: true
+6 −16
Original line number Diff line number Diff line
---
include:
  - local: project-automation/version-pin-check.yml

variables:
  PYVERSION: slim
  PYTHON_EXCLUDE_PATHS: tests,setup.py,migrations
@@ -47,20 +50,7 @@ image:
      - pip-log.txt
    when: always

python:PIN-VERSION:
  image: docker.io/alpine:latest
  stage: .pre
  variables:
    GIT_STRATEGY: none
  script:
    - |
      echo "PYVERSION is set to '${PYVERSION}'. You should pin your python
      version for these jobs based on the python version chosen for your
      package."
      echo "For example 'PYVERSION: 3.10-slim'"
      echo "You can disable this warning by setting the variable
      I_DONT_PIN_MY_VERSIONS."
    - exit 1
  allow_failure: true
PIN-VERSION:PYVERSION:
  extends: .version-pin-check
  rules:
    - if: '$I_DONT_PIN_MY_VERSIONS == null && $PYVERSION !~ /^3\.[0-9]{1,2}.*$/'
    - if: $PYVERSION !~ /^3\.[0-9]{1,2}.*$/