Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
.gitlab-ci.yml 2.03 KiB
---
stages:
  - check
  - build
  - test

default:
  tags:
    - docker
  image: registry.esss.lu.se/ics-docker/centos-e3:$E3_CI_DOCKER_VERSION


### stage: check

run pre-commit:
  stage: check
  image: registry.esss.lu.se/ics-docker/pre-commit:latest
  script:
    - pre-commit run --all-files
  allow_failure: true

shellcheck:
  image: pipelinecomponents/shellcheck:latest
  stage: check
  before_script:
    - shellcheck --version
  script:
    # anything ending on .*sh, should be shell script
    - |
      find . -name .git -type d -prune -o -type f -name \*.\*sh -print0 |
      xargs -0 -P $(nproc) -r -n1 shellcheck --format=gcc -x
    # magic, any file with a valid shebang should be scanned aswell
    - |
      find . -name .git -type d -prune -o -type f -regex '.*/[^.]*$' -print0 |
      xargs -0 -P $(nproc) -r -n1 sh -c 'FILE="$0"; if head -n1 "$FILE" |grep -q "^#\\! \?/.\+\(ba|d|k\)\?sh" ; then shellcheck "$FILE" --format=gcc -x ; else /bin/true ; fi '

shfmt:
  image: mvdan/shfmt:v3.2.0-alpine
  stage: check
  before_script:
    - shfmt -version
  script:
    - shfmt -i 2 -ci -d .  # 2 spaces indent, indent switch-case statements, show diff (don't apply change)

build require:
  stage: build
  before_script:
    - curl -L -o epics.tar.gz https://artifactory.esss.lu.se/artifactory/e3/epics-base-$E3_CI_BASE_VERSION.tar.gz
    - tar -zxvf epics.tar.gz
    - export BASE_PATH=$(ls -d $(pwd)/epics/base-*)
    - echo "EPICS_BASE:=${BASE_PATH}" >> configure/RELEASE.local
    - echo "E3_REQUIRE_VERSION:=${CI_COMMIT_SHORT_SHA}" >> configure/CONFIG_MODULE.local
    - chmod +w "${BASE_PATH}"/configure/CONFIG_SITE
    - echo 'INSTALL_LOCATION:=$(TOP)' >> "${BASE_PATH}"/configure/CONFIG_SITE
    - export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${BASE_PATH}/lib/linux-x86_64"
    - make vars
  script:
    - make build
    - make install
  artifacts:
    paths:
      - epics
      - configure/*.local

test require:
  stage: test
  before_script:
    - source $(pwd)/epics/base-*/require/*/bin/setE3Env.bash
  script:
    - make test