Skip to content

Commit

Permalink
added taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-hermann-sva committed Sep 30, 2024
1 parent d95bb9f commit 532b49d
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ on:
- 'feature/**'
- 'fix/**'
pull_request:
branches:
- 'main'
- 'feature/**'
- 'fix/**'
types: [opened, reopened]
workflow_dispatch:

jobs:
yaml-lint:
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
Expand All @@ -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
64 changes: 64 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 8 additions & 0 deletions requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
collections:
- name: community.general
version: 9.4.0

roles:
- src: https://github.com/stuttgart-things/install-requirements.git
scm: git

0 comments on commit 532b49d

Please sign in to comment.