Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
b50b558
First workflow with ruff
Apr 24, 2025
ecb4ecb
Poetry addition
Apr 24, 2025
bb27d09
Poetry actionaddition
Apr 24, 2025
75d7485
Removed poetry from cache
Apr 24, 2025
8dfdf2c
Further trial poetry
Apr 24, 2025
8c1b041
Further trial poetry. Linting only
Apr 24, 2025
e9126bc
Testing with changed files git action
Apr 24, 2025
f85bfb5
Rebuild yaml file
Apr 24, 2025
3e05afc
View all changed files
Apr 24, 2025
65e44cd
Merge branch 'master' into github-actions-tutorial
mwangidyce Apr 24, 2025
021970a
Merge branch 'master' into github-actions-tutorial
mwangidyce Apr 24, 2025
8ed3e2f
Tested linter on github. Better workflow settings
Apr 24, 2025
bed1535
Merge branch 'github-actions-tutorial' of github.com:mwangidyce/real_…
Apr 24, 2025
3236e9c
Linter should now pass
Apr 24, 2025
88a10be
Linter should now pass
Apr 24, 2025
f4047fe
Check for only changed files
Apr 25, 2025
2171495
Used git expressions
Apr 25, 2025
41f2605
Used git expressions previous
Apr 25, 2025
d129e59
Used git if statement
Apr 25, 2025
e2d4d36
Added changed file
Apr 25, 2025
0c1f014
Added 2 changed files
Apr 25, 2025
c1bd571
Force exclude in ruff
Apr 25, 2025
76bfc09
Dump github context
Apr 25, 2025
f4159a5
Job context
Apr 25, 2025
89947ca
Better env context
Apr 25, 2025
8e5a4ae
Changed a file
Apr 25, 2025
b50554c
Changed many files
Apr 25, 2025
6b71855
Change dfiles again
Apr 25, 2025
0fef0e9
Changed files again
Apr 25, 2025
bda4a15
env troubleshooting
Apr 25, 2025
ed4ab90
env troubleshooting workflows
Apr 25, 2025
1f67057
env troubleshooting workflows issues
Apr 25, 2025
63b9caf
env troubleshooting workflows issues2
Apr 25, 2025
fbee561
Document changed files
Apr 29, 2025
1f562f6
File changes 3
Apr 29, 2025
48cf90e
Skip tests
Apr 29, 2025
cdf1649
Some change to one ring py
Apr 29, 2025
a7ea777
Newest change failed print
Apr 29, 2025
57ba1b5
Now passing
Apr 29, 2025
180e16f
Test echo statement
Apr 30, 2025
b118a5e
Test echo statement for 2nd project
Apr 30, 2025
ac17033
If condition checks
Apr 30, 2025
3da96d8
Added if conditions
Apr 30, 2025
b78da12
Solved typos for workflow
Apr 30, 2025
ddf8f9e
Completed if statement check
Apr 30, 2025
a811214
Rectified script
Apr 30, 2025
8f422b5
Better script for action
Apr 30, 2025
65d2189
Job output setter
Apr 30, 2025
5403c91
Check job output literal
Apr 30, 2025
2dbe9eb
If checker
Apr 30, 2025
ab5f59a
Better if checker
Apr 30, 2025
a0dc09a
Check if file in common
Apr 30, 2025
5fb021c
Added first preliminary run for pytest
May 8, 2025
e084004
Correct poetry version
May 8, 2025
efad98a
Sorted out pytest issues
May 8, 2025
55c04ab
Annotation plugin added
May 8, 2025
d880b57
Solving for dependency issues
May 8, 2025
62a20e5
Solving for poetry env issues
May 8, 2025
1df458f
Special annotations
May 8, 2025
64bce01
Added all changes at once
May 8, 2025
9cb5fac
Added default working directory
May 8, 2025
3792a44
Added all common files
May 8, 2025
e9c420a
Cache debug
May 8, 2025
10899cd
Matching cache pattern
May 8, 2025
da3b6ba
Fixed cache per project
May 8, 2025
78b2243
Fixed tests
May 8, 2025
3a0f486
Fixed tests
May 8, 2025
a0b6ccc
Fixed local conflicts
May 8, 2025
b8d8ca0
Common dir
May 8, 2025
513febb
Github actions local with cache
May 9, 2025
9f6afd7
Github actions local with cache pipx
May 9, 2025
c9cfefc
Changed poetry lock file
May 9, 2025
edc0142
Common tests change
May 9, 2025
678015b
Better caching
May 9, 2025
f2b4531
Speed of docker builds
May 9, 2025
a788883
Check file structures
May 9, 2025
f082809
Compose file
May 9, 2025
dce1402
Composed files
May 9, 2025
f15cd16
Proper compose file name
May 9, 2025
979ca2a
Docker compose flow
May 9, 2025
afdf0f8
Test compose bake build
May 20, 2025
e55a10b
More tests with compose
May 20, 2025
a05e941
Compose file addition
May 20, 2025
182d9a8
Updated buildx driver
May 20, 2025
642490c
Solved workdir issue for tests
May 21, 2025
2dabddd
Better workdir setup
May 21, 2025
81f4ea8
More repair work on workdir
May 21, 2025
6fadd49
Added checkout statement
May 21, 2025
38001b9
Check dir structure
May 21, 2025
56aa51c
Check paths
May 22, 2025
445f60d
Sorted out compose dirs
May 22, 2025
d68004f
Forgot end of statement
May 22, 2025
2e62471
Fixed bug in workflow file
May 22, 2025
0e24d09
Fixed caching issues
May 22, 2025
d8109b2
Test cache for github actions
May 22, 2025
274b6e5
Added poetry lock file
May 22, 2025
cadcc00
Added mysql health check
May 22, 2025
b59d0ec
mysqlping with sql added
May 22, 2025
c8236df
First test with pytest github actions
May 23, 2025
171b11c
Solved dir missing issue
May 26, 2025
c0e57ea
Added gitignore to file
May 26, 2025
72ffe89
If statement to renaming config sample
May 26, 2025
04f62b6
Changed poetry lock file
May 26, 2025
e180c64
Added setup tools to path
May 26, 2025
e623bb2
Finalized test trials for events
May 26, 2025
012b055
Grouped workflows in directories
May 26, 2025
b7443d3
Ungrouped workflows
May 26, 2025
232e8a9
Major changes to github actions files
May 26, 2025
13b16ef
Added common SQL files
May 26, 2025
637bc93
Added if exists guard
May 26, 2025
afdfe3c
Fixed syntax error for table
May 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/final_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Linter - Quality and Type Checks

on:
- push
- pull_request
- workflow_dispatch

jobs:
lint: # The name of the job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Changed Python files only
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v46
with:
files: "**/*.py"

- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files}}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done

#Set up Python
- uses: actions/setup-python@v5
with:
python-version: "3.10"

#Ruff linter for checking. Replaces manual install and run.
- uses: astral-sh/ruff-action@v3
if: ${{ steps.changed-files.outputs.all_changed_files }}
with:
src: >-
${{ steps.changed-files.outputs.all_changed_files }}
42 changes: 42 additions & 0 deletions .github/workflows/my_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run Integration and Unit Tests

on:
push:
pull_request:
branches:
- master
workflow_dispatch:

jobs:
get_changed_files:
runs-on: ubuntu-latest
outputs:
changed-files: ${{steps.changed-files.outputs.all_changed_files}}
steps:
- uses: actions/checkout@v4
# Changed Python files only
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v46
with:
files: "**/*.py"

- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done

actual_tests:
name: Run Python tests
needs: get_changed_files
strategy:
matrix:
project: ["common", "events", "visits"]

uses: ./.github/workflows/test_workflow.yaml
with:
project: ${{ matrix.project }}
changed_files: ${{ needs.get_changed_files.outputs.changed-files }}
121 changes: 121 additions & 0 deletions .github/workflows/test_workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Run unit and integration tests

on:
workflow_call:
inputs:
project:
description: "Describes which project we are dealing with"
required: true
type: string
changed_files:
required: true
type: string

jobs:
decide_run_test:
name: Decide if we run test on project ${{ inputs.project}}
runs-on: ubuntu-latest
outputs:
run_test: ${{steps.if_run_test.outputs.RUN_TEST}}
workdir: ${{steps.if_run_test.outputs.WORKDIR}}
steps:
- uses: actions/checkout@v4
- name: Run regex to check if file match
id: if_run_test
env:
PROJECT: ${{ inputs.project }}
CHANGED_FILES: ${{inputs.changed_files}}
run: |
run_tests=false
for file in ${CHANGED_FILES}; do
#Runs project tests if any file in prject has changed or any file in common
if [[ ${file} =~ "common" || ${file} =~ ${PROJECT} ]]; then
echo "${file} has matched"
run_tests=true
break
fi
done

if [[ ${PROJECT} == "common" ]]; then
workdir="./common"
elif test -d "./services/${PROJECT}"; then
workdir="./services/${PROJECT}"
elif test -d "./tools/${PROJECT}"; then
workdir="./tools/${PROJECT}"
else
workdir="./"
fi

echo ${run_tests} ${workdir}

echo "RUN_TEST=${run_tests}" >> "$GITHUB_OUTPUT"
echo "WORKDIR=${workdir}" >> "$GITHUB_OUTPUT"

test_project:
name: Actual Test Job
runs-on: ubuntu-latest
needs: decide_run_test
if: ${{ needs.decide_run_test.outputs.run_test == 'true'}}
defaults:
run:
working-directory: ${{ needs.decide_run_test.outputs.workdir }}
steps:
- uses: actions/checkout@v4

- name: Setup db with docker and create tables
env:
PROJECT: ${{ inputs.project }}
run: |
if [[ ${PROJECT} == "common" ]]; then
base_dir="../"
else
mv config.sample.py config.py
base_dir="../.."
fi

docker compose --file ${base_dir}/compose/dependencies_external/compose.yaml up -d

while ! mysqladmin ping -h 127.0.0.1 -u root -ppassword --silent; do
sleep 1
done

if [ -d SQL ]; then
for file in SQL/*.sql; do
mysql -h 127.0.0.1 -u root -ppassword integrations_db < ${file}
done
fi

# Add common SQL
for file in ${base_dir}/common/SQL/*.sql; do
mysql -h 127.0.0.1 -u root -ppassword integrations_db < ${file}
done

- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: "2.1.3"

- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local

- uses: actions/cache@v3
id: cached-poetry-dependencies
name: Cache for the virtual environment based on the dependencies lock file
with:
path: ${{ format('{0}/.venv', needs.decide_run_test.outputs.workdir ) }}
key: venv-${{ hashFiles(format('{0}/poetry.lock', needs.decide_run_test.outputs.workdir )) }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install
poetry add pytest-github-actions-annotate-failures #Special package for github actions only

- name: Run tests with poetry
run: |
poetry run pytest -v
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: Lint Python Code - special linter
name: Lint changed files for quality and type errors

env:
mascot: Mona
super_duper_var: totally_awesome

on:
pull_request:
Expand All @@ -11,9 +15,27 @@ on:
workflow_dispatch:

jobs:
windows_job:
runs-on: windows-latest
steps:
- run: echo 'Hi ${{ env.mascot }}' # Hi Mona
- run: echo 'Hi ${{ env.mascot }}' # Hi Octocat
env:
mascot: Octocat

linux_job:
runs-on: ubuntu-latest
steps:
- run: echo 'Hi ${{ env.mascot }}' # Hi Tux

lint: # The name of the job
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v4

- uses: actions/setup-python@v5
Expand All @@ -34,21 +56,14 @@ jobs:
echo "$file was changed"
done

# - name: Install poetry
# uses: abatilo/actions-poetry@v4

# - name: Setup a local virtual environment (if no poetry.toml file)
# run: |
# poetry config virtualenvs.create true --local
# poetry config virtualenvs.in-project true --local

# - uses: actions/cache@v3
# name: Define a cache for the virtual environment based on the dependencies lock file
# with:
# path: ./.venv

# - name: Install dependencies
# run: poetry install
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(env) }}
run: echo "$JOB_CONTEXT"

#Ruff linter for checking. Replaces manual install and run.
- uses: astral-sh/ruff-action@v3
if: ${{ steps.changed-files.outputs.all_changed_files }}
with:
src: >-
${{ steps.changed-files.outputs.all_changed_files }}
58 changes: 29 additions & 29 deletions .github/workflows_orig/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@ name: Publish to PyPI
on:
push:
tags:
- '*.*.*'
- "*.*.*"

jobs:
publish:
runs-on: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[build]
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[build]

- name: Build package
run: python -m build
- name: Build package
run: python -m build

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Test publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TESTPYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Test publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TESTPYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ github.ref_name }} ./dist/* --generate-notes
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ github.ref_name }} ./dist/* --generate-notes
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ venv.bak/

# mypy
.mypy_cache/

config.py
27 changes: 27 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"editor.formatOnSave": true,
"editor.mouseWheelZoom": true,
"editor.formatOnSaveMode": "file",
"editor.wrappingIndent": "same",
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 120,
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "standard",
"python.analysis.fixAll": [
"source.unusedImports"
],
"python.analysis.completeFunctionParens": true,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
},
"ruff.nativeServer": "off",
"ruff.lint.enable": true,
"ruff.lint.run": "onSave",
"files.exclude": {
".ruff_cache": true
}
}
Empty file added common/README.rst
Empty file.
12 changes: 12 additions & 0 deletions common/SQL/hash_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE IF NOT EXISTS `nevvon_provider_hashes` (
`RECORD_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`employee_number` varchar(150) NOT NULL,
`phone_number` varchar(150) NOT NULL,
`provider_hash` varchar(150) NOT NULL,
`org_id` INT,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(),
deleted_at TIMESTAMP NULL
);
ALTER TABLE `nevvon_provider_hashes`
ADD CONSTRAINT UNIQUE(`org_id`, `employee_number`);
1 change: 1 addition & 0 deletions common/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.0'
Loading