Skip to content

Commit

Permalink
create actions (#36)
Browse files Browse the repository at this point in the history
* update submodules

* add new words

* add python test action

* incase django is not used

* fix syntax

* use single quote

* git and python actions

* Install Graphviz

* reorder steps

* use sudo

* refactor add-commit-push

* use expression

* go back

* add condition

* use @main

* feedback
  • Loading branch information
SKairinos authored Dec 15, 2023
1 parent 49d2eb0 commit e3b1243
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 5 deletions.
24 changes: 24 additions & 0 deletions .github/actions/git/add-commit-push/action.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions .github/actions/git/setup-bot/action.yaml
Original file line number Diff line number Diff line change
@@ -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 [email protected]
53 changes: 53 additions & 0 deletions .github/actions/python/docs/action.yaml
Original file line number Diff line number Diff line change
@@ -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"
55 changes: 55 additions & 0 deletions .github/actions/python/test/action.yaml
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion codeforlife-package-javascript
2 changes: 1 addition & 1 deletion codeforlife-package-python
Submodule codeforlife-package-python updated 70 files
+70 −96 .github/workflows/main.yml
+17 −0 .vscode/launch.json
+19 −0 .vscode/settings.json
+6 −0 CHANGELOG.md
+5 −9 Pipfile
+310 −807 Pipfile.lock
+21 −6 codeforlife/__init__.py
+165 −8 codeforlife/models/__init__.py
+385 −0 codeforlife/models/fields.py
+6 −0 codeforlife/permissions/__init__.py
+26 −0 codeforlife/permissions/is_self.py
+1 −0 codeforlife/settings/django.py
+9 −1 codeforlife/tests/__init__.py
+12 −6 codeforlife/tests/api.py
+54 −0 codeforlife/tests/model.py
+9 −5 codeforlife/user/auth/backends/email_and_password.py
+10 −5 codeforlife/user/auth/backends/otp_bypass_token.py
+0 −2 codeforlife/user/auth/backends/user_id_and_login_id.py
+22 −0 codeforlife/user/fixtures/classes.json
+12 −0 codeforlife/user/fixtures/schools.json
+20 −0 codeforlife/user/fixtures/students.json
+20 −0 codeforlife/user/fixtures/teachers.json
+62 −0 codeforlife/user/fixtures/users.json
+165 −21 codeforlife/user/migrations/0001_initial.py
+9 −5 codeforlife/user/models/__init__.py
+32 −6 codeforlife/user/models/auth_factor.py
+40 −0 codeforlife/user/models/class_student_join_request.py
+92 −102 codeforlife/user/models/klass.py
+0 −65 codeforlife/user/models/other.py
+50 −5 codeforlife/user/models/otp_bypass_token.py
+72 −50 codeforlife/user/models/school.py
+54 −0 codeforlife/user/models/school_teacher_invitation.py
+31 −25 codeforlife/user/models/session.py
+28 −7 codeforlife/user/models/session_auth_factor.py
+152 −73 codeforlife/user/models/student.py
+77 −68 codeforlife/user/models/teacher.py
+0 −47 codeforlife/user/models/teacher_invitation.py
+258 −82 codeforlife/user/models/user.py
+10 −2 codeforlife/user/permissions/__init__.py
+43 −0 codeforlife/user/permissions/in_class.py
+41 −0 codeforlife/user/permissions/in_school.py
+22 −0 codeforlife/user/permissions/is_independent.py
+0 −18 codeforlife/user/permissions/is_school_member.py
+0 −15 codeforlife/user/permissions/is_school_teacher.py
+35 −0 codeforlife/user/permissions/is_student.py
+47 −0 codeforlife/user/permissions/is_teacher.py
+2 −2 codeforlife/user/serializers/user.py
+20 −0 codeforlife/user/tests/models/test_klass.py
+3 −0 codeforlife/user/tests/models/test_otp_bypass_token.py
+25 −0 codeforlife/user/tests/models/test_school.py
+48 −0 codeforlife/user/tests/models/test_student.py
+57 −0 codeforlife/user/tests/models/test_teacher.py
+310 −0 codeforlife/user/tests/models/test_user.py
+137 −0 codeforlife/user/tests/models/test_warehouse.py
+0 −0 codeforlife/user/tests/permissions/__init__.py
+97 −0 codeforlife/user/tests/permissions/test_in_class.py
+29 −0 codeforlife/user/tests/permissions/test_in_school.py
+42 −0 codeforlife/user/tests/permissions/test_is_independent.py
+76 −0 codeforlife/user/tests/permissions/test_is_student.py
+137 −0 codeforlife/user/tests/permissions/test_is_teacher.py
+2 −0 codeforlife/user/tests/views/test_klass.py
+11 −43 codeforlife/user/tests/views/test_school.py
+20 −47 codeforlife/user/tests/views/test_user.py
+3 −2 codeforlife/user/views/klass.py
+3 −2 codeforlife/user/views/school.py
+35 −24 codeforlife/user/views/user.py
+1 −1 codeforlife/version.py
+2 −4 manage.py
+14 −1 pyproject.toml
+26 −88 setup.py
2 changes: 1 addition & 1 deletion codeforlife-portal
Submodule codeforlife-portal updated 70 files
+1 −8 .codecov.yml
+1 −7 .github/workflows/ci.yml
+5 −11 .github/workflows/publish-python-package.yml
+0 −12 .github/workflows/snyk.yaml
+1 −5 .gitignore
+494 −148 Pipfile.lock
+1 −0 cfl_common/setup.py
+2 −3 example_project/portal_test_settings.py
+2 −3 example_project/settings.py
+0 −8 portal/reactTestSpace.py
+0 −30 portal/tests/test_react_test_space.py
+0 −2 portal/urls.py
+0 −21 portal_frontend/.gitignore
+0 −6 portal_frontend/.prettierignore
+0 −1 portal_frontend/.prettierrc.json
+0 −46 portal_frontend/README.md
+0 −52 portal_frontend/package.json
+ portal_frontend/public/favicon.ico
+0 −47 portal_frontend/public/index.html
+0 −25 portal_frontend/public/manifest.json
+0 −4 portal_frontend/public/portal.css
+0 −3 portal_frontend/public/robots.txt
+0 −3 portal_frontend/src/@cfl/colors/index.ts
+0 −13 portal_frontend/src/@cfl/colors/primary.ts
+0 −13 portal_frontend/src/@cfl/colors/secondary.ts
+0 −13 portal_frontend/src/@cfl/colors/tertiary.ts
+0 −59 portal_frontend/src/App.tsx
+0 −27 portal_frontend/src/Components/Banner/RapidRouter.tsx
+0 −50 portal_frontend/src/Components/Banner/Welcome.tsx
+0 −33 portal_frontend/src/Components/Footer/ExternalLinks.tsx
+0 −38 portal_frontend/src/Components/Footer/Footer.tsx
+0 −49 portal_frontend/src/Components/Footer/FooterMenu.tsx
+0 −27 portal_frontend/src/Components/KuronoWidget/KuronoWidget.tsx
+0 −19 portal_frontend/src/Components/KuronoWidget/KuronoWidgetStyle.tsx
+0 −32 portal_frontend/src/Components/MeetTheCharacters/Cards.tsx
+0 −15 portal_frontend/src/Components/MeetTheCharacters/MeetTheCharacters.tsx
+0 −27 portal_frontend/src/Components/MeetTheCharacters/MeetTheCharactersStyle.tsx
+0 −26 portal_frontend/src/Components/Navbar/Dashboard.tsx
+0 −98 portal_frontend/src/Components/Navbar/Games.tsx
+0 −105 portal_frontend/src/Components/Navbar/LearningResources.tsx
+0 −145 portal_frontend/src/Components/Navbar/MobileMenu.tsx
+0 −153 portal_frontend/src/Components/Navbar/MobileNavbar.tsx
+0 −22 portal_frontend/src/Components/Navbar/MobileNavbarIcon.tsx
+0 −45 portal_frontend/src/Components/Navbar/NavBarDropDown.tsx
+0 −46 portal_frontend/src/Components/Navbar/Navbar.tsx
+0 −342 portal_frontend/src/Components/Navbar/NavbarStyle.tsx
+0 −122 portal_frontend/src/Components/Navbar/UserLogInButton.tsx
+0 −26 portal_frontend/src/Components/Navbar/UserTypeTitle.tsx
+0 −22 portal_frontend/src/Components/RapidRouterScores/RapidRouterScores.tsx
+0 −14 portal_frontend/src/Components/RapidRouterScores/RapidRouterScoresStyled.tsx
+0 −108 portal_frontend/src/Components/SubNav/SubNav.tsx
+0 −6 portal_frontend/src/Components/SubNav/SubNavItem.tsx
+0 −28 portal_frontend/src/Components/YourGames/YourGames.tsx
+0 −27 portal_frontend/src/Components/YourGames/YourGamesStyle.tsx
+0 −103 portal_frontend/src/Theme.tsx
+0 −15 portal_frontend/src/ThemeTypes.d.ts
+0 −336 portal_frontend/src/img/RR_logo.svg
+0 −1 portal_frontend/src/img/footer/facebook.svg
+0 −20 portal_frontend/src/img/footer/ocado.svg
+0 −1 portal_frontend/src/img/footer/twitter.svg
+ portal_frontend/src/img/navbar/logo_cfl.png
+0 −5 portal_frontend/src/img/navbar/logo_ocado_group.svg
+ portal_frontend/src/img/rapid_router_landing_hero.png
+0 −16 portal_frontend/src/index.tsx
+0 −4 portal_frontend/src/portal.css
+0 −1 portal_frontend/src/react-app-env.d.ts
+0 −15 portal_frontend/src/reportWebVitals.ts
+0 −21 portal_frontend/tsconfig.json
+0 −9,391 portal_frontend/yarn.lock
+1 −1 setup.py
2 changes: 1 addition & 1 deletion codeforlife-portal-react
4 changes: 3 additions & 1 deletion codeforlife.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
"cSpell.words": [
"codeforlife",
"klass",
"ocado"
"ocado",
"kurono",
"pipenv"
],
},
"extensions": {
Expand Down

0 comments on commit e3b1243

Please sign in to comment.