diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 730a018..ae8b5c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,15 @@ variables: - JOB_ROOT_DIR: '.' - SECURE_LOG_LEVEL: debug - GIT_SUBMODULE_STRATEGY: recursive - MY_PROJECT_ID: "28543717" - LICENSE_FINDER_CLI_OPTS: '--recursive' + JOB_ROOT_DIR: '.' + SECURE_LOG_LEVEL: debug + GIT_SUBMODULE_STRATEGY: recursive + MY_PROJECT_ID: "28543717" + LICENSE_FINDER_CLI_OPTS: '--recursive' stages: - - validation - - test - - release - - sync + - validation + - test + - release + - sync include: - local: $JOB_ROOT_DIR/yaml_lint/.gitlab-ci.yml @@ -95,37 +95,36 @@ yaml_lint Dependencies: PyLint: - extends: - - .PyLint - image: python:3.6-slim + extends: + - .PyLint + image: python:3.6-slim gilab-ci.yml Lint (python 3.11): - variables: - YAML_LINT_PATH: ".gitlab-ci* ./**/.gitlab-ci*" - YAML_LINT_EXTRA_ARGS: "{ extends: yaml_lint/.yamllint.yaml, ignore: [website-template/*] }" - extends: - - .yaml_lint_defaults - image: python:3.11-slim + variables: + YAML_LINT_PATH: ".gitlab-ci* ./**/*gitlab-ci*" + YAML_LINT_EXTRA_ARGS: "{ extends: yaml_lint/.yamllint.yaml, ignore: [website-template/*] }" + extends: + - .yaml_lint_defaults + image: python:3.11-slim Markdown Linting: variables: MDLINT_EXCLUDE_PATHS: '!website_template !.gitlab CHANGELOG.md' - extends: - .Lint_Markdown Gitlab Release: - variables: - MY_COMMAND: ./sub-folder_changlog.sh - extends: - - .gitlab_release + variables: + MY_COMMAND: ./sub-folder_changlog.sh + extends: + - .gitlab_release Github (Push --mirror): - variables: - GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/gitlab-ci.git" - extends: - - .git_push_mirror + variables: + GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/gitlab-ci.git" + extends: + - .git_push_mirror diff --git a/conventional_commits/.gitlab-ci.yml b/conventional_commits/.gitlab-ci.yml index 183d94e..a382b18 100644 --- a/conventional_commits/.gitlab-ci.yml +++ b/conventional_commits/.gitlab-ci.yml @@ -1,76 +1,76 @@ .conventional_commit: - variables: - DEFAULT_ROOT_DIR: './gitlab-ci' - image: python:3.6-slim - stage: validation - before_script: - - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" - - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests" - - if [ "0$MR_ACCESS_TOKEN" == "0" ]; then MR_ACCESS_TOKEN=$CI_JOB_TOKEN; fi - - echo "[DEBUG] MR_ACCESS_TOKEN[$MR_ACCESS_TOKEN]" - - if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=$DEFAULT_ROOT_DIR; else ROOT_DIR=$JOB_ROOT_DIR ; fi - - echo "[DEBUG] ROOT_DIR[$ROOT_DIR]" - - if [ "0$MY_PROJECT_ID" == "0" ]; then PROJECT_ID=$CI_PROJECT_ID; else PROJECT_ID=$MY_PROJECT_ID ; fi - - echo "[DEBUG] PROJECT_ID[$PROJECT_ID]" - - export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'` - - apt update - - apt install --no-install-recommends -y git - - python3 -m venv env - - . env/bin/activate - - pip install --upgrade pip - - pip install -r $ROOT_DIR/conventional_commits/requirements.txt - - echo "[DEBUG] CI_PROJECT_ID[$CI_PROJECT_ID]" - - echo "[DEBUG] CI_COMMIT_BRANCH[$CI_COMMIT_BRANCH]" - - git fetch --all - - git checkout --track origin/$CI_COMMIT_BRANCH - - git show-branch -a - - target_branch=$(git show-branch -a | awk 'BEGIN { FS="\n\s+*" } { print $1 }' | awk '{print $2}' | grep '\[' | sed 's/.*\[origin\/\(.*\)\].*/\1/' | grep -v '\[' | grep -v $(git rev-parse --abbrev-ref HEAD) | grep -vi 'HEAD' | awk 'BEGIN{ RS = "" ; FS = "\n" }{print $1}') - - echo "[DEBUG] Target Branch[$target_branch]" - - if [ -d "gitlab-ci" ]; then ls -la gitlab-ci; fi - - first_sha1=$(git log origin/$target_branch..$CI_COMMIT_BRANCH --format=format:%H | tail -1) - - echo "[DEBUG] First Commit SHA[$first_sha1]" - - echo "[DEBUG] artifacts directory [$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME]" - after_script: - - ls -lR "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE" - - cd .. - - rm -Rf check - artifacts: - expire_in: 3 days - when: always - paths: - - "$CI_PROJECT_DIR/artifacts/*" - reports: - junit: - - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml" - rules: - - if: '$JOB_STOP_CONVENTIONAL_COMMITS' - when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: '$CI_COMMIT_TAG' - when: always - - if: '$CI_COMMIT_BRANCH == "master"' - when: always - - if: '$CI_COMMIT_BRANCH' - when: always - - when: never + variables: + DEFAULT_ROOT_DIR: './gitlab-ci' + image: python:3.6-slim + stage: validation + before_script: + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests" + - if [ "0$MR_ACCESS_TOKEN" == "0" ]; then MR_ACCESS_TOKEN=$CI_JOB_TOKEN; fi + - echo "[DEBUG] MR_ACCESS_TOKEN[$MR_ACCESS_TOKEN]" + - if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=$DEFAULT_ROOT_DIR; else ROOT_DIR=$JOB_ROOT_DIR ; fi + - echo "[DEBUG] ROOT_DIR[$ROOT_DIR]" + - if [ "0$MY_PROJECT_ID" == "0" ]; then PROJECT_ID=$CI_PROJECT_ID; else PROJECT_ID=$MY_PROJECT_ID ; fi + - echo "[DEBUG] PROJECT_ID[$PROJECT_ID]" + - export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'` + - apt update + - apt install --no-install-recommends -y git + - python3 -m venv env + - . env/bin/activate + - pip install --upgrade pip + - pip install -r $ROOT_DIR/conventional_commits/requirements.txt + - echo "[DEBUG] CI_PROJECT_ID[$CI_PROJECT_ID]" + - echo "[DEBUG] CI_COMMIT_BRANCH[$CI_COMMIT_BRANCH]" + - git fetch --all + - git checkout --track origin/$CI_COMMIT_BRANCH + - git show-branch -a + - target_branch=$(git show-branch -a | awk 'BEGIN { FS="\n\s+*" } { print $1 }' | awk '{print $2}' | grep '\[' | sed 's/.*\[origin\/\(.*\)\].*/\1/' | grep -v '\[' | grep -v $(git rev-parse --abbrev-ref HEAD) | grep -vi 'HEAD' | awk 'BEGIN{ RS = "" ; FS = "\n" }{print $1}') + - echo "[DEBUG] Target Branch[$target_branch]" + - if [ -d "gitlab-ci" ]; then ls -la gitlab-ci; fi + - first_sha1=$(git log origin/$target_branch..$CI_COMMIT_BRANCH --format=format:%H | tail -1) + - echo "[DEBUG] First Commit SHA[$first_sha1]" + - echo "[DEBUG] artifacts directory [$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME]" + after_script: + - ls -lR "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE" + - cd .. + - rm -Rf check + artifacts: + expire_in: 3 days + when: always + paths: + - "$CI_PROJECT_DIR/artifacts/*" + reports: + junit: + - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml" + rules: + - if: '$JOB_STOP_CONVENTIONAL_COMMITS' + when: never + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: never + - if: '$CI_COMMIT_TAG' + when: always + - if: '$CI_COMMIT_BRANCH == "master"' + when: always + - if: '$CI_COMMIT_BRANCH' + when: always + - when: never MR Title: - extends: - - .conventional_commit - script: - - MR_TITLE=$($ROOT_DIR/conventional_commits/scripts/commit.py --token "$MR_ACCESS_TOKEN" --project $PROJECT_ID --title --branch $CI_COMMIT_BRANCH) - - echo "[DEBUG] MR_TITLE[$MR_TITLE]" - - cz_exit=0 && cz check --message "$MR_TITLE" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$? - - . $ROOT_DIR/conventional_commits/scripts/cz_junit.sh > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME-cz.junit.xml" + extends: + - .conventional_commit + script: + - MR_TITLE=$($ROOT_DIR/conventional_commits/scripts/commit.py --token "$MR_ACCESS_TOKEN" --project $PROJECT_ID --title --branch $CI_COMMIT_BRANCH) + - echo "[DEBUG] MR_TITLE[$MR_TITLE]" + - cz_exit=0 && cz check --message "$MR_TITLE" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$? + - . $ROOT_DIR/conventional_commits/scripts/cz_junit.sh > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME-cz.junit.xml" Commit Messages: - extends: - - .conventional_commit - script: - - if [ "$(git log $first_sha1..HEAD --format=format:%H | wc -l)" -eq 0 ]; then echo "[DEBUG] Single Commit"; cz_exit=0 && cz check -m "$(git log HEAD --format=format:%B -1)" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$?; fi - - if [ "$(git log $first_sha1..HEAD --format=format:%H | wc -l)" -gt 0 ]; then echo "[DEBUG] Commit range"; cz_exit=0 && cz check --rev-range $first_sha1..HEAD > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$?; fi - - . $ROOT_DIR/conventional_commits/scripts/cz_junit.sh > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME-cz.junit.xml" + extends: + - .conventional_commit + script: + - if [ "$(git log $first_sha1..HEAD --format=format:%H | wc -l)" -eq 0 ]; then echo "[DEBUG] Single Commit"; cz_exit=0 && cz check -m "$(git log HEAD --format=format:%B -1)" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$?; fi + - if [ "$(git log $first_sha1..HEAD --format=format:%H | wc -l)" -gt 0 ]; then echo "[DEBUG] Commit range"; cz_exit=0 && cz check --rev-range $first_sha1..HEAD > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$?; fi + - . $ROOT_DIR/conventional_commits/scripts/cz_junit.sh > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME-cz.junit.xml" diff --git a/type/docker-image.gitlab-ci.yaml b/type/docker-image.gitlab-ci.yaml index 7846967..ed00b5b 100644 --- a/type/docker-image.gitlab-ci.yaml +++ b/type/docker-image.gitlab-ci.yaml @@ -24,7 +24,6 @@ variables: # JOB_STOP_GITLAB_RELEASE: 'any value' - .build_docker_container: stage: build image: nofusscomputing/docker-buildx-qemu:dev @@ -105,7 +104,6 @@ variables: - when: never - .publish-docker-hub: stage: publish image: docker:23-dind @@ -206,8 +204,6 @@ variables: - when: never - - Docker Container: extends: .build_docker_container @@ -217,10 +213,10 @@ Docker Hub: Gitlab Release: - extends: - - .gitlab_release + extends: + - .gitlab_release Github (Push --mirror): - extends: - - .git_push_mirror \ No newline at end of file + extends: + - .git_push_mirror \ No newline at end of file