diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6dae673..4407449 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ stages: - sync include: - - local: $JOB_ROOT_DIR/yaml_lint/.gitlab-ci.yml + - local: $JOB_ROOT_DIR/lint/yaml.gitlab-ci.yaml - local: $JOB_ROOT_DIR/conventional_commits/.gitlab-ci.yml - local: $JOB_ROOT_DIR/git_push_mirror/.gitlab-ci.yml - local: $JOB_ROOT_DIR/gitlab_release/.gitlab-ci.yml diff --git a/ansible/.gitlab-ci.yml b/ansible/.gitlab-ci.yml deleted file mode 100644 index 80222b3..0000000 --- a/ansible/.gitlab-ci.yml +++ /dev/null @@ -1,38 +0,0 @@ - -.ansible_linter_defaults: - stage: validation - before_script: - - if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi - - echo "[DEBUG] ROOT_DIR[$ROOT_DIR]" - - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" - - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests" - - 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/ansible/requirements.txt - - mkdir $PYTHON_VERSION - script: - - ansible-lint -p --nocolor --parseable-severity "$ANSIBLE_LINT_PATH" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-ansible-lint.log" 1>&1 || ANSIBLE_LINT=$? - - cat "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-ansible-lint.log" | ansible-lint-to-junit-xml > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$PYTHON_VERSION-ansible-lint.junit.xml" - - ls -la $PYTHON_VERSION - - if [ $ANSIBLE_LINT > 0 ]; then echo "ansible lint failed with $ANSIBLE_LINT"; exit $ANSIBLE_LINT; fi - after_script: - - echo deactivate - artifacts: - expire_in: 3 days - when: always - paths: - - "artifacts/*" - reports: - junit: - - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml" - rules: - - if: '$CI_COMMIT_BRANCH == "master"' - when: never - - if: '$CI_COMMIT_BRANCH' - when: always - - when: never - diff --git a/ansible/CHANGELOG.md b/ansible/CHANGELOG.md deleted file mode 100644 index 70b72e2..0000000 --- a/ansible/CHANGELOG.md +++ /dev/null @@ -1,22 +0,0 @@ -# Changelog - -2023-05-13 15:35:28 +0930 [408e4ea](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/408e4eab9e1f61004f1e38af6d1531747b7da99b) - refactor: move docs as part of restructure -2022-01-25 00:08:05 +0000 [ce1cc01](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/ce1cc017e26ff7f6cee586cc7d98e4d292275672) - build(version): bump version 0.6.0 → 0.6.1rc0 -2022-01-24 06:33:24 +0000 [46cc1fb](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/46cc1fbb6a878e485af39e679b5184a9912c2e7f) - build(version): bump version 0.5.0 → 0.6.0 -2022-01-24 13:37:23 +0930 [4e1da5e](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/4e1da5e87281284e021791a4b600a1bff53b8431) - ci(dependency_scanning): python 3.7 not available for dependecy scanning. -2022-01-23 07:14:32 +0000 [6668c2f](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/6668c2fb8d7545b4f9052ad3065e58f00d11be62) - refactor: test specifying must equal. -2022-01-23 06:12:35 +0000 [0df60b1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/0df60b12dbfff983ca3a671b90ab1be126597e52) - fix(ansible): remove duplicate lines that last code review didn't remove. -2022-01-23 05:57:43 +0000 [484d987](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/484d98792a27c9d967331e9d3cd1afdca435bdd6) - fix(ansible): fix typo in job pip file -2022-01-23 05:46:31 +0000 [e1894ec](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/e1894ec0c4fe7504901682f008c2ff0db7e351fe) - fix(dependency_scanning): upgraded versions from vulnerability scan. -2022-01-16 00:09:42 +0000 [1ef6c41](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/1ef6c41818c40183f8019ea5cde48b4278e4d694) - build(version): bump version 0.4.0 → 0.5.0 -2022-01-15 03:53:53 +0000 [5c9000a](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/5c9000a74859504ed64bbefa1fd193f80a2b69c2) - build(version): bump version 0.3.1 → 0.4.0 -2022-01-11 07:03:09 +0000 [7751fd9](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/7751fd9494f610fff0ea16bd303bfe62d0034eec) - build(version): bump version 0.3.0 → 0.3.1 -2021-08-12 03:32:36 +0000 [389bc08](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/389bc08d7686153fb374aa83d440c35c9b4eac90) - build(version): bump version 0.3.0rc1 → 0.3.0 -2021-08-11 13:47:34 +0930 [def31ef](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/def31ef562c0002713401652657d59320548ee85) - style(yaml_lint): fixed yaml lint errors -2021-08-04 03:23:08 +0000 [eb5cc8a](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/eb5cc8a0e2885a9ed16a8d1a81611aec4d5a4d31) - build(version): bump version 0.3.0rc0 → 0.3.0rc1 -2021-08-04 03:13:54 +0000 [09dcb65](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/09dcb65b090f59e9f8a6bea5eba4bb98bddbad3d) - build(version): bump version 0.2.1 → 0.3.0rc0 -2021-08-04 02:49:45 +0000 [4453b43](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/4453b433c8966a334f02af592a6ce8092f2ac9de) - build(version): bump version 0.2.0 → 0.2.1 -2021-08-04 02:24:12 +0000 [856f2e1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/856f2e1770d0bda823996122ee70916dc0fe455b) - build(version): bump version 0.1.0 → 0.2.0 -2021-08-04 01:33:47 +0000 [6d34977](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/6d349774269bcd7c6e406cfe72c78b99f246df7b) - build(version): bump version 0.0.1 → 0.1.0 -2021-08-03 15:23:19 +0930 [2a3266f](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/2a3266fb537e22dddf47708d0af101945027128f) - fix(ansible): Ensure the default ci directory is populated -2021-08-03 15:08:37 +0930 [2413dae](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/2413daefb1e7e5a9e7a3cbb2d8cff2214f4a98ae) - feat(ansible): Added ansible validation job for linting diff --git a/ansible/requirements.txt b/ansible/requirements.txt deleted file mode 100644 index 3f7cb6f..0000000 --- a/ansible/requirements.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Dependency scanning only has Python 3.6 available. - -# Python 3.7 -# Pillow==9.0.0 -# numpy==1.22.0 - -# Python 3.6 -pipenv==2022.1.8 -wheel -ansible -setuptools_rust -Rust -ansible-lint -yamllint -lxml -ansible-lint-junit -ansible-lint-to-junit-xml diff --git a/yaml_lint/.yamllint.yaml b/lint/.yamllint.yaml similarity index 100% rename from yaml_lint/.yamllint.yaml rename to lint/.yamllint.yaml diff --git a/yaml_lint/CHANGELOG.md b/lint/CHANGELOG.md similarity index 100% rename from yaml_lint/CHANGELOG.md rename to lint/CHANGELOG.md diff --git a/lint/ansible.gitlab-ci.yaml b/lint/ansible.gitlab-ci.yaml new file mode 100644 index 0000000..3bcd470 --- /dev/null +++ b/lint/ansible.gitlab-ci.yaml @@ -0,0 +1,47 @@ + +.ansible_linter_defaults: + stage: validation + variables: + ANSIBLE_LINT_PATH: defaults/ handlers/ meta/ tasks/ templates/ + before_script: + - if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi + - echo "[DEBUG] ROOT_DIR[$ROOT_DIR]" + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests" + - 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/ansible/requirements.txt + - mkdir $PYTHON_VERSION + script: + - ansible-lint -q --nocolor --parseable $ANSIBLE_LINT_PATH > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-ansible-lint.log" 1>&1 || ANSIBLE_LINT=$? + - cat "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-ansible-lint.log" | ansible-lint-to-junit-xml > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$PYTHON_VERSION-ansible-lint.junit.xml" 1>&1 || ANSIBLE_LINT_JUNIT=$? + - ls -la $PYTHON_VERSION + - if [ $ANSIBLE_LINT_JUNIT > 0 ]; then echo "Error ANSIBLE_LINT_JUNIT failed with $ANSIBLE_LINT_JUNIT"; fi + - if [ $ANSIBLE_LINT -ge 3 ]; then echo "ansible lint failed with $ANSIBLE_LINT"; exit $ANSIBLE_LINT; fi # don't fail the job?? 1=failed test, 2=failed command i.e. switch/flag + after_script: + - echo deactivate + artifacts: + expire_in: 3 days + when: always + paths: + - "artifacts/*" + reports: + junit: + - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml" + rules: + - if: '$JOB_STOP_ANSIBLE_LINT' + when: never + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: never + - if: '$CI_COMMIT_BRANCH == "master"' + when: always + - if: '$CI_COMMIT_TAG' + when: always + - if: '$CI_COMMIT_BRANCH' + when: always + - when: never + diff --git a/lint/requirements.txt b/lint/requirements.txt new file mode 100644 index 0000000..5e254c3 --- /dev/null +++ b/lint/requirements.txt @@ -0,0 +1,11 @@ + +pipenv==2022.1.8 +wheel +ansible +setuptools_rust +Rust +ansible-lint==6.15.0 +yamllint==1.31.0 +lxml +ansible-lint-junit==0.17.7 +ansible-lint-to-junit-xml==0.1.0 diff --git a/yaml_lint/.gitlab-ci.yml b/lint/yaml.gitlab-ci.yaml similarity index 100% rename from yaml_lint/.gitlab-ci.yml rename to lint/yaml.gitlab-ci.yaml diff --git a/yaml_lint/requirements.txt b/yaml_lint/requirements.txt deleted file mode 100644 index 1013116..0000000 --- a/yaml_lint/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -yamllint -ansible-lint-to-junit-xml