From 532b49ddc9660fe71a9250aba27318059660d14d Mon Sep 17 00:00:00 2001 From: patrick hermann <47567770+patrick-hermann-sva@users.noreply.github.com> Date: Mon, 30 Sep 2024 09:51:55 +0000 Subject: [PATCH] added taskfile --- .../{ansible-lint.yaml => validate.yaml} | 22 ++++--- Taskfile.yaml | 64 +++++++++++++++++++ requirements.yaml | 8 +++ 3 files changed, 86 insertions(+), 8 deletions(-) rename .github/workflows/{ansible-lint.yaml => validate.yaml} (60%) create mode 100644 Taskfile.yaml create mode 100644 requirements.yaml diff --git a/.github/workflows/ansible-lint.yaml b/.github/workflows/validate.yaml similarity index 60% rename from .github/workflows/ansible-lint.yaml rename to .github/workflows/validate.yaml index 6a67b34..c4c8212 100644 --- a/.github/workflows/ansible-lint.yaml +++ b/.github/workflows/validate.yaml @@ -7,10 +7,7 @@ on: - 'feature/**' - 'fix/**' pull_request: - branches: - - 'main' - - 'feature/**' - - 'fix/**' + types: [opened, reopened] workflow_dispatch: jobs: @@ -18,7 +15,7 @@ jobs: name: Lint yaml files uses: stuttgart-things/stuttgart-things/.github/workflows/lint-yaml.yaml@yaml-lint-1 with: - runs-on: ghr-install-configure-docker-skyami-cicd + runs-on: ghr-download-install-binary-skyami-cicd environment-name: k8s continue-error: true yamllint-version: 1 @@ -29,9 +26,18 @@ jobs: name: Lint ansible code uses: stuttgart-things/stuttgart-things/.github/workflows/lint-ansible.yaml@main # ansible-lint-24.2.1 with: - runs-on: ghr-install-configure-docker-skyami-cicd + runs-on: ghr-download-install-binary-skyami-cicd environment-name: k8s continue-error: true - ansible-image: eu.gcr.io/stuttgart-things/sthings-ansible:9.3.0-1 - playbook: tests/kind.yaml + ansible-image: eu.gcr.io/stuttgart-things/sthings-ansible:10.3.0 + playbook: tests/test.yml needs: yaml-lint + + molecule-test: + name: Test ansible code w/ molecule + uses: stuttgart-things/stuttgart-things/.github/workflows/call-moluecule-test.yaml@main # ansible-lint-24.2.1 + with: + runs-on: docker + environment-name: k8s + scenario-names: "['docker_test']" + needs: ansible-lint diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..0b717a3 --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,64 @@ +--- +version: 3 +vars: + BRANCH: + sh: if [ $(git rev-parse --abbrev-ref HEAD) != "main" ]; then echo $(git rev-parse --abbrev-ref HEAD); else echo main ; fi + MOLECULE_SCENARIO: docker_test + +# PRECONDITION TO CHECK IF THE VIRTUAL ENVIRONMENT IS ACTIVATED +venv-precondition: &venv + - sh: | + pip -V | grep '.venv' >/dev/null 2>&1 + msg: "The pip version output does not contain .venv, Halting. Run task setup-molecule and/or source .venv/bin/activate" + +tasks: + run-molecule: + preconditions: *venv + cmds: + - molecule test -s {{ .MOLECULE_SCENARIO }} + + setup-molecule: + preconditions: *venv + cmds: + - pip install -U setuptools pip 'molecule' + - pip install molecule-docker + - molecule --version + + setup-venv: + desc: "Setup python virtual environment" + cmds: + - rm -rf ./.venv + - python3 -m venv ./.venv + - echo "DON'T FORGET TO RUN - source ./venv/bin/activate" + + branch: + desc: Create branch from main + cmds: + - git checkout main + - git branch + - git pull + - | + echo "Enter to be created (remote) branch:" + read BRANCH_NAME; + git checkout -b ${BRANCH_NAME} + git push origin ${BRANCH_NAME} + - git branch + - git branch --set-upstream-to=origin/main ${BRANCH_NAME} + + commit: + desc: Commit + push code into branch + cmds: + - rm -rf dist/ + - git branch --set-upstream-to=origin/{{ .BRANCH }} + - git pull + - | + echo "ENTER COMMIT MESSAGE" + read COMMIT_MESSAGE; + git add * + if [[ -n $(git status --porcelain) ]]; then + echo "committing changes" + git commit --allow-empty -a -m "$(echo ${COMMIT_MESSAGE})" + else + echo "no changes" + fi + git push origin -u {{ .BRANCH }} \ No newline at end of file diff --git a/requirements.yaml b/requirements.yaml new file mode 100644 index 0000000..87fe7a7 --- /dev/null +++ b/requirements.yaml @@ -0,0 +1,8 @@ +--- +collections: + - name: community.general + version: 9.4.0 + +roles: + - src: https://github.com/stuttgart-things/install-requirements.git + scm: git