Skip to content
Snippets Groups Projects
.gitlab-ci.yml 6.99 KiB
Newer Older
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
# Stages run in sequential order, but jobs within stages run in parallel.
#
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages
#
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml

before_script:
#git checkout "$CI_COMMIT_REF_NAME"
  - git status

variables:
  TARBALL: /home/gitlab-runner/${CI_PROJECT_NAME}-${CI_COMMIT_BRANCH}.pax
  TARBALL_EXTRA: /home/gitlab-runner/${CI_PROJECT_NAME}-${CI_COMMIT_BRANCH}.ST11xM.pax

stages:          # List of stages for jobs, and their order of execution
  - build
  - test
  - deploy
  - release

build-job:       # This job runs in the build stage, which runs first.
  stage: build
  tags:
    - build
  script:
    - echo "Build gcobol in focal-amd64 chroot..."
    - touch $TARBALL
    - rm -v $TARBALL
    - printf "Compiling the code \nfrom\t%s \nto\t%s\n" $PWD $PWD/build
    - schroot -c focal-amd64 --
      gcc/cobol/scripts/release-configure-build 'commit-release' -s -j12
    - find build -name gcobol -or -name cobol1 -or -name libgcobol.so
    - pax -x cpio -wf $TARBALL build
    - ls -i   $TARBALL
    - ls -l   $TARBALL
    - md5sum  $TARBALL
    - echo "Compile complete."

build-arm:       # This job runs in the build stage, which runs first.
  stage: build
  tags:
    - arm
  script:
    - printf "NOT Compiling the code \nfrom\t%s \nto\t%s\n" $PWD $PWD/build
    - echo gcc/cobol/scripts/release-configure-build -s -j12
    - echo find build -name gcobol -or -name cobol1 -or -name libgcobol.so
    - echo pax -x cpio -wf $TARBALL build
    - echo "Compile complete."

local-test-job:   # This job runs in the test stage.
  stage: test    # It only starts when the job in the build stage completes successfully.
  tags:
    - test
  script:
    - md5sum  $TARBALL
    - test -r build || pax -rf $TARBALL
    - echo "Local tests in focal-amd64 chroot..."
    - schroot -c focal-amd64 --
James K. Lowden's avatar
James K. Lowden committed
      make -s -j12 -C gcc/cobol/tests test

local-test-arm:
  stage: test
  tags:
    - arm
  script:
    - echo test -r build || pax -rf $TARBALL
    - echo make -s -j4 -C gcc/cobol/tests test

nist-test-job:   # This job runs in the test stage.
  stage: test    # It only starts when the job in the build stage completes successfully.
  tags:
    - test
  script:
    - md5sum  $TARBALL
    - test -r build || pax -rf $TARBALL
    - echo "NIST test in focal-amd64 chroot..."
    - schroot -c focal-amd64 --
James K. Lowden's avatar
James K. Lowden committed
      make -s -j12 -C gcc/cobol/nist report
  artifacts:
    paths:
      - gcc/cobol/nist/ST/ST112M
      - gcc/cobol/nist/ST/ST112M-reel-1
      - gcc/cobol/nist/ST/ST112M.cbl
      - gcc/cobol/nist/ST/ST112M.conf
      - gcc/cobol/nist/ST/ST112M.out
      - gcc/cobol/nist/ST/ST112M.rpt
      - gcc/cobol/nist/ST/ST113M
      - gcc/cobol/nist/ST/ST113M-file-srt-1
      - gcc/cobol/nist/ST/ST113M-tape-1
      - gcc/cobol/nist/ST/ST113M.cbl
      - gcc/cobol/nist/ST/ST113M.conf
      - gcc/cobol/nist/ST/ST113M.out
      - gcc/cobol/nist/ST/ST114M
      - gcc/cobol/nist/ST/ST114M.cbl
      - gcc/cobol/nist/ST/ST114M.conf
      - gcc/cobol/nist/ST/ST114M.out
      - gcc/cobol/nist/ST/ST114M.rpt

nist-test-arm:   # This job runs in the test stage.
  stage: test    # It only starts when the job in the build stage completes successfully.
  tags:
    - arm
  script:
    - echo test -r build || pax -rf $TARBALL
    - echo make -s -C gcc/cobol/nist report

uat-test-job:
  stage: test
  tags:
    - test
  script:
    - md5sum  $TARBALL
    - test -r build/gcc/gcobol || pax -rf $TARBALL
    - echo "User Acceptance Tests in focal-amd64 chroot..."
    - export GCOBOL_BUILD_DIR=$PWD/build
    - status=0
    - schroot -p -c focal-amd64 --
James K. Lowden's avatar
James K. Lowden committed
      /usr/bin/make -j12 -C gcc/cobol/UAT test || status=$?
    - |
      if [ $status -ne 0 ]
      then
         echo 'Filtered Log:'
         log=gcobol-tests/testsuite.log
         awk 'NR==1,/Running/ { if (/Running/) {print}; next } / ok / {next} 1' $log
         echo 'Failed'
         exit $status
      fi
    - echo "Done."

#
# Deploy packages to gitlab "releases" page
#

deploy-job:      # This job runs in the deploy stage.
  stage: deploy  # It only runs when *both* jobs in the test stage complete successfully.
  environment: production
  tags:
    - general
  script:
    - echo "Packaging in focal-amd64 chroot..."
    - test -r build || pax -rf $TARBALL
    - find build -name gcobol -or -name cobol1 -or -name libgcobol.so
    - schroot -c focal-amd64 --
      /usr/bin/make -f $HOME/Makefile.pkg packages publish
              CI_JOB_TOKEN=$CI_JOB_TOKEN
              CI_API_V4_URL=${CI_API_V4_URL}
              BRANCH=$CI_COMMIT_BRANCH
              ID=${CI_PROJECT_ID}
              REPOSITORY=$PWD
              BUILDDIR=$PWD/build
              PREFIX=$HOME/stage
              PACKAGE_NAME=gcobol PACKAGE_VERSION=dev
    - echo "Done."

deploy-arm:      # This job runs in the deploy stage.
  stage: deploy  # It only runs when *both* jobs in the test stage complete successfully.
  environment: qa
  tags:
    - arm
  script:
    - echo "Deploying application..."
    - echo "Application successfully deployed."

release_commit_x86:
  stage: release
  tags:
    - general
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  rules:
    - if: $CI_COMMIT_TAG
      when: never                                  # Do not run this job when a tag is created manually
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH  # Job runs when commits are pushed or merged to the default branch
  script:
    - echo "running release_job for $TAG" in $PWD
    - echo "tag_name= 'v0.$CI_PIPELINE_IID'"
    - echo "description= 'v0.$CI_PIPELINE_IID'"
    - echo "ref= '$CI_COMMIT_SHA'"                          # The tag is created from the pipeline SHA.
  release:                                         # See https://docs.gitlab.com/ee/ci/yaml/#release for available properies
    tag_name: 'v0.$CI_PIPELINE_IID'                # The version is incremented per pipeline.
    description: 'v0.$CI_PIPELINE_IID'
    ref: '$CI_COMMIT_SHA'                          # The tag is created from the pipeline SHA.

#
# Tagged releases
#

tag_release_x86:
  stage: release
  tags:
    - general
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  rules:
    - if: $CI_COMMIT_TAG                 # Run this job when a tag is created
  script:
    - echo "running release_job"
  release:                               # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
    tag_name: '$CI_COMMIT_TAG'
    description: '$CI_COMMIT_TAG'

tag_release_arm:
  stage: release
  tags:
    - arm
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  rules:
    - if: $CI_COMMIT_TAG                 # Run this job when a tag is created
  script:
    - echo "running release_job"
  release:
    tag_name: '$CI_COMMIT_TAG'
    description: '$CI_COMMIT_TAG'