diff --git a/.github/actions/git/add-commit-push/action.yaml b/.github/actions/git/add-commit-push/action.yaml new file mode 100644 index 00000000..7466b31a --- /dev/null +++ b/.github/actions/git/add-commit-push/action.yaml @@ -0,0 +1,24 @@ +name: "Code for Life - Git - Add, Commit and Push" +description: "Git add and, if there are differences, commit and push." +inputs: + add: + description: "The changes to add." + required: true + commit-message: + description: "The commit message. Prepended with 'chore: ' and post-pended with ' [skip ci]'." + required: true +runs: + using: composite + steps: + - name: โž• Git Add + shell: bash + run: git add ${{ inputs.add }} + + - name: ๐Ÿ”„ Git Commit and Push + shell: bash + run: | + # Only commit and push if there are differences. + if ! git diff --staged --quiet; then + git commit -m "chore: ${{ inputs.commit-message }} [skip ci]" + git push + fi diff --git a/.github/actions/git/setup-bot/action.yaml b/.github/actions/git/setup-bot/action.yaml new file mode 100644 index 00000000..2c45e3b4 --- /dev/null +++ b/.github/actions/git/setup-bot/action.yaml @@ -0,0 +1,10 @@ +name: "Code for Life - Git - Setup Bot" +description: "Sets up CFL's bot as the Git user." +runs: + using: composite + steps: + - name: โš™๏ธ Set up cfl-bot as Git user + shell: bash + run: | + git config --local user.name cfl-bot + git config --local user.email codeforlife-bot@ocado.com diff --git a/.github/actions/python/docs/action.yaml b/.github/actions/python/docs/action.yaml new file mode 100644 index 00000000..bc0b2041 --- /dev/null +++ b/.github/actions/python/docs/action.yaml @@ -0,0 +1,53 @@ +name: "Code for Life - Python - Docs" +description: "Documents python code written in the CFL workspace." +inputs: + python-version: + description: "The python version to set up." + required: true + default: "3.8" + working-directory: + description: "The current working directory." + required: true + default: "." + graph-django-models: + description: "If there are Django models to graph." + required: true + default: "true" +runs: + using: composite + steps: + - name: ๐Ÿ›ซ Checkout + uses: actions/checkout@v4 + + - name: ๐Ÿ Set up Python ${{ inputs.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python-version }} + + - name: ๐Ÿ›  Install Graphviz + if: inputs.graph-django-models == 'true' + shell: bash + run: sudo apt-get install python3-dev graphviz libgraphviz-dev pkg-config + + - name: ๐Ÿ›  Install Dependencies + shell: bash + working-directory: ${{ inputs.working-directory }} + run: | + python -m pip install --upgrade pip + python -m pip install pipenv + pipenv install --dev + + - name: ๐Ÿ“ˆ Graph Django Models + if: inputs.graph-django-models == 'true' + shell: bash + working-directory: ${{ inputs.working-directory }} + run: pipenv run python manage.py graph_models + + - uses: ocadotechnology/codeforlife-workspace/.github/actions/git/setup-bot@main + if: inputs.graph-django-models == 'true' + + - uses: ocadotechnology/codeforlife-workspace/.github/actions/git/add-commit-push@main + if: inputs.graph-django-models == 'true' + with: + add: docs/entity_relationship_diagram.png + commit-message: "entity relationship diagram" diff --git a/.github/actions/python/test/action.yaml b/.github/actions/python/test/action.yaml new file mode 100644 index 00000000..83a651f6 --- /dev/null +++ b/.github/actions/python/test/action.yaml @@ -0,0 +1,55 @@ +name: "Code for Life - Python - Test" +description: "Tests python code written in the CFL workspace." +inputs: + python-version: + description: "The python version to set up." + required: true + default: "3.8" + working-directory: + description: "The current working directory." + required: true + default: "." + check-django-migrations: + description: "Check if there are pending Django migrations." + required: true + default: "true" +runs: + using: composite + steps: + - name: ๐Ÿ›ซ Checkout + uses: actions/checkout@v4 + + - name: ๐Ÿ Set up Python ${{ inputs.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python-version }} + + - name: ๐Ÿ›  Install Dependencies + shell: bash + working-directory: ${{ inputs.working-directory }} + run: | + python -m pip install --upgrade pip + python -m pip install pipenv + pipenv install --dev + + - name: ๐Ÿ”Ž Check Code Format + shell: bash + working-directory: ${{ inputs.working-directory }} + run: if ! pipenv run black --check .; then exit 1; fi + + # TODO: check static type hints with mypy + + # TODO: check linter error with pylint + + - name: ๐Ÿ”Ž Check Django Migrations + if: inputs.check-django-migrations == 'true' + shell: bash + working-directory: ${{ inputs.working-directory }} + run: pipenv run python manage.py makemigrations --check --dry-run + + - name: ๐Ÿงช Test Code Units + shell: bash + working-directory: ${{ inputs.working-directory }} + run: pipenv run pytest -n auto + + # TODO: assert code coverage target. diff --git a/codeforlife-package-javascript b/codeforlife-package-javascript index 3ca4e316..a15b89df 160000 --- a/codeforlife-package-javascript +++ b/codeforlife-package-javascript @@ -1 +1 @@ -Subproject commit 3ca4e316639306c08ed90c79d2ee703fe3172e83 +Subproject commit a15b89dfa582409faa290b47f214112eef7b4497 diff --git a/codeforlife-package-python b/codeforlife-package-python index 7d6c2d26..37306451 160000 --- a/codeforlife-package-python +++ b/codeforlife-package-python @@ -1 +1 @@ -Subproject commit 7d6c2d26ed2d41c591f4461867c952ee54a3059d +Subproject commit 373064511f5dbf7679248c9bc2a4a0bee69d6193 diff --git a/codeforlife-portal b/codeforlife-portal index f84cd1ed..704caacd 160000 --- a/codeforlife-portal +++ b/codeforlife-portal @@ -1 +1 @@ -Subproject commit f84cd1ed1c5bde36c62f60e14a201e58feff757d +Subproject commit 704caacd1febf19e965186fdd1185041524cd375 diff --git a/codeforlife-portal-react b/codeforlife-portal-react index 0e442c0c..e2f0de16 160000 --- a/codeforlife-portal-react +++ b/codeforlife-portal-react @@ -1 +1 @@ -Subproject commit 0e442c0c64b0185380b375bb7eb3bad2897ed94a +Subproject commit e2f0de1631f4f50ca8d612dd6c6e32e03ce4de07 diff --git a/codeforlife.code-workspace b/codeforlife.code-workspace index 8f09c3cf..de816a5f 100644 --- a/codeforlife.code-workspace +++ b/codeforlife.code-workspace @@ -75,7 +75,9 @@ "cSpell.words": [ "codeforlife", "klass", - "ocado" + "ocado", + "kurono", + "pipenv" ], }, "extensions": {