Skip to content

Commit

Permalink
Add Makefile and start ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddie4k-code committed Nov 11, 2024
1 parent 9ba1502 commit ac17315
Show file tree
Hide file tree
Showing 7 changed files with 600 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
push:
branches:
- master
jobs:

python-unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set Up Python
uses: actions/setup-python@v4

- name: Run Python Unit Tests
run: |
make python_tests
changed-files:
runs-on: ubuntu-latest
needs:
- python-unit-tests
outputs:
files_matrix: ${{ steps.print-changed-files.outputs.files_matrix }}
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set Up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Run Python Unit Tests
run: |
make python_tests
- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@v45

- name: Print Changed Files
id: print-changed-files
run: |
make get_changed_files changed_files="${{ steps.changed-files.outputs.all_changed_files }}"
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.PHONY: get_changed_files python_tests

changed_files :=

get_changed_files:
python3 ./scripts/changed_files/changed_files.py $(changed_files)

python_tests:
python3 -m unittest discover -s ./scripts/tests -p "*.py"
14 changes: 14 additions & 0 deletions UserService/UserService.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
32 changes: 32 additions & 0 deletions scripts/changed_files/changed_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import json

"""
Identifies files that were changed to produce a matrix to run in git hub actions for updating the appropriate docker images.
"""

import sys

files = sys.argv[1:]

services = set(["auth-service", "sneaker-service", "order-service", "payment-service"])

"""
Generates a matrix of service names returning an array of strings
"""
def get_changed_files(files):

matrix = set()

for service in files:
service_directory = service.split("/")[0]

if service_directory in services:
matrix.add(service_directory)


return list(matrix)

changed_files = get_changed_files(files)

# Set as Output in github actions
print(f"::set-output name=files_matrix::{json.dumps(changed_files)}")
Loading

0 comments on commit ac17315

Please sign in to comment.